Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle null value for elapsed time in Music Assistant #133597

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -565,17 +565,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