Yesterday I created 3 zones and 6 automations to notify when entering and leaving zones but didn’t received notifications.
I revised zones and I’ve seen zones are " Passive", I disabled option and today I received notifications for all, entering and leaving but only after I unlocked my phone, home assistant app was “sleeping” even if I disabled battery optimisation, maybe it’s possible to add some priority to blueprint?
So, it’s working, you can upload blueprint to github, thank you!
I modified that same blueprint and noticed that it does seem to work for zones other than the home zone. I changed the notification to use my telegram notify and that does work but again, there seems to be something about the home zone specifically that does not trigger this automation when running from a blueprint. I’ve set up a separate automation not using the blueprint and the home zone does seem to work. It’s a bit frustrating…
I found the official leaving zone blueprint doesn’t work for me. I tracked it down (thanks to the automation tracing) to the fact the state and name do not match case… trigger.from_state.state == home and states[zone.home].name == Home.
So, when the check of the state vs the zone name happen, it never matches as coming from THAT zone. It might only happen with certain device trackers (I’m using nmap for this example) or the default Home zone has some quirks.
Hi, it’s December 2022 as I type this. This is an old thread, but still has some value.
What I want:
A notification to my android Home Assistant app that a person arrived at a zone
How I did it:
add person in Home Assistant under Settings > People
install Android Home Assistant app in those people’s phones, enable notifications, vibrate, pop on screen, etc, enable location (of course)
create your target zone(s) in Settings > Area & Zones
open File Editor
navigate to /config/blueprints/automation/homeassistant
open notify_leaving_zone.yaml
copy all code from notify_leaving_zone.yaml
create a new file, name it notify_entering_zone.yaml
paste all code from notify_leaving_zone.yaml into the newly created notify_entering_zone.yaml
reverse the logic in line 37, from this
value_template: "{{ trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}"
to this
value_template: "{{ trigger.from_state.state != zone_state and trigger.to_state.state == zone_state }}"
and change the action text:
action:
- alias: "Notify that a person has left the zone"
domain: mobile_app
type: notify
device_id: !input notify_device
message: "{{ person_name }} has left {{ zone_state }}"
to this
action:
- alias: "Notify that a person has entered the zone"
domain: mobile_app
type: notify
device_id: !input notify_device
message: "{{ person_name }} has arrived at {{ zone_state }}"
Save changes
Navigate back to Settings > Automations & Scenes > Bluebrints
You should see your newly created Zone Entry Notification blueprint
Select “create notification” to create a new automation
Just tested (by pressing Run in the automation), it’s working. Crossing fingers that it works when the person actually enters
The quirk is that for all zones EXCEPT zone.home the device will report back the zone name (ie friendly name), while in zone.home the device will report back “home” rather than the friendly name, this poses some challenge to the blueprint as it needs to test for the special case zone.home being supplied as input.
I am (trying to) use this automation too and have the same problems as the posters above. I can run the automation manually and receive notifications. But when devices enter zones (even if they are not the home zone), nothing happens. When checking the logs of the autmation, I did see a trigger where
I replaced the blueprint with a normal automation from scratch:
alias: Me at the Office
description: ""
trigger:
- platform: zone
entity_id: person.rolf
zone: zone.office
event: enter
condition: []
action:
- device_id: f6f1e7XXXXXXXXXX32bf2
domain: mobile_app
type: notify
message: Rolf at Work
mode: single
Of course this is easiest with the graphical editor (or paste this script in yaml and then switch back to the UI to get a headstart on what to fill in where.
The normal automation seems to work more reliable than the blueprint for some reason. I also note that homeassistant, the browser and the app require some restarts/logins for some changes which to me seem like trivial. That could be an improvement.
I added a custom iPhone sound to the notification in the yaml (this cannot be done in the GUI):
alias: Me at the Office
description: ""
trigger:
- platform: zone
entity_id: person.rolf
zone: zone.office
event: enter
condition: []
action:
- device_id: f6f1e7XXXXXXXXXX32bf2
domain: mobile_app
type: notify
message: Rolf at Work
data:
push:
sound: 'shake.caf'
mode: single
I hope this helps others with these intermitting notification problems, although it is a bit frustrating that I did not get to why the blueprint does not work reliably.
Hi,
Being new to HA, this is my first automation. That said, I need som help, and wonder if someone here can help. I imported the blueprint, and created some automations from, using zones I created and my familys devices. But when I click Run, I get no notification.
I tried once with the built-in blueprint, for leaving zones. That notifications reaches me just fine. Should I make any adjustments for this to work in the same way? Have I misconfigured something? I get no error message, in HA it looks like tha notifications has gone through just fine.
I think that is intended behaviour. When I click run on the automation, I don’t get a notification either.
I do get an warning in the log, since when the automation is run without a trigger, there is no from_state.
When I manually change the state of the person entity in Developer Tools -> States, I do get a notification. Can you try that as well?
That works for me too. I set the state to “away” and got a notification. Today, however, when I had some actual movment between zones, I didn´t. Can I somehow try this in the same way, to trigger a notification both on leaving the current state of “home”, and entering another zone?
Yes, in history I can see the switched zones. Again this morning, I got a notification on a person entity (my daughter) leaving Home, but I didn´t get a notification for entering a new zone (school). Again, in history it shows, and in the current state, it also shows the correct zone.
Both my kids just came home from school. I got notifications for both entering the Home zone. But nothing for leaving the school zone.
So, for Home everything seems ok, but for no other zones. Thoughts?
I got a notification both when leaving and entering my home zone today. I’ve now created a notification at another zone and will see tomorrow if it works. When I test that zone with the developer tools it gives me notifications as well.
Do you have any entries in the log about the blueprint?
Also, when you change the state of your person from home to other_zone, do you get two notifications? (Assuming you have two automations set up, one for home, and one for other_zone)