Remove old deCONZ entity cleanup (#117590)

This commit is contained in:
Robert Svensson 2024-05-17 03:42:09 +02:00 committed by GitHub
parent 657b3ceedc
commit 0e3c0ccfd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,6 @@ from typing import Any, TypedDict, TypeVar
from pydeconz.interfaces.groups import GroupHandler from pydeconz.interfaces.groups import GroupHandler
from pydeconz.interfaces.lights import LightHandler from pydeconz.interfaces.lights import LightHandler
from pydeconz.models import ResourceType
from pydeconz.models.event import EventType from pydeconz.models.event import EventType
from pydeconz.models.group import Group from pydeconz.models.group import Group
from pydeconz.models.light.light import Light, LightAlert, LightColorMode, LightEffect from pydeconz.models.light.light import Light, LightAlert, LightColorMode, LightEffect
@ -29,7 +28,6 @@ from homeassistant.components.light import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.color import color_hs_to_xy from homeassistant.util.color import color_hs_to_xy
@ -114,17 +112,6 @@ async def async_setup_entry(
hub = DeconzHub.get_hub(hass, config_entry) hub = DeconzHub.get_hub(hass, config_entry)
hub.entities[DOMAIN] = set() hub.entities[DOMAIN] = set()
entity_registry = er.async_get(hass)
# On/Off Output should be switch not light 2022.5
for light in hub.api.lights.lights.values():
if light.type == ResourceType.ON_OFF_OUTPUT.value and (
entity_id := entity_registry.async_get_entity_id(
DOMAIN, DECONZ_DOMAIN, light.unique_id
)
):
entity_registry.async_remove(entity_id)
@callback @callback
def async_add_light(_: EventType, light_id: str) -> None: def async_add_light(_: EventType, light_id: str) -> None:
"""Add light from deCONZ.""" """Add light from deCONZ."""