action:
- alias: Notify that a person has left the zone
  device_id: !input 'notify_device'
  domain: mobile_app
  message: '{{ person_name }} has left {{ zone_state }}'
  type: notify
blueprint:
  description: Send a notification to a device when a person leaves a specific zone.
  domain: automation
  input:
    notify_device:
      description: Device needs to run the official Home Assistant app to receive notifications.
      name: Device to notify
      selector:
        device:
          integration: mobile_app
    person_entity:
      name: Person
      selector:
        entity:
          domain: person
    zone_entity:
      name: Zone
      selector:
        entity:
          domain: zone
  name: Zone Notification
  source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml
condition:
  condition: template
  value_template: '{{ trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}'
trigger:
  entity_id: !input 'person_entity'
  platform: state
variables:
  person_entity: !input 'person_entity'
  person_name: '{{ states[person_entity].name }}'
  zone_entity: !input 'zone_entity'
  zone_state: '{{ states[zone_entity].name }}'
