notify_leaving_zone.yaml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. blueprint:
  2. name: Zone Notification
  3. description: Send a notification to a device when a person leaves a specific zone.
  4. domain: automation
  5. source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml
  6. input:
  7. person_entity:
  8. name: Person
  9. selector:
  10. entity:
  11. domain: person
  12. zone_entity:
  13. name: Zone
  14. selector:
  15. entity:
  16. domain: zone
  17. notify_device:
  18. name: Device to notify
  19. description: Device needs to run the official Home Assistant app to receive notifications.
  20. selector:
  21. device:
  22. integration: mobile_app
  23. trigger:
  24. platform: state
  25. entity_id: !input person_entity
  26. variables:
  27. zone_entity: !input zone_entity
  28. # This is the state of the person when it's in this zone.
  29. zone_state: "{{ states[zone_entity].name }}"
  30. person_entity: !input person_entity
  31. person_name: "{{ states[person_entity].name }}"
  32. condition:
  33. condition: template
  34. value_template: "{{ trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}"
  35. action:
  36. - alias: "Notify that a person has left the zone"
  37. domain: mobile_app
  38. type: notify
  39. device_id: !input notify_device
  40. message: "{{ person_name }} has left {{ zone_state }}"