Hey all,
I am about 85% finished doing a project - getting HASS to control the Synology AudioStation - trying to keep a complicated task simple - but it has all come unstuck with regards to selecting the remote players available. I want this to be seamless and automatic, as this is the real archilles heel of the system.
My goal is to achieve this example below (from https://www.home-assistant.io/components/input_select/) - but using a template for the options - note the bit: options: [“Item A”, “Item B”, “Item C”]
# Example configuration.yaml entry
automation:
- alias: example automation
trigger:
platform: event
event_type: MY_CUSTOM_EVENT
action:
- service: input_select.set_options
data:
entity_id: input_select.who_cooks
options: ["Item A", "Item B", "Item C"] <-- this bit
So - my automation script goes like this - basically the same, but defining the options using a template instead:
update_synoplayers:
alias: Update Synology Audio Players
sequence:
- service: shell_command.syno_audio_controls ## Updates 'sensor.synoplayers'
data:
action: updatePlayers
prot: any
room: any
id: all
- delay: '00:00:05'
- service: input_select.set_options
data_template:
entity_id: input_select.syno_players
options: '[ "NotSet", "{% if states.sensor.synoplayers.attributes.data.players[0] %}{{ states.sensor.synoplayers.attributes.data.players[0].name }}"{% endif %}{% if states.sensor.synoplayers.attributes.data.players[1] %}, "{{ states.sensor.synoplayers.attributes.data.players[1].name }}"{% endif %}{% if states.sensor.synoplayers.attributes.data.players[2] %}, "{{ states.sensor.synoplayers.attributes.data.players[2].name }}"{% endif %}{% if states.sensor.synoplayers.attributes.data.players[3] %}, "{{ states.sensor.synoplayers.attributes.data.players[3].name }}"{% endif %}{% if states.sensor.synoplayers.attributes.data.players[4] %}, "{{ states.sensor.synoplayers.attributes.data.players[4].name }}"{% endif %}{% if states.sensor.synoplayers.attributes.data.players[5] %}, "{{ states.sensor.synoplayers.attributes.data.players[5].name }}" {% endif %} ]'
The template seems 100% fine, and I get no errors - this is how it looks in the templating section:
options: ‘[ “NotSet”, “TV_LCD60”, “Kodi_Lounge (DLNA)”, “Kodi_Lounge (AirPlay)”, “Multiple AirPlay Devices” ]’
My only issue - is that the input selector comes out looking like this (image below, this appears as the single option when I click it)… The template is clearly being parsed correctly but not accepted as an array for the Options
Can anyone tell me what I am doing wrong? Or perhaps inform me that ‘data_template’ doesn’t work here, saving me days of trial and error ?
Many thanks if you have even read this far!
Regards
Matt