diff --git a/custom_components/mass/const.py b/custom_components/mass/const.py index bd6b5456..dc563992 100644 --- a/custom_components/mass/const.py +++ b/custom_components/mass/const.py @@ -15,6 +15,7 @@ ATTR_GROUP_LEADER = "group_leader" ATTR_MASS_PLAYER_ID = "mass_player_id" ATTR_MASS_PLAYER_TYPE = "mass_player_type" +ATTR_STREAM_TITLE = "stream_title" ADDON_SLUG = "d5369777_music_assistant_beta" ADDON_HOSTNAME = "d5369777-music-assistant-beta" diff --git a/custom_components/mass/manifest.json b/custom_components/mass/manifest.json index 8788a10c..9c7cf112 100644 --- a/custom_components/mass/manifest.json +++ b/custom_components/mass/manifest.json @@ -8,7 +8,7 @@ "iot_class": "local_push", "issue_tracker": "https://github.com/music-assistant/hass-music-assistant/issues", "loggers": ["music_assistant"], - "requirements": ["music-assistant==2.0.0b59"], + "requirements": ["music-assistant==2.0.0b79"], "version": "0.0.0", "zeroconf": ["_mass._tcp.local."] } diff --git a/custom_components/mass/media_player.py b/custom_components/mass/media_player.py index 24f47446..cf84cabc 100644 --- a/custom_components/mass/media_player.py +++ b/custom_components/mass/media_player.py @@ -47,6 +47,7 @@ ATTR_MASS_PLAYER_TYPE, ATTR_QUEUE_INDEX, ATTR_QUEUE_ITEMS, + ATTR_STREAM_TITLE, DOMAIN, ) from .entity import MassBaseEntity @@ -194,7 +195,7 @@ def extra_state_attributes(self) -> Mapping[str, Any]: """Return additional state attributes.""" player = self.player queue = self.mass.players.get_player_queue(player.active_source) - return { + attrs = { ATTR_MASS_PLAYER_ID: self.player_id, ATTR_MASS_PLAYER_TYPE: player.type.value, ATTR_GROUP_MEMBERS: player.group_childs, @@ -203,6 +204,23 @@ def extra_state_attributes(self) -> Mapping[str, Any]: ATTR_QUEUE_ITEMS: queue.items if queue else None, ATTR_QUEUE_INDEX: queue.current_index if queue else None, } + # add optional stream_title for radio streams + if ( + queue + and queue.current_item + and queue.current_item.streamdetails + and queue.current_item.streamdetails.stream_title + ): + attrs[ATTR_STREAM_TITLE] = queue.current_item.streamdetails.stream_title + elif ( + queue + and queue.current_item + and queue.current_item.media_type == MediaType.RADIO + and queue.current_item.media_item + and queue.current_item.media_item.metadata + ): + attrs[ATTR_STREAM_TITLE] = queue.current_item.media_item.metadata.description + return attrs async def async_on_update(self) -> None: """Handle player updates.""" diff --git a/requirements_dev.txt b/requirements_dev.txt index b757ff93..82f03bc6 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,5 +1,6 @@ mypy==1.7.1 pylint==3.0.3 pre-commit==3.6.0 -homeassistant==2023.11.3 -music-assistant==2.0.0b78 +homeassistant==2023.12.4 +music-assistant==2.0.0b79 +async_timeout==4.0.2