HI,
I use several automations that check the state-change of the entity-id’s of a group and then call an action.
Right now, i have to state all individual entities, and cant just state the group (cause the automation than uses the group.state)
Can’t i somehow use a template with a for-statement?
for entity_id in group, check state change, action…
Example automation:
# Call Summary after Lights change
- alias: 'Sense Lights change'
id: '1511601488008'
# hide_entity: True
initial_state: 'on'
trigger:
platform: state
entity_id: 'light.dining_corner,light.dining_table_lamp_1,light.dining_table_lamp_2,
light.dining_table_lamp_3,light.kist,light.cabinet,light.home_theater,
light.corridor_cabinet,light.bedside_table,light.lounge_chair_long,
light.drawer,light.gamer_den,light.table,light.bureau,light.inside,
light.outside,light.hue_go_1'
condition: []
action:
- service: python_script.anything_on
- delay: 00:00:02
- service: python_script.summary
All the above lights are in group.all_lights, so i’d rather use something along the lines of:
# Call Summary after Lights change
- alias: 'Sense Lights change'
id: '1511601488008'
# hide_entity: True
initial_state: 'on'
trigger:
platform: state
entity_id: {{states.group.all_lights_only.attributes.entity_id}}
condition: []
action:
- service: python_script.anything_on
- delay: 00:00:02
- service: python_script.summary
Which would make it so more robust, and even more importantly , would never need the automation to change, if I change the group members…
Ive checked everywhere i can think of in the doc’s but no mentioning of this at all.
trying to get this working…
{% for attr in states.group.all_lights_only.attributes.entity_id %}
{{ states.{{attr}}.state }}
{%endfor%}
Please have a look? Thanks!
Marius