From b15387ffb991fbcc18c5f6db8276441cd7df0fac Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Sun, 24 Apr 2022 23:32:13 +0200 Subject: [PATCH] Remove migration of entities from deCONZ switch to siren platform (#70600) --- homeassistant/components/deconz/switch.py | 15 +----------- tests/components/deconz/test_siren.py | 30 ----------------------- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/homeassistant/components/deconz/switch.py b/homeassistant/components/deconz/switch.py index 6be34a26ab3..f1ff95183dd 100644 --- a/homeassistant/components/deconz/switch.py +++ b/homeassistant/components/deconz/switch.py @@ -5,16 +5,14 @@ from __future__ import annotations from typing import Any from pydeconz.models.light.light import Light -from pydeconz.models.light.siren import Siren from homeassistant.components.switch import DOMAIN, SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant, callback -from homeassistant.helpers import entity_registry as er from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback -from .const import DOMAIN as DECONZ_DOMAIN, POWER_PLUGS +from .const import POWER_PLUGS from .deconz_device import DeconzDevice from .gateway import get_gateway_from_config_entry @@ -31,17 +29,6 @@ async def async_setup_entry( gateway = get_gateway_from_config_entry(hass, config_entry) gateway.entities[DOMAIN] = set() - entity_registry = er.async_get(hass) - - # Siren platform replacing sirens in switch platform added in 2021.10 - for light in gateway.api.lights.sirens.values(): - if isinstance(light, Siren) and ( - entity_id := entity_registry.async_get_entity_id( - DOMAIN, DECONZ_DOMAIN, light.unique_id - ) - ): - entity_registry.async_remove(entity_id) - @callback def async_add_switch(lights: list[Light] | None = None) -> None: """Add switch from deCONZ.""" diff --git a/tests/components/deconz/test_siren.py b/tests/components/deconz/test_siren.py index c24e2087768..16d44540dbc 100644 --- a/tests/components/deconz/test_siren.py +++ b/tests/components/deconz/test_siren.py @@ -2,9 +2,7 @@ from unittest.mock import patch -from homeassistant.components.deconz.const import DOMAIN as DECONZ_DOMAIN from homeassistant.components.siren import ATTR_DURATION, DOMAIN as SIREN_DOMAIN -from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN from homeassistant.const import ( ATTR_ENTITY_ID, SERVICE_TURN_OFF, @@ -13,7 +11,6 @@ from homeassistant.const import ( STATE_ON, STATE_UNAVAILABLE, ) -from homeassistant.helpers import entity_registry as er from .test_gateway import ( DECONZ_WEB_REQUEST, @@ -103,30 +100,3 @@ async def test_sirens(hass, aioclient_mock, mock_deconz_websocket): await hass.config_entries.async_remove(config_entry.entry_id) await hass.async_block_till_done() assert len(hass.states.async_all()) == 0 - - -async def test_remove_legacy_siren_switch(hass, aioclient_mock): - """Test that switch platform cleans up legacy siren entities.""" - unique_id = "00:00:00:00:00:00:00:00-00" - - registry = er.async_get(hass) - switch_siren_entity = registry.async_get_or_create( - SWITCH_DOMAIN, DECONZ_DOMAIN, unique_id - ) - - assert switch_siren_entity - - data = { - "lights": { - "1": { - "name": "Warning device", - "type": "Warning device", - "state": {"alert": "lselect", "reachable": True}, - "uniqueid": unique_id, - }, - } - } - with patch.dict(DECONZ_WEB_REQUEST, data): - await setup_deconz_integration(hass, aioclient_mock) - - assert not registry.async_get(switch_siren_entity.entity_id)