mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Improve Sonos activity tracking (#60642)
This commit is contained in:
parent
0cf228d5a1
commit
cb7e7e9bd1
@ -64,6 +64,7 @@ from .const import (
|
||||
from .favorites import SonosFavorites
|
||||
from .helpers import soco_error
|
||||
|
||||
NEVER_TIME = -1200.0
|
||||
EVENT_CHARGING = {
|
||||
"CHARGING": True,
|
||||
"NOT_CHARGING": False,
|
||||
@ -159,7 +160,6 @@ class SonosSpeaker:
|
||||
self.available = True
|
||||
|
||||
# Synchronization helpers
|
||||
self._is_ready: bool = False
|
||||
self._platforms_ready: set[str] = set()
|
||||
|
||||
# Subscriptions and events
|
||||
@ -167,7 +167,7 @@ class SonosSpeaker:
|
||||
self._subscriptions: list[SubscriptionBase] = []
|
||||
self._resubscription_lock: asyncio.Lock | None = None
|
||||
self._event_dispatchers: dict[str, Callable] = {}
|
||||
self._last_activity: datetime.datetime | None = None
|
||||
self._last_activity: float = NEVER_TIME
|
||||
|
||||
# Scheduled callback handles
|
||||
self._poll_timer: Callable | None = None
|
||||
@ -280,7 +280,6 @@ class SonosSpeaker:
|
||||
if self._platforms_ready == PLATFORMS:
|
||||
self._resubscription_lock = asyncio.Lock()
|
||||
await self.async_subscribe()
|
||||
self._is_ready = True
|
||||
|
||||
def write_entity_states(self) -> None:
|
||||
"""Write states for associated SonosEntity instances."""
|
||||
@ -965,6 +964,7 @@ class SonosSpeaker:
|
||||
#
|
||||
# Media and playback state handlers
|
||||
#
|
||||
@soco_error()
|
||||
def update_volume(self) -> None:
|
||||
"""Update information about current volume settings."""
|
||||
self.volume = self.soco.volume
|
||||
@ -979,6 +979,7 @@ class SonosSpeaker:
|
||||
except SoCoSlaveException:
|
||||
pass
|
||||
|
||||
@soco_error()
|
||||
def update_media(self, event: SonosEvent | None = None) -> None:
|
||||
"""Update information about currently playing media."""
|
||||
variables = event and event.variables
|
||||
|
Loading…
x
Reference in New Issue
Block a user