When I try to use it in an automation it fails with Error loading /config/configuration.yaml: while scanning for the next token found character ‘%’ that cannot start any token
- alias: 'kitchen_vol_down'
trigger:
platform: state
entity_id: binary_sensor.kitchen_vol_down
from: 'off'
to: 'on'
action:
service: media_player.volume_down
entity_id:
data_template: >
{% for sonos in states.media_player.kitchen.attributes.sonos_group %}
' {{sonos }}'
{% endfor %}
I have tried all sorts of options and searched the web for hours. Welcome some advice please.
Regards David
That appears to be acceptable for use with entity_id except that the result of any template is always a string value. That means the python list gets converted to a string; those square-brackets lose their special meaning (indicating they delimit a python list). Now seen as a string to entity_id, those square brackets become invalid characters.
The addition of the join filter converts the python list to a string and places commas between each of the list’s items: