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:
Johan Bloemberg authored and Paulus Schoutsen committed 2017-04-18 20:24:44 -07:00
1 parent 4becfb66e3
commit e5feeec7a4
2 files changed
+9 -4

No files matched your search

+6 -1
View File
@@ -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