You may also need to add an Event Trigger for startup. As you may already know, any options you set with the set_options
service call will not survive a restart. So you may want the automation to execute on startup to ensure the input_select is loaded with the desired options and not its default ones.
Fo volumio I solved this setting up initial value of input_select to some already known list⌠but indeed here I expect this to be more dynamic, so manaully updating configuration does not kmake sense
My aim with this post was to get a selection from the list in the input_select and copy that into an input_text. I had thought it was necessary to have 2 actions in the automation but I was over-complicating it. With your assistance I now have this working to do this:
alias: Album Select
description: ''
trigger:
- platform: state
entity_id: input_select.tunes
condition: []
action:
- service: input_text.set_value
target:
entity_id: input_text.folderlist2
data_template:
value: '{{ states.input_select.tunes.state }}'
mode: single
Of course the ultimate aim was to select firstly a category (Pop Modern, Classical etc.) then an album (or folder) name and play the content. I have another automation that plays the tracks within one particular folder but have now realised that I would need to have a folder sensor for every album. In my case that would be hundreds. Not practical.
This all comes about because the Media Browser in core can only play a single selection. No random continuous play or sequential play of tracks.
Maybe I just need to wait for the next step in the development of the Media Browser to become a comprehensive player.
Two things:
data_template
was deprecated in favor of data
many versions ago. It still works but is now considered to be archaic, especially when the service call also employs target
which is a comparatively new term.
The preferred method of getting an entityâs state
value is to use the states()
function.
alias: Album Select
description: ''
trigger:
- platform: state
entity_id: input_select.tunes
condition: []
action:
- service: input_text.set_value
target:
entity_id: input_text.folderlist2
data:
value: "{{ states('input_select.tunes') }}"
mode: single
Ok. Thanks for the updating.
Just found your suggestion and it works! Unfortunately I get duplicates in the generated list so it throws an error. Is there a simple way to ignore or filter out duplicates when piping the list command, or do I have to loop?
Answer: {{state_attr(âlight.wledâ, âeffect_listâ)|unique|list}}
The original example involved an Input Select so I was going to ask how/why do you have duplicates in an Input Select but I now see you are using a lightâs attribute.
Hehe, yes, not exactly the same problem, but I noticed that you seem to be both very helpful and know your stuff, so I took a chance. After some continued jinja trial and error I was lucky to fix it by myself, but I appreciate your fast response nevertheless!