mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Do not discard zero positions for Sonos media players (#83249)
fixes undefined
This commit is contained in:
parent
34fd64addf
commit
c70388869b
@ -43,11 +43,11 @@ DURATION_SECONDS = "duration_in_s"
|
|||||||
POSITION_SECONDS = "position_in_s"
|
POSITION_SECONDS = "position_in_s"
|
||||||
|
|
||||||
|
|
||||||
def _timespan_secs(timespan: str | None) -> None | float:
|
def _timespan_secs(timespan: str | None) -> None | int:
|
||||||
"""Parse a time-span into number of seconds."""
|
"""Parse a time-span into number of seconds."""
|
||||||
if timespan in UNAVAILABLE_VALUES:
|
if timespan in UNAVAILABLE_VALUES:
|
||||||
return None
|
return None
|
||||||
return time_period_str(timespan).total_seconds() # type: ignore[arg-type]
|
return int(time_period_str(timespan).total_seconds()) # type: ignore[arg-type]
|
||||||
|
|
||||||
|
|
||||||
class SonosMedia:
|
class SonosMedia:
|
||||||
@ -73,7 +73,7 @@ class SonosMedia:
|
|||||||
self.title: str | None = None
|
self.title: str | None = None
|
||||||
self.uri: str | None = None
|
self.uri: str | None = None
|
||||||
|
|
||||||
self.position: float | None = None
|
self.position: int | None = None
|
||||||
self.position_updated_at: datetime.datetime | None = None
|
self.position_updated_at: datetime.datetime | None = None
|
||||||
|
|
||||||
def clear(self) -> None:
|
def clear(self) -> None:
|
||||||
|
@ -323,7 +323,7 @@ class SonosMediaPlayerEntity(SonosEntity, MediaPlayerEntity):
|
|||||||
@property
|
@property
|
||||||
def media_position(self) -> int | None:
|
def media_position(self) -> int | None:
|
||||||
"""Position of current playing media in seconds."""
|
"""Position of current playing media in seconds."""
|
||||||
return int(self.media.position) if self.media.position else None
|
return self.media.position
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_position_updated_at(self) -> datetime.datetime | None:
|
def media_position_updated_at(self) -> datetime.datetime | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user