FHEM logging & new dimmer

This commit is contained in:
Martin Bauer
2019-07-15 21:38:00 +02:00
parent 87e199e260
commit 08a0d17fa0
3 changed files with 10 additions and 2 deletions

View File

@@ -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)