Hi,
I have been playing a bunch with HA today - probably spent to much time doing it but I am having some issue which I suspect are due to my own logic - in terms of thinking through things.
I have a few automations & none of them working. I can see the state changes but i cant figure why its not working.
I started with a basic - trigger is life360 reporting tim is away & when he is home for 1 minute to send an email. That didnt work.
Then I tried the same thing but added a condition of tim being home. I am not sure why it didnt work - I think it looks like it should but I am missing something (clearly).
Any help would be great
JD
alias: tim - life360 Notification - Away to Home
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.tim
from: null
to: home
for:
hours: 0
minutes: 1
seconds: 0
condition:
- condition: zone
entity_id: device_tracker.tim
zone: zone.home
action:
- service: notify.gmail
data:
message: tim - Life360 - tim was Away and has now come home
title: >-
tim- Life360 - tim was Away and has now come home {{
now().strftime('%m-%d-%Y at %H:%M %p') }}
target: [email protected]
mode: single
alias: Tim - life360 Notification - Arrived at School
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.Tim
from: null
to: HS
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action:
- service: notify.gmail
data:
message: Tim - Life360 - tim has arrived at school
title: >-
Tim - Life360 - Tim has arrived at school {{
now().strftime('%m-%d-%Y at %H:%M %p') }}
target: [email protected]
mode: single
Thank you again for helping - i have four different versions of the automation & I cant get any of them to work.
I do see the changes in life360 and HA showing Tim at home, Tim at School, etc - the automations just arent starting - I am not sure why?
alias: Tim - life360 Notification - Home to Away
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.Tim
from: home
to: not_home
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action:
- service: notify.gmail
data:
message: Tim - Life360 - Tim was home and has now left
title: >-
Tim - Life360 - Tim was home and has now left {{
now().strftime('%m-%d-%Y at %H:%M %p') }}
target: [email protected]
mode: single
alias: Tim - life360 Notification - Away to Home
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.Tim
to: home
for:
hours: 0
minutes: 1
seconds: 0
action:
- service: notify.gmail
data:
message: Tim - Life360 - Tim was Away and has now come home
title: >-
Tim - Life360 - Tim was Away and has now come home {{
now().strftime('%m-%d-%Y at %H:%M %p') }}
target: [email protected]
mode: single
alias: Tim - life360 Notification - Away from HS
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.Tim
from: John Jay HS
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action:
- service: notify.gmail
data:
message: Tim - Life360 - Tim has left school
title: >-
Tim - Life360 - Tim has left school {{
now().strftime('%m-%d-%Y at %H:%M %p') }}
target: [email protected]
mode: single
alias: Tim - life360 Notification - Arrived at HS
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.Tim
to: HS
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action:
- service: notify.gmail
data:
message: Tim - Life360 - Tim has arrived at school
title: >-
Tim - Life360 - Tim has arrived at school {{
now().strftime('%m-%d-%Y at %H:%M %p') }}
target: [email protected]
mode: single
To confirm - when Tim gets to school - it should run after 1 minute of him being there?
If I remove the 1 minute - as soon has he gets there it should send the email?
Without the for duration it would run the second the zone changes to meet the criteria. You would have to remove the whole section. If you use a for statement, the state should not change for that long. Any short interruption aborts or restarts the timer.
Also note that school and not_home are different states. Theoretically one could change from any zone to any other zone. So only use from: if you really need it (leaving) and only use to: when you really need it (entering).
If it is unavailable you are worried about, use not_from: unavailable or not_to: unavailable
Ideally when Tim gets to school I would like an email so then the “to” is all I need - dont need a from for that one automation? The ‘from’ would be deleted or the ‘from’ would be one of these drop down options:
Any State
Home
Away
Unavailable
Unknown
Im a little confused as I would think - for me anyway - When Tim arrives at school (removing the 1 minute) - I get an email. That is with the “TO” school and “from” is blank.
Are you saying I should put the from unavailable vs leaving it blank?
The example you have, with only to: and no from: in the yaml is fine. I commented on the one with both a to: and a from: line in the yaml as being overly cautious. A to: line in the yaml that is blank may our may not be the same as no line at all, I know for sure omitting the whole line works as expected (don’t test it). I do advise not_from: unavailable to avoid mail after a restart of HA.
This should be fine… except for one thing I just noticed: device_tracker.Tim can’t be right, it should be all lower case. You had that in earlier examples, but there you had the from: null giving you trouble. So make sure you have the right entity. Personally I’d use person.tim (if that is the right person entity) and make sure all the right device trackers are linked to that person.
For some reason this isnt working - i think that either home / school isnt setup correctly - meaning that the zone ‘home’ in HA is not the same as ‘home’ in life360.
Same with the school. It sounds like the automation is correct but if it is still not working then ‘home’ isnt right.
You can see the state of the device tracker or person in the developer tools, this shows the exact values you need to test for. It uses zones in HA, not those in life360 afaik. But did you already fix the wrong entity id I mentioned?