send notification to a person when i arrive at home.zone only when i leave my work.zone
The issue is that you will not be going directly from the “work” zone to "home, so you either need a proxy to represent that you were at work. You could use something like the History stats sensor-based condition given in this post.
You could use a Wait action.
trigger:
- platform: zone
entity_id: person.1
zone: zone.work
event: leave
condition: []
action:
- alias: "Wait for me to get home"
timeout: "01:00:00"
continue_on_timeout: false
wait_for_trigger:
- platform: zone
entity_id: person.1
zone: zone.home
event: enter
- service: notify.YOUR_NOTIFIER
data:
message: abcd
title: abcd
Note that waits do not survive restarts or reloads of automations so this method is not 100% reliable. If your commute is long and/or the notification is critical you will need to find an alternative.If you try this method, make sure to set the timeout as low as is reasonably possible for your commute.
Like this?
- platform: zone
entity_id: device_tracker.iphone_van_mieneke
zone: zone.de_zijlen_leek
event: leave
condition: []
action:
- alias: Wait for me to get home
timeout:
hours: 0
minutes: 20
seconds: 0
milliseconds: 0
continue_on_timeout: false
wait_for_trigger:
- platform: zone
entity_id: device_tracker.iphone_van_mieneke
zone: zone.home
event: enter
- service: notify.mobile_app_iphone_van_jc
data:
message: Ben bijna thuis
title: Mieneke```
What happens in the timeout time? Do i need to get home in that period of time?
A safer and perhaps more reliable way of doing it is to turn on a boolean when you leave work.
Then this boolean is a condition to send the message.
This does not wait and will work for days and even after restarts.
description: ""
mode: single
trigger:
- platform: zone
entity_id: device_tracker.iphone_van_mieneke
zone: zone.de_zijlen_leek
event: leave
id: leave
- platform: zone
entity_id: device_tracker.iphone_van_mieneke
zone: zone.home
event: enter
id: home
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: leave
sequence:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.left_work
- choose:
- conditions:
- condition: trigger
id: home
- condition: state
entity_id: input_boolean.left_work
state: "on"
sequence:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.left_work
- service: notify.mobile_app_iphone_van_jc
data:
message: Ben bijna thuis
title: Mieneke
Yes, when using the wait for trigger you need to set the timeout to a reasonable length of time for you to get home.