Help with search in a state or attribute list

Hello
I have a little problem with my spotify automation. I have fibaro buttons in different rooms to start some music.
but the problem is selecting the source because I can have my Heos speaker grouped and then the source name changes, and the automation is bricked.

I can see the source list with the code

{{ state_attr('media_player.spotify_heos' , 'source_list')  | list | join (', ') }}

or a sensor I made

{{states('sensor.spotify_lista') }}

with output a list like

“flyttbar, badrum + kitchen, hemmabio, kattrum, veranda”

so if my automation wants to play in the kitchen it must search and see that the source is “badrum + kitchen”

any idea how it can be done?

Copy-paste the following template into the Template Editor and confirm it reports the correct source.

{{ state_attr('media_player.spotify_heos', 'source_list')  | list | select('search', 'kitchen') | first }}

If it does then you can incorporate it into your automation.

Thanks it works lika a charm :grin:

1 Like