1
mirror of https://github.com/home-assistant/core synced 2024-09-03 08:14:07 +02:00

Provide Sonos media position if duration not available (#73001)

This commit is contained in:
jjlawren 2022-06-03 17:03:21 -05:00 committed by GitHub
parent 14030991cf
commit 04b2223f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -205,13 +205,15 @@ class SonosMedia:
self, position_info: dict[str, int], force_update: bool = False
) -> None:
"""Update state when playing music tracks."""
if (duration := position_info.get(DURATION_SECONDS)) == 0:
duration = position_info.get(DURATION_SECONDS)
current_position = position_info.get(POSITION_SECONDS)
if not (duration or current_position):
self.clear_position()
return
should_update = force_update
self.duration = duration
current_position = position_info.get(POSITION_SECONDS)
# player started reporting position?
if current_position is not None and self.position is None: