mirror of
https://github.com/home-assistant/core
synced 2024-09-06 10:29:55 +02:00
deCONZ - Disable daylight sensor by default (#30625)
* Dont enable daylight sensor by default * Fix tests
This commit is contained in:
parent
c13b461737
commit
d883ee62f8
@ -59,7 +59,10 @@ class DeconzDevice(DeconzBase, Entity):
|
||||
|
||||
@property
|
||||
def entity_registry_enabled_default(self):
|
||||
"""Return if the entity should be enabled when first added to the entity registry."""
|
||||
"""Return if the entity should be enabled when first added to the entity registry.
|
||||
|
||||
Daylight is a virtual sensor from deCONZ that should never be enabled by default.
|
||||
"""
|
||||
if not self.gateway.option_allow_clip_sensor and self._device.type.startswith(
|
||||
"CLIP"
|
||||
):
|
||||
@ -71,6 +74,9 @@ class DeconzDevice(DeconzBase, Entity):
|
||||
):
|
||||
return False
|
||||
|
||||
if self._device.type == "Daylight":
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
|
@ -104,11 +104,11 @@ async def test_sensors(hass):
|
||||
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" 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()) == 6
|
||||
assert len(hass.states.async_all()) == 5
|
||||
|
||||
light_level_sensor = hass.states.get("sensor.light_level_sensor")
|
||||
assert light_level_sensor.state == "999.8"
|
||||
@ -129,7 +129,7 @@ async def test_sensors(hass):
|
||||
assert switch_2_battery_level.state == "100"
|
||||
|
||||
daylight_sensor = hass.states.get("sensor.daylight_sensor")
|
||||
assert daylight_sensor.state == "dawn"
|
||||
assert daylight_sensor is None
|
||||
|
||||
power_sensor = hass.states.get("sensor.power_sensor")
|
||||
assert power_sensor.state == "6"
|
||||
@ -182,11 +182,11 @@ async def test_allow_clip_sensors(hass):
|
||||
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" 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()) == 7
|
||||
assert len(hass.states.async_all()) == 6
|
||||
|
||||
light_level_sensor = hass.states.get("sensor.light_level_sensor")
|
||||
assert light_level_sensor.state == "999.8"
|
||||
@ -207,7 +207,7 @@ async def test_allow_clip_sensors(hass):
|
||||
assert switch_2_battery_level.state == "100"
|
||||
|
||||
daylight_sensor = hass.states.get("sensor.daylight_sensor")
|
||||
assert daylight_sensor.state == "dawn"
|
||||
assert daylight_sensor is None
|
||||
|
||||
power_sensor = hass.states.get("sensor.power_sensor")
|
||||
assert power_sensor.state == "6"
|
||||
|
Loading…
Reference in New Issue
Block a user