well not sure, that’s why I asked. But maybe it isn’t necessary.
Ive entered the template in my setup to see what happens. added the entity_id’s in the sensor, so the state changes on each input_boolean state change.
was wondering of we can use an empty list to initiate the template too? dev-template doesn’t object.
but won’t make the group correctly either. this doesn’t work, because it also adds the ‘,’ with 1 entity_id only:
{% set rooms = ['woonkamer','hall','master_bedroom','hobbykamer','office','dorm_marte'] %}
{% set ns = namespace(speakers = '') %}
{% for i in range(rooms | length) %}
{% if states('input_boolean.player_' ~ rooms[i]) == 'on' %}
{% set ns.speakers = ns.speakers ~ ' media_player.googlehome_' ~ rooms[i] + ',' %}
{% endif %}
{% endfor %}
{{ ns.speakers }}
SO need to test for only 1 entity_id (to not add the comma) and need a safegard against the empty list, and consequently a none for the sensor…
it does complain against my group…;-((
Testing configuration at /config
Failed config
group:
- Invalid config for [group]: Entity ID {{states('sensor.media_players_on')}}
is an invalid entity id for dictionary value @ data['group']['media_players_on']['entities']. Got ["{{states('sensor.media_players_on')}}\n"]. (See /config/configuration.yaml, line 57). Please check the docs at https://home-assistant.io/components/group/