From 224c874673d5ef07b1dd1d0b6987cfcdcca1826f Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Wed, 22 Apr 2020 20:45:09 +0200 Subject: [PATCH] UniFi - Improve logging related to loosing connection to controller (#34547) --- homeassistant/components/unifi/controller.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/unifi/controller.py b/homeassistant/components/unifi/controller.py index 33e7fc3836b..96f1194df24 100644 --- a/homeassistant/components/unifi/controller.py +++ b/homeassistant/components/unifi/controller.py @@ -174,7 +174,7 @@ class UniFiController: if signal == SIGNAL_CONNECTION_STATE: if data == STATE_DISCONNECTED and self.available: - LOGGER.error("Lost connection to UniFi") + LOGGER.warning("Lost connection to UniFi controller") if (data == STATE_RUNNING and not self.available) or ( data == STATE_DISCONNECTED and self.available @@ -183,7 +183,9 @@ class UniFiController: async_dispatcher_send(self.hass, self.signal_reachable) if not self.available: - self.hass.loop.call_later(RETRY_TIMER, self.reconnect) + self.hass.loop.call_later(RETRY_TIMER, self.reconnect, True) + else: + LOGGER.info("Connected to UniFi controller") elif signal == SIGNAL_DATA and data: @@ -292,9 +294,10 @@ class UniFiController: async_dispatcher_send(hass, controller.signal_options_update) @callback - def reconnect(self) -> None: + def reconnect(self, log=False) -> None: """Prepare to reconnect UniFi session.""" - LOGGER.debug("Reconnecting to UniFi in %i", RETRY_TIMER) + if log: + LOGGER.info("Will try to reconnect to UniFi controller") self.hass.loop.create_task(self.async_reconnect()) async def async_reconnect(self) -> None: