Automated notifications for multiple zones

I’d like to have automation that sends a notification when I enter a zone.

Currently I have the below, which works for 1 zone.

Assume I have zone.one, zone.two, zone.three, what I’d like to do is to add the additional zones and have a dynamic notification instead of 3 scripts (one per zone)

I can’t quite work out how to pass multiple zones, and have this appear in the notification?

- id: 'Entering Zone'
  alias: Notification when entering Zone
  description: ''
  trigger:
  - entity_id: device_tracker.iphone
    event: enter
    platform: zone
    zone: zone.one
  condition: []
  action:
  - data:
      message: You're entering {{ state_attr('zone.one', 'friendly_name') }}
      title: Zone Notification
    service: notify.mobile_app_iphone
- id: 'Entering Zone'
  alias: Notification when entering Zone
  description: ''
  trigger:
  - entity_id: device_tracker.iphone
    event: enter
    platform: zone
    zone: zone.one
  - entity_id: device_tracker.iphone
    event: enter
    platform: zone
    zone: zone.two
  - entity_id: device_tracker.iphone
    event: enter
    platform: zone
    zone: zone.three
  condition: []
  action:
  - data:
      message: You're entering {{ trigger.to_state.attributes.friendly_name }}
      title: Zone Notification
    service: notify.mobile_app_iphone

Untested. but I have a simliar setup working:

- id: "1557405390202"
  alias: TeleG -  Notify lights on when not home
  trigger:
    - entity_id: light.chandelier
      platform: state
      to: "on"
    - entity_id: input_boolean.group_fan_state
      platform: state
      to: "on"
  condition:
    - condition: state
      entity_id: sensor.jim_home
      state: "false"
    - condition: and
      conditions:
        - condition: state
          entity_id: input_boolean.boolean_switch3
          state: "on"
  action:
    - data_template:
        message: Alert- "{{ trigger.to_state.attributes.friendly_name }}" turned on
      service: notify.habot

You may, or may not need to quote around the trigger variable.

I don’t think that will work. There’s no trigger.to_state for event triggers, only state triggers.

Thanks both.

I’ve added the zone (didn’t think to simply add additional triggers, I assumed I would need to add an array or something)

Reading through other posts on the forum (now I know what to search for), would the below be a solution if trigger.to_state doesn’t work.

Without heading out, I can’t test if the above suggestion works.

I don’t think so. That will only give your tracker name, not the zone.

Here’s a good example ( for both leaving and entering a zone):

Hmm good catch, didn’t realize that.

Looks to be almost the same though with trigger.zone replacing trigger.to.state.

Ok thanks. I’ve got both solutions set up, I’ll be heading out in the morning, let’s see which sends a notification :slight_smile:

Thanks to both, I went with the solution tom_l suggested, tried it this morning and it works a treat :+1: