1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

deCONZ - use entity registry disabled_by to control available entities (#26219)

* First draft

* Support enabling disabled entities

* Clean up

* Move import

* Local entity enabled replaced during rebase

* Add option flow test

* Mark options properties with option
This commit is contained in:
Robert Svensson
2019-09-06 01:38:00 +02:00
committed by Paulus Schoutsen
parent b1c2a5fa08
commit 518d2c31bb
19 changed files with 191 additions and 82 deletions

View File

@@ -13,7 +13,7 @@ from homeassistant.util import slugify
from .const import ATTR_DARK, ATTR_ON, NEW_SENSOR
from .deconz_device import DeconzDevice
from .gateway import get_gateway_from_config_entry
from .gateway import get_gateway_from_config_entry, DeconzEntityHandler
ATTR_CURRENT = "current"
ATTR_POWER = "power"
@@ -30,6 +30,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the deCONZ sensors."""
gateway = get_gateway_from_config_entry(hass, config_entry)
entity_handler = DeconzEntityHandler(gateway)
@callback
def async_add_sensor(sensors):
"""Add sensors from deCONZ."""
@@ -37,22 +39,22 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for sensor in sensors:
if not sensor.BINARY and not (
not gateway.allow_clip_sensor and sensor.type.startswith("CLIP")
):
if not sensor.BINARY:
if sensor.type in Switch.ZHATYPE:
if sensor.battery:
entities.append(DeconzBattery(sensor, gateway))
else:
entities.append(DeconzSensor(sensor, gateway))
new_sensor = DeconzSensor(sensor, gateway)
entity_handler.add_entity(new_sensor)
entities.append(new_sensor)
async_add_entities(entities, True)
gateway.listeners.append(
async_dispatcher_connect(
hass, gateway.async_event_new_device(NEW_SENSOR), async_add_sensor
hass, gateway.async_signal_new_device(NEW_SENSOR), async_add_sensor
)
)