diff --git a/custom_components/econnect_metronet/binary_sensor.py b/custom_components/econnect_metronet/binary_sensor.py index 904eeb3..bc671ad 100644 --- a/custom_components/econnect_metronet/binary_sensor.py +++ b/custom_components/econnect_metronet/binary_sensor.py @@ -62,7 +62,8 @@ def __init__( ) -> None: """Construct.""" # Enable experimental settings from the configuration file - self._attr_force_update = coordinator.hass.data[DOMAIN].get("force_update", False) + experimental = coordinator.hass.data[DOMAIN].get("experimental", {}) + self._attr_force_update = experimental.get("force_update", False) super().__init__(coordinator) self.entity_id = generate_entity_id(config, name) @@ -117,7 +118,8 @@ def __init__( ) -> None: """Construct.""" # Enable experimental settings from the configuration file - self._attr_force_update = coordinator.hass.data[DOMAIN].get("force_update", False) + experimental = coordinator.hass.data[DOMAIN].get("experimental", {}) + self._attr_force_update = experimental.get("force_update", False) super().__init__(coordinator) self.entity_id = generate_entity_id(config, name) @@ -163,7 +165,8 @@ def __init__( ) -> None: """Construct.""" # Enable experimental settings from the configuration file - self._attr_force_update = coordinator.hass.data[DOMAIN].get("force_update", False) + experimental = coordinator.hass.data[DOMAIN].get("experimental", {}) + self._attr_force_update = experimental.get("force_update", False) super().__init__(coordinator) self.entity_id = generate_entity_id(config, name) diff --git a/tests/test_experiments.py b/tests/test_experimental_settings.py similarity index 82% rename from tests/test_experiments.py rename to tests/test_experimental_settings.py index 1e3ab2f..c9b26f4 100644 --- a/tests/test_experiments.py +++ b/tests/test_experimental_settings.py @@ -2,7 +2,7 @@ from custom_components.econnect_metronet.const import DOMAIN -class TestExperiments: +class TestExperimentalSettings: def test_sensor_force_update_default(self, coordinator, config_entry, alarm_device): # Ensure the default is to not force any update entity = AlertSensor("device_tamper", 7, config_entry, "device_tamper", coordinator, alarm_device) @@ -10,6 +10,10 @@ def test_sensor_force_update_default(self, coordinator, config_entry, alarm_devi def test_sensor_force_update_on(self, hass, coordinator, config_entry, alarm_device): # Ensure you can force the entity update - hass.data[DOMAIN] = {"force_update": True} + hass.data[DOMAIN] = { + "experimental": { + "force_update": True, + } + } entity = AlertSensor("device_tamper", 7, config_entry, "device_tamper", coordinator, alarm_device) assert entity._attr_force_update is True