From 99476d933791ed49a71a2fe46f8ec32001f204af Mon Sep 17 00:00:00 2001 From: Rasmus Lundsgaard Date: Sat, 6 Jul 2024 19:20:14 +0200 Subject: [PATCH] Fix empty list in kodi media_player (#121250) Co-authored-by: Franck Nijhof --- homeassistant/components/kodi/media_player.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/kodi/media_player.py b/homeassistant/components/kodi/media_player.py index 290b3b1e566..46dee891e3a 100644 --- a/homeassistant/components/kodi/media_player.py +++ b/homeassistant/components/kodi/media_player.py @@ -641,12 +641,10 @@ class KodiEntity(MediaPlayerEntity): 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"] = "sdr" + if (video_details := self._item.get("streamdetails", {}).get("video")) and ( + hdr_type := video_details[0].get("hdrtype") + ): state_attr["dynamic_range"] = hdr_type return state_attr