Add config option to set timeout for wiffi devices (#35694)

* add config option to set timeout for wiffi devices

Wiffi devices allow to configure the update period (=
full_loop_minutes). The integration shall respect the configured update
period and therefore need a configuration for the timeout, too.

* Move timeout from config flow to option flow

* add test for option flow
This commit is contained in:
Steffen Zimmermann 2020-05-17 10:31:28 +02:00 committed by GitHub
parent d02bb70f0c
commit 51eebb3906
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 112 additions and 19 deletions

View file

@ -21,7 +21,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
entities = []
if metric.is_bool:
entities.append(BoolEntity(device, metric))
entities.append(BoolEntity(device, metric, config_entry.options))
async_add_entities(entities)
@ -31,9 +31,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
class BoolEntity(WiffiEntity, BinarySensorEntity):
"""Entity for wiffi metrics which have a boolean value."""
def __init__(self, device, metric):
def __init__(self, device, metric, options):
"""Initialize the entity."""
super().__init__(device, metric)
super().__init__(device, metric, options)
self._value = metric.value
self.reset_expiration_date()