I adjusted a template I found on this forum to get an alert when a person enters a zone. The reason for sharing this blueprint is:
- When using the zone entering template, it only works for GPS trackers. The blueprint below works for Persons.
- You can configure the sound of the (iPhone) notification.
Things to pay attention to to get this working:
- Make sure all system notification sounds are imported in the Home Assistant Companion app
- Restart home assistant after creating the automations
- Log all users out, and in again on the phones so that they get all zone info
blueprint:
name: Zone Entering Notification
description: Send a notification to a device when a person enters a specific zone.
domain: automation
input:
person_entity:
name: Person
selector:
entity:
domain: person
zone_entity:
name: Zone
selector:
entity:
domain: zone
notify_device:
name: Device to notify
description: Device needs to run the official Home Assistant app to receive notifications.
selector:
device:
integration: mobile_app
ios_sound:
name: Notification sound
description: Notification sound for iOS (Optional). Default <US-EN-Morgan-Freeman-Someone-Is-Arriving.wav>
default: US-EN-Morgan-Freeman-Someone-Is-Arriving.wav
selector:
select:
mode: dropdown
custom_value: true
options:
- shake.caf
- Tink.caf
- Swish.caf
- US-EN-Morgan-Freeman-Someone-Is-Arriving.wav
- US-EN-Morgan-Freeman-Motion-Detected.wav
- US-EN-Daisy-Back-Door-Motion.wav
- US-EN-Daisy-Front-Door-Motion.wav
- US-EN-Alexa-Motion-Detected-Generic.wav
trigger:
platform: state
entity_id: !input person_entity
variables:
zone_entity: !input zone_entity
# This is the state of the person when it's in this zone.
zone_state: "{{ states[zone_entity].name }}"
person_entity: !input person_entity
person_name: "{{ states[person_entity].name }}"
condition:
condition: template
value_template: "{{ trigger.from_state.state != zone_state and trigger.to_state.state == zone_state }}"
action:
domain: mobile_app
type: notify
device_id: !input notify_device
message: "{{ person_name }} has entered {{ zone_state }}"
data:
push:
sound: !input ios_sound