1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Mark type "On/Off Switch" as a deCONZ switch entity (#70598)

Convert entity types of light platform to switch platform
This commit is contained in:
Robert Svensson
2022-04-25 08:25:38 +02:00
committed by GitHub
parent 9f11063724
commit 8eae572c93
3 changed files with 53 additions and 1 deletions

View File

@@ -2,12 +2,15 @@
from unittest.mock import patch
from homeassistant.components.deconz.const import DOMAIN as DECONZ_DOMAIN
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
from homeassistant.components.switch import (
DOMAIN as SWITCH_DOMAIN,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
)
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, STATE_UNAVAILABLE
from homeassistant.helpers import entity_registry as er
from .test_gateway import (
DECONZ_WEB_REQUEST,
@@ -107,3 +110,32 @@ async def test_power_plugs(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_on_off_output_as_light(hass, aioclient_mock):
"""Test that switch platform cleans up legacy light entities."""
unique_id = "00:00:00:00:00:00:00:00-00"
registry = er.async_get(hass)
switch_light_entity = registry.async_get_or_create(
LIGHT_DOMAIN, DECONZ_DOMAIN, unique_id
)
assert switch_light_entity
data = {
"lights": {
"1": {
"name": "On Off output device",
"type": "On/Off output",
"state": {"on": True, "reachable": True},
"uniqueid": unique_id,
},
}
}
with patch.dict(DECONZ_WEB_REQUEST, data):
await setup_deconz_integration(hass, aioclient_mock)
assert not registry.async_get("light.on_off_output_device")
assert registry.async_get("switch.on_off_output_device")
assert len(hass.states.async_all()) == 1