Hi,
I’m running my head against the wall with the below automation.
I want to see what triggers the automation and then send a message depending on which trigger, triggered the automation.
I can’t seem to find any examples on this, only ones with friendly name, but i cannot use that because i use dynamic friendly names on two of the triggers.
- alias: Notify - Presence Home
trigger:
platform: state
entity_id: sensor.status_family, sensor.status_jeppe, sensor.status_kitt
to: 'home'
action:
service: notify.pushoverjeppe
data_template:
title: "Hass.io - Presence Home"
message: >
{% if trigger.entity_id == sensor.status_family %}
{{ "All home." }}
{% elif trigger.entity_id == sensor.status_jeppe %}
{{ "Jeppe is home." }}
{% elif trigger.entity_id == sensor.status_kitt %}
{{ "Kitt is home." }}
{% endif %}
Thank you very much for your inputs on this!
Cheers!
It’s not really a feature, it’s just using a dictionary to map known names to known responses. Dictionaries can be used for anything. So what it’s doing is using a key to map to a phrase. In this instance we are mapping the entity_id ‘sensor.status_family’ to the phrase ‘All home’. to extract the information out of the mapper, we use []. So we use the variable trigger.entity_id as the key to extract the information, because trigger.entity_id should be equal to ‘sensor.status_family’, ‘sensor.status_jeppe’, or ‘sensor.status_kitt’. You’ll run into issues if you don’t have a map for an entity id thats in the trigger. Only way for this to happen is if you add an entity_id to your trigger but not your map.