FHEM logging & new dimmer
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user