Trying to create a switch group
helper for a bunch of switches that control chargers around the house. All the chargers are labeled with chargers
- no matter what the jinja incantation it keeps throwing errors.
What am i doing wrong?
switch:
- platform: group
entities: "{{ label_entities('chargers') | list }}"
Invalid config for 'group' from integration 'switch' at configuration.yaml, line 141: Entity ID {{ label_entities('chargers') | list }} is an invalid entity ID for dictionary value 'entities', got "{{ label_entities('chargers') | list }}"
Where Should I use Templates?
Templates are not valid there.
where have you been all my life.
ended up creating a template switch to get around it.
- platform: template
switches:
all_chargers:
friendly_name: "All Chargers"
unique_id: "eaa51bb5-88e8-4810-92ff-8b3591746bf4"
value_template: >
{{ expand(label_entities('chargers')) | selectattr('state', 'eq', 'on') | list | count > 0 }}
turn_on:
service: switch.turn_on
target:
entity_id: "{{ label_entities('chargers') | list }}"
turn_off:
service: switch.turn_off
target:
entity_id: "{{ label_entities('chargers') | list }}"
icon_template: >
{% if this.state == 'on' %}
mdi:flash
{% else %}
mdi:flash-off
{% endif %}
1 Like