In the action part of an automation, I can use {{ trigger.to_state.attributes.friendly_name }} in the message part of a notification.
If the automation contains one ore more conditions, how can I use the name (or other info) of this condition to be used in the message to be sent?
My automation, which does not work as the platform time does not has the to_state:
alias: Deur/poort open Informatie
description: Controlleert op een tijdstip, of er nog deuren of poorten open staan
trigger:
- platform: time
at: "09:11:00"
condition:
- type: is_open
condition: device
device_id: 3fd1069bead2701e31388937010a1568
entity_id: ccfb0b293558795247ab02051f43f471
domain: binary_sensor
enabled: false
action:
- service: notify.mail_to_<my name>
metadata: {}
data:
title: Deur open van ID={{ trigger.id }}
message: De {{ trigger.to_state.attributes.friendly_name }} is nog open
enabled: true
mode: single
I understand, I was not clear enough. In the future, several devices will be put in the condition section. Like the example below.
conditions:
- condition: or
conditions:
- condition: state
entity_id: "P01_Door garden"
state: "open"
- condition: state
entity_id: "P02_Door Shed"
state: "open"
- condition: state
entity_id: "P03_Door Garage"
state: "open"
In the mail message, I want the have the intity_id (or other info) from the door, which is open at the time given in the trigger section. For example, the email message should be “Deur open van P01_Door garden”.
I tried something like {{ condition.state.attributes.friendly_name }}, but that does not work.
This is not an entity id: entity_id: "P01_Door garden" nor are the others. The entity id will be like binary_sensor.something look in developer tools → states
No you can’t get that information from the conditions.
Create a group of your doors then use this in the message:
alias: Deur/poort open Informatie
description: Controlleert op een tijdstip, of er nog deuren of poorten open staan
trigger:
- platform: time
at: "17:27:00"
condition:
- condition: state
entity_id: binary_sensor.alle_deuren
state: "on"
action:
- service: notify.mail_to_<me>
metadata: {}
data:
title: Deur is open
message: >-
De volgende deur is nog open {{
expand('binary_sensor.alle_deuren')|selectattr('state','eq','on')|map(attribute='name')|list|join(',
') }}
enabled: true
mode: single
Where can I find the explaination if the line in the message?