From 3e41dd31aede71c0330e0f1b5ceffd7eb32300b8 Mon Sep 17 00:00:00 2001 From: Samuel Spagl <46893256+samuelspagl@users.noreply.github.com> Date: Tue, 8 Oct 2024 10:59:10 +0200 Subject: [PATCH] Update 'totalTime' and 'elapsedTime' to be optional attributes --- .../samsung_soundbar/api_extension/SoundbarDevice.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py b/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py index 9750f33..0890751 100644 --- a/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py +++ b/custom_components/samsung_soundbar/api_extension/SoundbarDevice.py @@ -373,11 +373,15 @@ class SoundbarDevice: @property def media_duration(self) -> int | None: - return self.device.status.attributes.get("totalTime").value + attr = self.device.status.attributes.get("totalTime", None) + if attr: + return attr.value @property def media_position(self) -> int | None: - return self.device.status.attributes.get("elapsedTime").value + attr = self.device.status.attributes.get("elapsedTime", None) + if attr: + return attr.value async def media_play(self): await self.device.play(True)