Fixes in FHM switch & sensor
This commit is contained in:
parent
8bf29a5c82
commit
5b0215177f
|
@ -66,7 +66,7 @@ class FhemSensor(Entity):
|
||||||
_, new_value = line.split(':')
|
_, new_value = line.split(':')
|
||||||
self._state = int(float(new_value) / 255 * 100)
|
self._state = int(float(new_value) / 255 * 100)
|
||||||
await self.async_update_ha_state()
|
await self.async_update_ha_state()
|
||||||
elif self._type == 'power':
|
elif self._type == 'power' and line.startswith('power'):
|
||||||
self._available = True
|
self._available = True
|
||||||
_, new_value = line
|
_, new_value = line
|
||||||
self._state = int(new_value)
|
self._state = int(new_value)
|
||||||
|
|
|
@ -60,6 +60,7 @@ class FhemSwitch(SwitchDevice):
|
||||||
self.connection.fhem_set(self._ids[0], 'off')
|
self.connection.fhem_set(self._ids[0], 'off')
|
||||||
|
|
||||||
async def line_received(self, line):
|
async def line_received(self, line):
|
||||||
|
line = line.strip()
|
||||||
if line.startswith('level:'):
|
if line.startswith('level:'):
|
||||||
_, new_state = line.split(':')
|
_, new_state = line.split(':')
|
||||||
new_state = new_state.strip().lower()
|
new_state = new_state.strip().lower()
|
||||||
|
@ -68,6 +69,8 @@ class FhemSwitch(SwitchDevice):
|
||||||
if new_state in ('off', '0'):
|
if new_state in ('off', '0'):
|
||||||
self._on = False
|
self._on = False
|
||||||
await self.async_update_ha_state()
|
await self.async_update_ha_state()
|
||||||
|
elif line in ('on', 'off'):
|
||||||
|
self._on = (line == 'on')
|
||||||
elif line.startswith('ResndFail') or line.startswith('MISSING ACK'):
|
elif line.startswith('ResndFail') or line.startswith('MISSING ACK'):
|
||||||
self._available = False
|
self._available = False
|
||||||
await self.async_update_ha_state()
|
await self.async_update_ha_state()
|
||||||
|
|
Loading…
Reference in New Issue