mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Skip Sonos zeroconf availability check in non-timeout scenarios (#54425)
This commit is contained in:
parent
8264fd2eb6
commit
f4fb5f2f5a
@ -499,21 +499,26 @@ class SonosSpeaker:
|
|||||||
|
|
||||||
self.async_write_entity_states()
|
self.async_write_entity_states()
|
||||||
|
|
||||||
async def async_unseen(self, now: datetime.datetime | None = None) -> None:
|
async def async_unseen(
|
||||||
|
self, callback_timestamp: datetime.datetime | None = None
|
||||||
|
) -> None:
|
||||||
"""Make this player unavailable when it was not seen recently."""
|
"""Make this player unavailable when it was not seen recently."""
|
||||||
if self._seen_timer:
|
if self._seen_timer:
|
||||||
self._seen_timer()
|
self._seen_timer()
|
||||||
self._seen_timer = None
|
self._seen_timer = None
|
||||||
|
|
||||||
hostname = uid_to_short_hostname(self.soco.uid)
|
if callback_timestamp:
|
||||||
zcname = f"{hostname}.{MDNS_SERVICE}"
|
# Called by a _seen_timer timeout, check mDNS one more time
|
||||||
aiozeroconf = await zeroconf.async_get_async_instance(self.hass)
|
# This should not be checked in an "active" unseen scenario
|
||||||
if await aiozeroconf.async_get_service_info(MDNS_SERVICE, zcname):
|
hostname = uid_to_short_hostname(self.soco.uid)
|
||||||
# We can still see the speaker via zeroconf check again later.
|
zcname = f"{hostname}.{MDNS_SERVICE}"
|
||||||
self._seen_timer = self.hass.helpers.event.async_call_later(
|
aiozeroconf = await zeroconf.async_get_async_instance(self.hass)
|
||||||
SEEN_EXPIRE_TIME.total_seconds(), self.async_unseen
|
if await aiozeroconf.async_get_service_info(MDNS_SERVICE, zcname):
|
||||||
)
|
# We can still see the speaker via zeroconf check again later.
|
||||||
return
|
self._seen_timer = self.hass.helpers.event.async_call_later(
|
||||||
|
SEEN_EXPIRE_TIME.total_seconds(), self.async_unseen
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"No activity and could not locate %s on the network. Marking unavailable",
|
"No activity and could not locate %s on the network. Marking unavailable",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user