From 08a0d17fa0702fff36937ceb066f5ad94877b290 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Mon, 15 Jul 2019 21:38:00 +0200 Subject: [PATCH] FHEM logging & new dimmer --- config_creation/fhem.yaml | 5 +++++ custom_components/fhem/switch.py | 6 +++++- custom_components/reconnecting_client.py | 1 - 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config_creation/fhem.yaml b/config_creation/fhem.yaml index 160347e..b140ad6 100644 --- a/config_creation/fhem.yaml +++ b/config_creation/fhem.yaml @@ -36,6 +36,11 @@ light: - office_rebecca +- name: Steckdosen Dimmer + dimmer: True + fhem_ids: + - Steckdose_Dimmer + # ---------------------------------- Covers ------------------------------------ cover: diff --git a/custom_components/fhem/switch.py b/custom_components/fhem/switch.py index ef28c3b..34b1f30 100644 --- a/custom_components/fhem/switch.py +++ b/custom_components/fhem/switch.py @@ -66,6 +66,8 @@ class FhemSwitch(SwitchDevice): async def line_received(self, line): line = line.strip() + if not self._available: + _LOGGER.warning(f"Line for unavailable device {self.name}: {line}") if line.startswith('level:'): self._available = True _, new_state = line.split(':') @@ -77,11 +79,13 @@ class FhemSwitch(SwitchDevice): await self.async_update_ha_state() elif line in ('on', 'off'): self._available = True - prev = self._on self._on = (line == 'on') await self.async_update_ha_state() elif line.startswith('ResndFail') or line.startswith('MISSING ACK'): self._available = False + _LOGGER.warning(f"FHEM device {self.name} became unavailable: {line}") await self.async_update_ha_state() else: + if not self._available: + _LOGGER.warning(f"Other line from unavailable FHEM device {self.name}: {line}") device_error_reporting(self.hass, line, component_type="Switch", component_name=self.entity_id) diff --git a/custom_components/reconnecting_client.py b/custom_components/reconnecting_client.py index ee1e168..e65685c 100644 --- a/custom_components/reconnecting_client.py +++ b/custom_components/reconnecting_client.py @@ -61,7 +61,6 @@ class ReconnectingClient: if not line: raise OSError("Disconnect") line = line.decode() - _LOGGER.warning("{} received line: {}".format(self._connection_name, line)) await self._receive_line_callback(line) except OSError as e: if self._connection_last_state != 'FAILED':