Hi guys,
I have a problem. I have Person entities who have multiple GPS device trackers. Like OWT, Google and Life360.
I configured an automation that notify when it arrive of leave pre-configured zones.
The problem is that even if the state of the Person is already in a zone, I keep get messages for all the trackers a triggers to the automation. I tried to fix it with templating, but it still triggered multiple times.
I checked and the Person state hasn’t changed, only the device tracker state…
Any idea what am I doing wrong?
This is the automation:
- alias: 'family location notify'
id: 'familylocationnotify'
initial_state: true
mode: queued
trigger:
# For Home enter/leave events
- platform: zone
entity_id:
- person.boy
- person.girl
event: enter
zone: zone.home
- platform: zone
entity_id:
- person.boy
- person.girl
event: leave
zone: zone.home
# For School enter/leave events
- platform: zone
entity_id:
- person.boy
- person.girl
event: enter
zone: zone.school
- platform: zone
entity_id:
- person.boy
- person.girl
event: leave
zone: zone.school
action:
- choose:
- conditions:
- condition: template
value_template: >
{% if trigger.to_state.state == 'School' %} true
{% else %} false {% endif %}
sequence:
- service: notify.ha_notify_me
data:
message: "
{{ trigger.to_state.attributes.friendly_name }} Has Left School
Delivered by {{ trigger.to_state.attributes.source }}.
"
- conditions:
- condition: template
value_template: >
{% if trigger.from_state.state == 'School' %} true
{% else %} false {% endif %}
sequence:
- service: notify.ha_notify_me
data:
message: "
{{ trigger.to_state.attributes.friendly_name }} Has Left School
Delivered by {{ trigger.to_state.attributes.source }}.
"
- conditions:
- condition: template
value_template: >
{% if trigger.from_state.state != 'home' and trigger.to_state.state == 'home' %} true
{% else %} false {% endif %}
sequence:
- service: notify.ha_notify_me
data:
message: "
{{ trigger.to_state.attributes.friendly_name }} Has Arrived Home
Delivered by {{ trigger.to_state.attributes.source }}.
"
- conditions:
- condition: template
value_template: >
{% if trigger.from_state.state == 'home' and trigger.to_state.state != 'home' %} true
{% else %} false {% endif %}
sequence:
- service: notify.ha_notify_me
data:
message: "
{{ trigger.to_state.attributes.friendly_name }} Has Left Home
Delivered by {{ trigger.to_state.attributes.source }}.
"