Update 'totalTime' and 'elapsedTime' to be optional attributes

This commit is contained in:
Samuel Spagl 2024-10-08 10:59:10 +02:00 committed by GitHub
parent 11ed2d1444
commit 3e41dd31ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

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