From 26ab4ad91855b824289de54e489a7fe4cb459828 Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Mon, 3 Jun 2024 14:37:36 +0200 Subject: [PATCH] Add HDR type attribute to Kodi (#109603) Co-authored-by: Andriy Kushnir Co-authored-by: Erik Montnemery --- homeassistant/components/kodi/media_player.py | 19 +++++++++++++++++++ homeassistant/components/kodi/strings.json | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/homeassistant/components/kodi/media_player.py b/homeassistant/components/kodi/media_player.py index 46d3d614bfa..2bfe21b6eaa 100644 --- a/homeassistant/components/kodi/media_player.py +++ b/homeassistant/components/kodi/media_player.py @@ -259,6 +259,7 @@ class KodiEntity(MediaPlayerEntity): _attr_has_entity_name = True _attr_name = None + _attr_translation_key = "media_player" _attr_supported_features = ( MediaPlayerEntityFeature.BROWSE_MEDIA | MediaPlayerEntityFeature.NEXT_TRACK @@ -516,6 +517,7 @@ class KodiEntity(MediaPlayerEntity): "album", "season", "episode", + "streamdetails", ], ) else: @@ -632,6 +634,23 @@ class KodiEntity(MediaPlayerEntity): return None + @property + def extra_state_attributes(self) -> dict[str, str | None]: + """Return the state attributes.""" + state_attr: dict[str, str | None] = {} + if self.state == MediaPlayerState.OFF: + return state_attr + + hdr_type = ( + self._item.get("streamdetails", {}).get("video", [{}])[0].get("hdrtype") + ) + if hdr_type == "": + state_attr["dynamic_range"] = "sdr" + else: + state_attr["dynamic_range"] = hdr_type + + return state_attr + async def async_turn_on(self) -> None: """Turn the media player on.""" _LOGGER.debug("Firing event to turn on device") diff --git a/homeassistant/components/kodi/strings.json b/homeassistant/components/kodi/strings.json index 7c7d53b33ac..5b472e0c193 100644 --- a/homeassistant/components/kodi/strings.json +++ b/homeassistant/components/kodi/strings.json @@ -83,5 +83,14 @@ } } } + }, + "entity": { + "media_player": { + "media_player": { + "state_attributes": { + "dynamic_range": { "name": "Dynamic range" } + } + } + } } }