Skip to content

Commit

Permalink
Handle null value for elapsed time in Music Assistant (#133597)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt authored and frenck committed Dec 20, 2024
1 parent 367749d commit 8c1a18b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions homeassistant/components/music_assistant/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,17 +566,13 @@ def _update_media_attributes(
# shuffle and repeat are not (yet) supported for external sources
self._attr_shuffle = None
self._attr_repeat = None
if TYPE_CHECKING:
assert player.elapsed_time is not None
self._attr_media_position = int(player.elapsed_time)
self._attr_media_position = int(player.elapsed_time or 0)
self._attr_media_position_updated_at = (
utc_from_timestamp(player.elapsed_time_last_updated)
if player.elapsed_time_last_updated
else None
)
if TYPE_CHECKING:
assert player.elapsed_time is not None
self._prev_time = player.elapsed_time
self._prev_time = player.elapsed_time or 0
return

if queue is None:
Expand Down
2 changes: 1 addition & 1 deletion tests/components/music_assistant/fixtures/players.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"power",
"enqueue"
],
"elapsed_time": 0,
"elapsed_time": null,
"elapsed_time_last_updated": 0,
"state": "idle",
"volume_level": 20,
Expand Down

0 comments on commit 8c1a18b

Please sign in to comment.