I want to do an automation for the humidity value of several sensors I have. I can get it to run if I do not show the current value of the sensor but I am trying to show it.
This is the current automation:
alias: "Notify: Humedad muy alta!"
trigger:
- type: humidity
platform: device
device_id: device-id-1
entity_id: sensor.entity_2
domain: sensor
id: room1
above: 10
- type: humidity
platform: device
device_id: device-id-2
entity_id: sensor.entity_2
domain: sensor
id: room2
above: 10
- type: humidity
platform: device
device_id: device-id-2
entity_id: sensor.entity_3
domain: sensor
id: room3
above: 20
condition: []
action:
- service: notify.mobile_app_my_phone
data:
message: |
The current humidity is of {{ states(trigger.entity_id) }}%
title: Humidity in {{ trigger.id }} is too high!
data:
actions:
- action: URI
title: To Home Dashboard
uri: /lovelace-humedad/default_view
mode: queued
max: 10
I get this error:
Error while executing automation automation.humedad_muy_alta: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘entity_id’
I thought the trigger would carry all the info defined in the trigger object but looks like it is not the case (?).
How can I access the value of the trigger sensor dynamically?
As a bonus question, which is the best way to debug this? For example, how can I know what the trigger object contains or what properties are accessible in that context? I can move myself with javascript and typescript but I have negative knowledge of yaml or phyton.
Thanks!