How to access the media source list in templates?

Hi, I’m using a sonos media_player. Before the introduction of Media Selector and the new Play media action in homeassistant 2022.3 I could access my favorites in templates with

The “source_list” has vanished so it doesn’t work any more. Now I would expect some kind of “media_source.myradio.favorites” call, but I couldn’t find anything in the documentation or comments.
Any help appreciated
Thanks in advance

Is there a new entity with an options list for your Sonos media player?

Also you should have been using {{state_attr('media_player.myradio', 'source_list' }} not {{states.media_player.myradio.attributes.source_list}}

Thanks for the reply. No, a select entity for Sonos does not exist. I presume the sourcelist query went to a more central point for the media selector and play media action, but if so, there is no documentation. Another possibility is the sonos integration is supposed to deliver a select entity, then this would be a bug.

What do you mean by this?

I believe they mean that the Sonos media player no longer has this:

Sure it does.

And your template.

Are your favourites still on that list?

I think that’s what is missing (I don’t have a Sonos player).

The entire source list is favorites only.

Exactly. This source list is exactly missing.

That what you see here is only available in the frontend, but not for programming/templating purposes.

Can you give an example use?

Not sure if your reference is the same, but the following works.

service: media_player.play_media
  media_content_id: "x-sonosapi-hls-static:ALkSOiGOqT4NOsTCYpKs5I5vEoOF85V3OqKmhZY5op7biKrQHlysYSU792MKCxopJDlkP6ZKvWP6seoJW-hIaQ?sid=284&flags=0&sn=13"
  media_content_type: music
  entity_id: media_player.living_room_2
1 Like

If that is shown as an attribute of the media player you most definitely should be able to access the list with:

{{state_attr('media_player.myradio', 'source_list') }}

Or if you want the third item from the list:

{{ state_attr('media_player.myradio', 'source_list')[2] }}

The following works as well.

service: media_player.select_source
  source: 1. T'Hits YouTube
  entity_id: media_player.living_room_2
1 Like

yeah, would be. but as mentioned it is not available as an attribute

I can see the source list is an attribute in Coolie’s image.

Share the full code you are using so we can see why it is not working.

that’s correct. that works for a single song/radio station/playlist.
But I need to access the whole list, e.g. for text2speech purposes to tell, what choice you have.

But the whole list is available.

Yes. But again, it is missing in my lsit

Does it show in Sonos App like below?

What does the template show?
{{ state_attr('media_player.living_room', 'source_list') }}

The app shows it similar to yours, the state_attr call fails as “source_list” does not exist.
I currently use the latest homeassistant version 2022.4.1. Which version do you use?