deCONZ - Directly reflect changes to config entry options (#31661)
* Directly reflect changes to config entry options * Remove print * Add tests * Add title to config options
This commit is contained in:
1 parent
17f3332c89
commit
b5df2ba853
12 files changed
+188
-22
No files matched your search
@@ -134,6 +134,28 @@ async def test_allow_clip_sensor(hass):
|
||||
vibration_sensor = hass.states.get("binary_sensor.vibration_sensor")
|
||||
assert vibration_sensor.state == "on"
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: False}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "binary_sensor.presence_sensor" in gateway.deconz_ids
|
||||
assert "binary_sensor.temperature_sensor" not in gateway.deconz_ids
|
||||
assert "binary_sensor.clip_presence_sensor" not in gateway.deconz_ids
|
||||
assert "binary_sensor.vibration_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 3
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: True}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "binary_sensor.presence_sensor" in gateway.deconz_ids
|
||||
assert "binary_sensor.temperature_sensor" not in gateway.deconz_ids
|
||||
assert "binary_sensor.clip_presence_sensor" in gateway.deconz_ids
|
||||
assert "binary_sensor.vibration_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 4
|
||||
|
||||
|
||||
async def test_add_new_binary_sensor(hass):
|
||||
"""Test that adding a new binary sensor works."""
|
||||
|
||||
@@ -214,6 +214,30 @@ async def test_clip_climate_device(hass):
|
||||
clip_thermostat = hass.states.get("climate.clip_thermostat")
|
||||
assert clip_thermostat.state == "heat"
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: False}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "climate.thermostat" in gateway.deconz_ids
|
||||
assert "sensor.thermostat" not in gateway.deconz_ids
|
||||
assert "sensor.thermostat_battery_level" in gateway.deconz_ids
|
||||
assert "climate.presence_sensor" not in gateway.deconz_ids
|
||||
assert "climate.clip_thermostat" not in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 3
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: True}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "climate.thermostat" in gateway.deconz_ids
|
||||
assert "sensor.thermostat" not in gateway.deconz_ids
|
||||
assert "sensor.thermostat_battery_level" in gateway.deconz_ids
|
||||
assert "climate.presence_sensor" not in gateway.deconz_ids
|
||||
assert "climate.clip_thermostat" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 4
|
||||
|
||||
|
||||
async def test_verify_state_update(hass):
|
||||
"""Test that state update properly."""
|
||||
|
||||
@@ -245,3 +245,29 @@ async def test_disable_light_groups(hass):
|
||||
|
||||
empty_group = hass.states.get("light.empty_group")
|
||||
assert empty_group is None
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_DECONZ_GROUPS: True}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "light.rgb_light" in gateway.deconz_ids
|
||||
assert "light.tunable_white_light" in gateway.deconz_ids
|
||||
assert "light.light_group" in gateway.deconz_ids
|
||||
assert "light.empty_group" not in gateway.deconz_ids
|
||||
assert "light.on_off_switch" not in gateway.deconz_ids
|
||||
# 3 entities
|
||||
assert len(hass.states.async_all()) == 5
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_DECONZ_GROUPS: False}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "light.rgb_light" in gateway.deconz_ids
|
||||
assert "light.tunable_white_light" in gateway.deconz_ids
|
||||
assert "light.light_group" not in gateway.deconz_ids
|
||||
assert "light.empty_group" not in gateway.deconz_ids
|
||||
assert "light.on_off_switch" not in gateway.deconz_ids
|
||||
# 3 entities
|
||||
assert len(hass.states.async_all()) == 4
|
||||
@@ -218,6 +218,40 @@ async def test_allow_clip_sensors(hass):
|
||||
clip_light_level_sensor = hass.states.get("sensor.clip_light_level_sensor")
|
||||
assert clip_light_level_sensor.state == "999.8"
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: False}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "sensor.light_level_sensor" in gateway.deconz_ids
|
||||
assert "sensor.presence_sensor" not in gateway.deconz_ids
|
||||
assert "sensor.switch_1" not in gateway.deconz_ids
|
||||
assert "sensor.switch_1_battery_level" not in gateway.deconz_ids
|
||||
assert "sensor.switch_2" not in gateway.deconz_ids
|
||||
assert "sensor.switch_2_battery_level" in gateway.deconz_ids
|
||||
assert "sensor.daylight_sensor" not in gateway.deconz_ids
|
||||
assert "sensor.power_sensor" in gateway.deconz_ids
|
||||
assert "sensor.consumption_sensor" in gateway.deconz_ids
|
||||
assert "sensor.clip_light_level_sensor" not in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 5
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: True}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert "sensor.light_level_sensor" in gateway.deconz_ids
|
||||
assert "sensor.presence_sensor" not in gateway.deconz_ids
|
||||
assert "sensor.switch_1" not in gateway.deconz_ids
|
||||
assert "sensor.switch_1_battery_level" not in gateway.deconz_ids
|
||||
assert "sensor.switch_2" not in gateway.deconz_ids
|
||||
assert "sensor.switch_2_battery_level" in gateway.deconz_ids
|
||||
assert "sensor.daylight_sensor" not in gateway.deconz_ids
|
||||
assert "sensor.power_sensor" in gateway.deconz_ids
|
||||
assert "sensor.consumption_sensor" in gateway.deconz_ids
|
||||
assert "sensor.clip_light_level_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 6
|
||||
|
||||
|
||||
async def test_add_new_sensor(hass):
|
||||
"""Test that adding a new sensor works."""
|
||||
|
||||
Reference in new issue
Block a user