Water leak notification with sensor name

Hi there,

I am trying to get notifications if my sensors detect water leakage. The sensors are aqara, connected via deconz. This is my action in the automation:

service: notify.mobile_app_mantass_iphone
data:
  message: 'Water leak somewhere {{ trigger.to_state.attributes.friendly_name }}'

I have tried both data and data_template, when I run the automation I get this error in my logs (and I do not receive the notification):

Error while executing automation automation.water_leak_alerts: Error rendering data template: UndefinedError: 'dict object' has no attribute 'to_state'
Error while executing automation automation.water_leak_alerts: Error rendering data template: UndefinedError: 'dict object' has no attribute 'event'

I do not know what am I doing wrong. I tried running it without making any sensors wet, and then took one sensor, put it in a bowl of water so it runs automatically, but the automation is just not working. If I remove the friendly_name attribute, meaning just to have it send me a message without any additional info, it works like a charm. Any help is very much appreciated.

try replacing data: with data_template:

I did, like I said in the original post. Did not help.

I literally copy/pasted your code and it works fine on my system, but I used something with a known state trigger… are you using a device event trigger?

This is my trigger.

  alias: Water leak alerts
  description: ''
  trigger:
  - entity_id: binary_sensor.washer_water_leak_sensor
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: binary_sensor.sink_water_leak_sensor
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: binary_sensor.kitchen_water_leak_sensor
    from: 'off'
    platform: state
    to: 'on'
  - entity_id: binary_sensor.dishwasher_water_leak_sensor
    from: 'off'
    platform: state
    to: 'on'
1 Like

That is a standard state trigger, so I have no idea why my system works and yours does not. What version of HA are you running?

core-2021.4.4. Everything is running the latest version - addons, hacs.