Help Sending ID with Water Leak Detected

I finally got my water sensors working. I’m trying to create a single automation to handle everything.

How can I edit my yaml to send the location of the water sensor with the push alert as the mesage? i.e., is there a way to assign an id to the device and use that id as the message for the send notification?

Here is my automation config. I’m new to this, so definitely a learning curve. Thanks for any help you can provide.

alias: Water Sensor - Water Leak Detected
description: ''
trigger:
  - type: moist
    platform: device
    device_id: 305a586d9f7660dfac8e421888e6cda0
    entity_id: binary_sensor.water_sensor_erics_office_bathroom_ias_zone
    domain: binary_sensor
    id: Eric's Office Bathroom
  - type: moist
    platform: device
    device_id: f48d914ab2ed693ceaa93bcfe50a6526
    entity_id: binary_sensor.water_sensor_laundry_room_ias_zone
    domain: binary_sensor
    id: Laundry Room
  - type: moist
    platform: device
    device_id: 90d88c26231a882710d48f484da4c773
    entity_id: binary_sensor.water_sensor_lucas_bathroom_toilet_ias_zone
    domain: binary_sensor
    id: Luca's Bathroom Toilet
  - type: moist
    platform: device
    device_id: 57cd079b8647ba2cf39a3b8b21f03c49
    entity_id: binary_sensor.water_sensor_powder_room_ias_zone
    domain: binary_sensor
    id: Powder Room
  - type: moist
    platform: device
    device_id: 5881155ba2f78eba845e6483ef094e85
    entity_id: binary_sensor.water_sensor_water_heaters_ias_zone
    domain: binary_sensor
    id: Water Heaters
condition: []
action:
  - service: notify.notify
    data:
      message: {{ trigger.id }}
      title: Water Leak Detected
      data:
        push:
          sound:
            name: default
            critical: 1
            volume: 1
mode: single

Simple mistake; you forgot to include quotes for the template.

Change it to this:

      message: '{{ trigger.id }}'

If you’re interested, you can also do this:

alias: Water Sensor - Water Leak Detected
description: ''
trigger:
  - platform: state
    entity_id:
      - binary_sensor.water_sensor_erics_office_bathroom_ias_zone
      - binary_sensor.water_sensor_laundry_room_ias_zone
      - binary_sensor.water_sensor_lucas_bathroom_toilet_ias_zone
      - binary_sensor.water_sensor_powder_room_ias_zone
      - binary_sensor.water_sensor_water_heaters_ias_zone
condition: []
action:
  - service: notify.notify
    data:
      message: '{{ trigger.to_state.attributes.friendly_name }}'
      title: Water Leak Detected
      data:
        push:
          sound:
            name: default
            critical: 1
            volume: 1
mode: single

Thanks, that got it working. @123 I may change to the one you suggested. I have 10 more sensors coming (want to put one under every toilet/sink since the builder used the push on valves that are known to pop off sometimes).

Now I gotta figure out why I get a notification from both HomeKit and Home Assistant.

Glad to hear it solved the problem.

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions. For more information, refer to guideline 21 in the FAQ.