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:
1 parent
d02bb70f0c
commit
51eebb3906
8 files changed
+112
-19
No files matched your search
@@ -49,9 +49,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
entities = []
|
||||
|
||||
if metric.is_number:
|
||||
entities.append(NumberEntity(device, metric))
|
||||
entities.append(NumberEntity(device, metric, config_entry.options))
|
||||
elif metric.is_string:
|
||||
entities.append(StringEntity(device, metric))
|
||||
entities.append(StringEntity(device, metric, config_entry.options))
|
||||
|
||||
async_add_entities(entities)
|
||||
|
||||
@@ -61,9 +61,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
class NumberEntity(WiffiEntity):
|
||||
"""Entity for wiffi metrics which have a number 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._device_class = UOM_TO_DEVICE_CLASS_MAP.get(metric.unit_of_measurement)
|
||||
self._unit_of_measurement = UOM_MAP.get(
|
||||
metric.unit_of_measurement, metric.unit_of_measurement
|
||||
@@ -103,9 +103,9 @@ class NumberEntity(WiffiEntity):
|
||||
class StringEntity(WiffiEntity):
|
||||
"""Entity for wiffi metrics which have a string 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()
|
||||
|
||||
|
||||
Reference in new issue
Block a user