Expose media_player.async_browse_media as a service #1079
-
The topic of this discussion is to consider extending the entity model to expose the existing media_player.async_browse_media method as a service call. This method call is currently exists and is used by the media browser through a websocket interface. The change is to expose this as a service call with a return value, There is a draft pr here: The purpose is to allow automations to access the service to browse for media (just as you can do from the UI) and then use the return values to do other actions. As an example, here is an automation that gets a list of the albums by the Beatles and randomly plays one. This is using a Sonos music library.
Here is a sample of the YAML returned when running the browse_media service from developer tools / services
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 10 replies
-
I'm interested in seeing this as a potential option for browsing media for future input into multi-modal LLMs. A couple thoughts:
|
Beta Was this translation helpful? Give feedback.
-
We were discussing a media library search service for the squeezebox integration at home-assistant/core#127824 and @joostlek asked me to comment over here ..... Could you maybe explain your thoughts on the media_content_id structure. The media browser architecture is a browser unless I've missed something, so you're always navigating through a set of known content and their ids. For a service like this to be useful, wouldn't you need to know the media_content_id and the structure of that? I think that's end point specific, and in the case of the squeezebox integration, is a numeric string - e.g. an artist id might be 121423. I think we might need async_search_media - something to which you could pass a search string and media content type. This I think would then let us expose a more useful service, but could also be implemented in the media browser UI itself, which would greatly increase useability of the browser - I have over a thousand of albums with 10's of thousands of tracks and the current browser ui without search isn't useable for me. Search would make a big difference to its usefulness IMHO. |
Beta Was this translation helpful? Give feedback.
-
I like the idea of search as an action. You are correct that the existing browse interface is a hierarchy that you navigate and get the content ids. If you specify no content id the integration will return its top level content ids. The use cases that i'd like to enable (play a random album by the Beatles) would work with either search or browse. Certainly there are a set of use cases that would not work well with browse (find all songs with the word love in it) The advantage of the browse interface is that it is already implemented by many integrations and we'd just need to expose the existing interface as a service and then the existing implementations just work. However, if the decision is to create a search interface. Id be happy to Implement that for Sonos. |
Beta Was this translation helpful? Give feedback.
-
We discussed the proposal in the core team and the proposal is approved. |
Beta Was this translation helpful? Give feedback.
-
Implemented in home-assistant/core#116452 |
Beta Was this translation helpful? Give feedback.
We discussed the proposal in the core team and the proposal is approved.
I've reopened + unlocked the implementation PR.