Add HDR type attribute to Kodi (#109603)

Co-authored-by: Andriy Kushnir <me@orhideous.name>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
starkillerOG 2024-06-03 14:37:36 +02:00 committed by GitHub
parent a3b60cb054
commit 26ab4ad918
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -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")

View File

@ -83,5 +83,14 @@
}
}
}
},
"entity": {
"media_player": {
"media_player": {
"state_attributes": {
"dynamic_range": { "name": "Dynamic range" }
}
}
}
}
}