forked from home-assistant/core
Add action to Music Assistant to add currently playing item to favorites
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
"transfer_queue": { "service": "mdi:transfer" },
|
"transfer_queue": { "service": "mdi:transfer" },
|
||||||
"search": { "service": "mdi:magnify" },
|
"search": { "service": "mdi:magnify" },
|
||||||
"get_queue": { "service": "mdi:playlist-music" },
|
"get_queue": { "service": "mdi:playlist-music" },
|
||||||
"get_library": { "service": "mdi:music-box-multiple" }
|
"get_library": { "service": "mdi:music-box-multiple" },
|
||||||
|
"add_currently_playing_to_favorites": { "service": "mdi:heart-plus" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -118,6 +118,7 @@ SERVICE_PLAY_MEDIA_ADVANCED = "play_media"
|
|||||||
SERVICE_PLAY_ANNOUNCEMENT = "play_announcement"
|
SERVICE_PLAY_ANNOUNCEMENT = "play_announcement"
|
||||||
SERVICE_TRANSFER_QUEUE = "transfer_queue"
|
SERVICE_TRANSFER_QUEUE = "transfer_queue"
|
||||||
SERVICE_GET_QUEUE = "get_queue"
|
SERVICE_GET_QUEUE = "get_queue"
|
||||||
|
SERVICE_ADD_FAVORITE = "add_currently_playing_to_favorites"
|
||||||
|
|
||||||
|
|
||||||
def catch_musicassistant_error[_R, **P](
|
def catch_musicassistant_error[_R, **P](
|
||||||
@@ -211,6 +212,11 @@ async def async_setup_entry(
|
|||||||
func="_async_handle_get_queue",
|
func="_async_handle_get_queue",
|
||||||
supports_response=SupportsResponse.ONLY,
|
supports_response=SupportsResponse.ONLY,
|
||||||
)
|
)
|
||||||
|
platform.async_register_entity_service(
|
||||||
|
SERVICE_ADD_FAVORITE,
|
||||||
|
schema=None,
|
||||||
|
func="_async_handle_add_currently_playing_to_favorites",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MusicAssistantPlayer(MusicAssistantEntity, MediaPlayerEntity):
|
class MusicAssistantPlayer(MusicAssistantEntity, MediaPlayerEntity):
|
||||||
@@ -611,6 +617,13 @@ class MusicAssistantPlayer(MusicAssistantEntity, MediaPlayerEntity):
|
|||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@catch_musicassistant_error
|
||||||
|
async def _async_handle_add_currently_playing_to_favorites(self) -> None:
|
||||||
|
"""Handle action to add currently playing item to favorites."""
|
||||||
|
await self.mass.players.add_currently_playing_to_favorites(
|
||||||
|
self.player_id,
|
||||||
|
)
|
||||||
|
|
||||||
async def async_browse_media(
|
async def async_browse_media(
|
||||||
self,
|
self,
|
||||||
media_content_type: MediaType | str | None = None,
|
media_content_type: MediaType | str | None = None,
|
||||||
|
@@ -100,6 +100,12 @@ get_queue:
|
|||||||
supported_features:
|
supported_features:
|
||||||
- media_player.MediaPlayerEntityFeature.PLAY_MEDIA
|
- media_player.MediaPlayerEntityFeature.PLAY_MEDIA
|
||||||
|
|
||||||
|
add_currently_playing_to_favorites:
|
||||||
|
target:
|
||||||
|
entity:
|
||||||
|
domain: media_player
|
||||||
|
integration: music_assistant
|
||||||
|
|
||||||
search:
|
search:
|
||||||
fields:
|
fields:
|
||||||
config_entry_id:
|
config_entry_id:
|
||||||
|
@@ -104,6 +104,10 @@
|
|||||||
"name": "Get playerQueue details (advanced)",
|
"name": "Get playerQueue details (advanced)",
|
||||||
"description": "Retrieves the details of the currently active queue of a Music Assistant player."
|
"description": "Retrieves the details of the currently active queue of a Music Assistant player."
|
||||||
},
|
},
|
||||||
|
"add_currently_playing_to_favorites": {
|
||||||
|
"name": "Add currently playing to favorites",
|
||||||
|
"description": "Adds the currently playing item on a Music Assistant player to the favorites."
|
||||||
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"name": "Search Music Assistant",
|
"name": "Search Music Assistant",
|
||||||
"description": "Performs a global search on the Music Assistant library and all providers.",
|
"description": "Performs a global search on the Music Assistant library and all providers.",
|
||||||
|
Reference in New Issue
Block a user