I’m new to Home Assistant and am trying to experiment with presence detection, automation and notifications. Basically I’ve set up Pushbullet on my iPhone, presence detection (with OwnTracks and CloudMQTT) and zones. I would like to get a notification when I leave or enter a zone, for instance the Home zone.
Each of these things are working individually. If I test PushBullet notifications from HASS they go to my iPhone. And the map shows my location and whether I am home, at work or away. But I am not getting notifications when I leave or enter my home zone. Also, if I manually trigger the automation from the from the HASS page the notification goes through to my phone.
I’m sure it’s probably something I missed with my automation but I can’t figure out what.
My zones.yaml:
name: Home
latitude: ****
longitude: ****
adius: 10
name: Work
latitude: ***
longitude: ***
radius: 100
My automations.yaml:
- alias: NotifyWhenHome
trigger:
platform: zone
entity_id: device_tracker.my_iphone
zone: zone.Home
# Event is either enter or leave
event: enter
action:
service: notify.iphone_pushbullet
data_template:
title: "Lucy, I'm home!"
message: "Is this thing on?"
- alias: NotifyWhenLeave
trigger:
platform: zone
entity_id: device_tracker.iphone_iphone
zone: zone.Home
# Event is either enter or leave
event: leave
action:
service: notify.iphone_pushbullet
data_template:
title: "I'm outta here!"
message: "I'll be surprised if this works!"
Well I hope that is not the real info provided, since it shows the your house and your work.
Try changng the radius, the gps is not accurate enough and will show in and out of the radius, plus take into account the yard, laneway, sidewalk. Tracking device joining your home network is probably easier and no battery drain. Used ddwrt to track the device joining the network.
In addition to what Hick Hackers suggested change “zone.Home” to “zone.home”.
I was notified recently that HomeAssistant is sensitive to the case of entities.
Can you see if the automation was ever triggered (listed in the states page)? It may be triggering but your notification isn’t working or the other way around.
also, click the pencil in the lower right of your post to edit your post. Then highlight your config text and click the < / > symbol above your post. This will make the forum maintain the formatting of your config so we can see if there are any spacing/indent errors.
Woops, Rookie mistake. Was multitasking when I posted. Redacted.
I will try using my network join as a test to see if it works that way. However the only way I’ll be able to to leave automations for work will be with zones.
I originally had it as “zone.home” and it didn’t work either. I then realized my zone was actually defined as “zone.Home” so I changed it to a capital H on the chance that it was case sensitive but still no joy.
I don’t see anything indicating that the automation triggered. I can see my device transition from home to away and back to home but no automations are firing.
try moving the action to be in line with trigger. You will need to move everything under action over also to maintain the formatting.
See an example below from my config text.
- alias: "Turn Off When Home"
trigger:
platform: zone
entity_id: device_tracker.iphone
zone: zone.home
event: enter
action:
service: homeassistant.turn_off
entity_id: group.away_automations
Also change “data_template” to just “data”
edit: Its easier to show you rather than type it all out. The component page show spacing as follows, its also what I use and have working.
action:
service: notify.iphone_pushbullet
data:
title: "I'm outta here!"
message: "I'll be surprised if this works!"
Actually I miss formatted it on the post. The action: is inline with trigger in my config:
- alias: NotifyWhenHome
trigger:
platform: zone
entity_id: device_tracker.iphone
zone: zone.Home
# Event is either enter or leave
event: enter # or "leave"
action:
service: notify.my_pushbullet
data_template:
title: "Lucy, I'm home!"
message: "I'll be surprised if this works!"
- alias: NotifyWhenLeave
trigger:
platform: zone
entity_id: device_tracker.iphone
zone: zone.Home
# Event is either enter or leave
event: leave # or "leave"
action:
service: notify.my_pushbullet
data_template:
title: "I'm outta here!"
message: "I'll be surprised if this works!"
- alias: NotifyWhenLeaveWork
trigger:
platform: zone
entity_id: device_tracker.iphone
zone: zone.Work
# Event is either enter or leave
event: leave # or "leave"
action:
service: notify.my_pushbullet
data_template:
title: "Leaving work!"
message: "I'll be surprised if this works!"
Will try changing “data_template” to “data” as you suggested.
So next battle: I can’t find an example of what I need to change in my automation for a trigger based on network connectivity. I’m using the Ubiquity component as that is what I have at home.
I have it successfully detecting if I’m home or away based on being connected but what do I change the trigger to in the automation.yaml? Right now it’s zone: but I need to use something else now that I’m using network detection I assume?
My home to not_home trigger is working but is very slow to react. It takes about fifteen minutes for HASS to tell that my device is away at which point it triggers the automation. So that’s some progress at least. I just have to see if I can get to be quicker. I’ll look at the Ubiquiti tracker to see if there is anything I can do to speed it up.
I just noticed a syntax error in my not_home to home automation so we’ll see if that works now that I’ve fixed it.
Ok, both triggers are working but not very timely. Takes about fifteen minutes after I’ve left or arrived before HASS detects I’ve left or arrived even though my phone joins or leaves the network much faster than that.
I’ve added an interval_seconds value of 60 but that hasn’t sped things up. No thanks sure if that even applies to the Ubiquiti.
So trying to get my first automation based on leaving a zone and seem to have the issue as @TheFourDees even though I am using iOS notifiations vs Pushbullet.
alias: 'Home Presence Notifications'
trigger:
platform: zone
entity_id: device_tracker.chris
zone: zone.home
event: enter
action:
service: notify.ios_chris_iphone
data:
title: "Presence Event"
message: "Chris has arrived left home."
data:
subtitle: "Home Location"
I have tested seperatedly the notify_ios service and it works. I also can see in the device updating (in mosquitto and in the HA frontend) to home. The frontend log shows “Chris is at home” change but the Automation for the zone.home does not seem to trigger and it doesn’t show up.
I been searching the forum and docs pages for hours and can’t seem to find the problem. Any ideas?