Value of 0 should not be considered unknown
. (#7139)
* Value of 0 should not be considered `unknown`. * Reflect disconnect state in entity states. * Due to adding unknown state on disconnect, the amount of reconnects can sometimes be more. Test for at least 2 reconnect attempts.
This commit is contained in:
parent
4becfb66e3
commit
e5feeec7a4
2 changed files with 9 additions and 4 deletions
|
@ -153,10 +153,15 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||
yield from protocol.wait_closed()
|
||||
|
||||
if hass.state != CoreState.stopping:
|
||||
# unexpected disconnect
|
||||
if transport:
|
||||
# remove listerer
|
||||
stop_listerer()
|
||||
|
||||
# reflect disconnect state in devices state by setting an
|
||||
# empty telegram resulting in `unkown` states
|
||||
update_entities_telegram({})
|
||||
|
||||
# throttle reconnect attempts
|
||||
yield from asyncio.sleep(config[CONF_RECONNECT_INTERVAL],
|
||||
loop=hass.loop)
|
||||
|
@ -207,7 +212,7 @@ class DSMREntity(Entity):
|
|||
if self._obis == obis.ELECTRICITY_ACTIVE_TARIFF:
|
||||
return self.translate_tariff(value)
|
||||
else:
|
||||
if value:
|
||||
if value is not None:
|
||||
return value
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue