Let’s say I have an automation telling me “at least a window was left open” when I left home:
- alias: "Home: something was left unsecured before leaving"
hide_entity: true
trigger:
- platform: state
entity_id: group.family
to: not_home
condition:
condition: or
conditions:
- condition: state
entity_id: binary_sensor.door_window_sensor_kitchen
state: 'on'
- condition: state
entity_id: binary_sensor.door_window_sensor_bathroom
state: 'on'
- condition: state
entity_id: binary_sensor.door_window_sensor_office
state: 'on'
- condition: state
entity_id: binary_sensor.door_window_sensor_bedroom
state: 'on'
action:
- service: notify.chris_tts
data:
message: "Warning, at least one window was left open with nobody at home!"
My phone will use Google TTS service to tell me the given message just there. However, I’d like it to tell me WHICH windows were left open. The “dumb” way to do that would be to put as much automations as windows I have, but that would be redundant. Is there a way to intercept, in the action block, which conditions were on TRUE when the event triggered?
Any advice will be appreciated. Thank you very much!
it will do this, but only on first read, or on group state change. I fear it wont work when several of the entities change state, but the group state change doesn’t change because of that. Be interested to hear from @vanclec if it does in his setting?
with a little ‘smart’ naming for the locks or windows, you could use this:
{%-for state in states.binary_sensor
if 'lock' in state.entity_id and state.state == 'on' %}
{{state.name}}: {{state.state}}
{%endfor%}
{%-for state in states.sensor
if 'window' in state.entity_id and state.state == 'on' %}
{{state.name}}: {{state.state}}
{%endfor%}