1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-27 14:31:13 +00:00

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
2017-04-19 05:24:44 +02:00
committed by Paulus Schoutsen
parent 4becfb66e3
commit e5feeec7a4
2 changed files with 9 additions and 4 deletions

View File

@@ -56,7 +56,7 @@ def test_default_setup(hass, mock_connection_factory):
telegram = {
CURRENT_ELECTRICITY_USAGE: CosemObject([
{'value': Decimal('0.1'), 'unit': 'kWh'}
{'value': Decimal('0.0'), 'unit': 'kWh'}
]),
ELECTRICITY_ACTIVE_TARIFF: CosemObject([
{'value': '0001', 'unit': ''}
@@ -82,7 +82,7 @@ def test_default_setup(hass, mock_connection_factory):
# ensure entities have new state value after incoming telegram
power_consumption = hass.states.get('sensor.power_consumption')
assert power_consumption.state == '0.1'
assert power_consumption.state == '0.0'
assert power_consumption.attributes.get('unit_of_measurement') is 'kWh'
# tariff should be translated in human readable and have no unit
@@ -199,5 +199,5 @@ def test_reconnect(hass, monkeypatch, mock_connection_factory):
# wait for sleep to resolve
yield from hass.async_block_till_done()
assert connection_factory.call_count == 2, \
assert connection_factory.call_count >= 2, \
'connecting not retried'