Remove migration of entities from deCONZ switch to siren platform (#70600)
This commit is contained in:
parent
0726bc2cab
commit
b15387ffb9
2 changed files with 1 additions and 44 deletions
|
@ -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."""
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue