I used to have a notification working that would tell me if I left anything open when my house alarm was ‘arming’. It hasn’t been working for a long time, but at one point a long time ago, it did work. I’d like to get it working again. Can anyone provide feedback on how I can loop over a list of entities and only return the ones with an ‘open’ state?
My old automation was this (I think it used to work because I used to be able to grab ALL entities with an ‘open’ state, but I really would like to be able to specify a select list of entities to get the states from):
- alias: alarm_arming_actions
initial_state: True
trigger:
- platform: state
entity_id: alarm_control_panel.house
to: 'arming'
action:
- service: notify.all_general
data_template:
message: >
House alarm activating, ensure all doors and windows are closed.
{% for state in states -%}
{% if state.state == 'open'%}
{{ state.name }} is open!
{%- endif -%}
{% endfor %}
For reference, in another automation, I found that I can trigger on a list of entities by placing them in their own .yaml file and calling it like this:
trigger:
- platform: state
entity_id: !include ../groups_by_file/alarm_trigger_sensor.yaml
to: 'on'
Is it possible to call that same .yaml file as a list to get the entity states from?