mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Add log to show last received UniFi websocket message (#109167)
This commit is contained in:
parent
9ed50d8b0c
commit
30fdb2a8b3
@ -75,6 +75,7 @@ from .errors import AuthenticationRequired, CannotConnect
|
|||||||
|
|
||||||
RETRY_TIMER = 15
|
RETRY_TIMER = 15
|
||||||
CHECK_HEARTBEAT_INTERVAL = timedelta(seconds=1)
|
CHECK_HEARTBEAT_INTERVAL = timedelta(seconds=1)
|
||||||
|
CHECK_WEBSOCKET_INTERVAL = timedelta(minutes=1)
|
||||||
|
|
||||||
|
|
||||||
class UniFiController:
|
class UniFiController:
|
||||||
@ -89,6 +90,7 @@ class UniFiController:
|
|||||||
self.api = api
|
self.api = api
|
||||||
|
|
||||||
self.ws_task: asyncio.Task | None = None
|
self.ws_task: asyncio.Task | None = None
|
||||||
|
self._cancel_websocket_check: CALLBACK_TYPE | None = None
|
||||||
|
|
||||||
self.available = True
|
self.available = True
|
||||||
self.wireless_clients = hass.data[UNIFI_WIRELESS_CLIENTS]
|
self.wireless_clients = hass.data[UNIFI_WIRELESS_CLIENTS]
|
||||||
@ -275,6 +277,9 @@ class UniFiController:
|
|||||||
self._cancel_heartbeat_check = async_track_time_interval(
|
self._cancel_heartbeat_check = async_track_time_interval(
|
||||||
self.hass, self._async_check_for_stale, CHECK_HEARTBEAT_INTERVAL
|
self.hass, self._async_check_for_stale, CHECK_HEARTBEAT_INTERVAL
|
||||||
)
|
)
|
||||||
|
self._cancel_websocket_check = async_track_time_interval(
|
||||||
|
self.hass, self._async_watch_websocket, CHECK_WEBSOCKET_INTERVAL
|
||||||
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_heartbeat(
|
def async_heartbeat(
|
||||||
@ -411,6 +416,14 @@ class UniFiController:
|
|||||||
):
|
):
|
||||||
self.hass.loop.call_later(RETRY_TIMER, self.reconnect)
|
self.hass.loop.call_later(RETRY_TIMER, self.reconnect)
|
||||||
|
|
||||||
|
@callback
|
||||||
|
def _async_watch_websocket(self, now: datetime) -> None:
|
||||||
|
"""Watch timestamp for last received websocket message."""
|
||||||
|
LOGGER.debug(
|
||||||
|
"Last received websocket timestamp: %s",
|
||||||
|
self.api.connectivity.ws_message_received,
|
||||||
|
)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def shutdown(self, event: Event) -> None:
|
def shutdown(self, event: Event) -> None:
|
||||||
"""Wrap the call to unifi.close.
|
"""Wrap the call to unifi.close.
|
||||||
@ -450,6 +463,10 @@ class UniFiController:
|
|||||||
self._cancel_heartbeat_check()
|
self._cancel_heartbeat_check()
|
||||||
self._cancel_heartbeat_check = None
|
self._cancel_heartbeat_check = None
|
||||||
|
|
||||||
|
if self._cancel_websocket_check:
|
||||||
|
self._cancel_websocket_check()
|
||||||
|
self._cancel_websocket_check = None
|
||||||
|
|
||||||
if self._cancel_poe_command:
|
if self._cancel_poe_command:
|
||||||
self._cancel_poe_command()
|
self._cancel_poe_command()
|
||||||
self._cancel_poe_command = None
|
self._cancel_poe_command = None
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"loggers": ["aiounifi"],
|
"loggers": ["aiounifi"],
|
||||||
"quality_scale": "platinum",
|
"quality_scale": "platinum",
|
||||||
"requirements": ["aiounifi==69"],
|
"requirements": ["aiounifi==70"],
|
||||||
"ssdp": [
|
"ssdp": [
|
||||||
{
|
{
|
||||||
"manufacturer": "Ubiquiti Networks",
|
"manufacturer": "Ubiquiti Networks",
|
||||||
|
@ -380,7 +380,7 @@ aiosyncthing==0.5.1
|
|||||||
aiotractive==0.5.6
|
aiotractive==0.5.6
|
||||||
|
|
||||||
# homeassistant.components.unifi
|
# homeassistant.components.unifi
|
||||||
aiounifi==69
|
aiounifi==70
|
||||||
|
|
||||||
# homeassistant.components.vlc_telnet
|
# homeassistant.components.vlc_telnet
|
||||||
aiovlc==0.1.0
|
aiovlc==0.1.0
|
||||||
|
@ -353,7 +353,7 @@ aiosyncthing==0.5.1
|
|||||||
aiotractive==0.5.6
|
aiotractive==0.5.6
|
||||||
|
|
||||||
# homeassistant.components.unifi
|
# homeassistant.components.unifi
|
||||||
aiounifi==69
|
aiounifi==70
|
||||||
|
|
||||||
# homeassistant.components.vlc_telnet
|
# homeassistant.components.vlc_telnet
|
||||||
aiovlc==0.1.0
|
aiovlc==0.1.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user