From 0391f03244cb2db5e84e102a289ab268d0a26c2c Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Mon, 2 Dec 2019 20:18:14 +0100 Subject: [PATCH] Logger integration & more log messages --- config_creation/manual_config.yaml | 4 ++-- custom_components/fhem/switch.py | 1 + custom_components/reconnecting_client.py | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config_creation/manual_config.yaml b/config_creation/manual_config.yaml index d71e7da..b59e3d4 100644 --- a/config_creation/manual_config.yaml +++ b/config_creation/manual_config.yaml @@ -94,8 +94,8 @@ dimmer: cover_half: -#logger: -# default: info +logger: + default: info # logs: # xknx.telegram: debug # xknx.knx: debug diff --git a/custom_components/fhem/switch.py b/custom_components/fhem/switch.py index 34b1f30..b7012cb 100644 --- a/custom_components/fhem/switch.py +++ b/custom_components/fhem/switch.py @@ -66,6 +66,7 @@ class FhemSwitch(SwitchDevice): async def line_received(self, line): line = line.strip() + _LOGGER.debug(f"Switch received line {line}") if not self._available: _LOGGER.warning(f"Line for unavailable device {self.name}: {line}") if line.startswith('level:'): diff --git a/custom_components/reconnecting_client.py b/custom_components/reconnecting_client.py index e65685c..37cd7ab 100644 --- a/custom_components/reconnecting_client.py +++ b/custom_components/reconnecting_client.py @@ -64,10 +64,14 @@ class ReconnectingClient: await self._receive_line_callback(line) except OSError as e: if self._connection_last_state != 'FAILED': - notification_text = "{} connection to {}:{} failed".format(self._connection_name,self._host, self._port) + notification_text = "{} connection to {}:{} failed".format(self._connection_name, self._host, + self._port) self.hass.components.persistent_notification.async_create(notification_text, title="No connection") _LOGGER.error("Connection to {} failed {}:{}".format(self._connection_name, self._host, self._port)) await self._connection_status_changed_callback('disconnected') + else: + _LOGGER.debug(f"{self._connection_name} retried connection, last state {self._connection_last_state}" + f"reconnection time {self.reconnect_time}") self._connection_last_state = 'FAILED' self.connected = False await asyncio.sleep(self.reconnect_time)