#Trigger a notification when my GF leaves work

1 messages · Page 1 of 1 (latest)

finite chasm
#

Hi! I'm having troubles writing what I thought it would be a very easy automation.
I want to have a notification on my Echo Show when my GF leaves work, so I can start preparing coffee for when she gets home.

I want the automation to trigger ONLY if she's been at work for at least 1 hour, and then leaves, so

  1. person.girlfriend = Workplace --> 1 or more hours passed --> person.girlfriend = Away --> TRIGGER AUTOMATION
  2. person.girlfriend = Workplace --> person.girlfriend = Away --> DOES NOT TRIGGER (maybe she passed next to the workplace with the car, I don't want random notifications triggering while I'm smart working at home)

I was doing something like this

alias: Exit from work after at least 1 hour
description: Exit from work after at least 1 hour
triggers:
  - entity_id: person.gf
    from: Workplace
    to: Away
    trigger: state
conditions:
  - condition: template
    value_template: >
      {{ (as_timestamp(now()) - as_timestamp(states.person.gf.last_changed)) >
      3600 }}
actions:
  - action: notify.alexa_media_echo_show
    data:
      message: "\"GF is out of work!\""
      data:
        type: announce
mode: single

but that of course isn't working 😦 any idea?

rose void
#

to: Away is not correct.
Away is a state translation of not_home, which is the default state of a person who is not in any other zone.

#

it should be: to: not_home

finite chasm
#

the rest should be ok? 😮

rose void
#

I didn't carefully review, just pointed out one issue I noticed.

finite chasm
#

ah, k 😉

#

thanks tho 🙂

rose void
#

Sure. Try it out and see what happens

#

looks reasonable at first glance

burnt grove
#

Why not leave the to altogether? And what are you trying to do with the condition? As the automation is triggered on a change of person.gf the last_changed will never be more then 5 minutes ago...

rose void
#

I guess you'd want to look at trigger.from_state.last_changed, since you want the state from before the automation triggered.

past hamlet
#

I personally like this blueprint for such automations.

https://community.home-assistant.io/t/zone-notification-extended/538732

#

To announce on your Echo Show use the custom actions in that blueprint.