From 8d4f32645dc1cb604dc131816f5c214ffdc44878 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 4 Feb 2024 11:23:33 -0600 Subject: [PATCH] Add tests for shelly switch unique ids (#109617) --- tests/components/shelly/test_switch.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/components/shelly/test_switch.py b/tests/components/shelly/test_switch.py index 9a99116e66c..555533cc817 100644 --- a/tests/components/shelly/test_switch.py +++ b/tests/components/shelly/test_switch.py @@ -54,6 +54,16 @@ async def test_block_device_services(hass: HomeAssistant, mock_block_device) -> assert hass.states.get("switch.test_name_channel_1").state == STATE_OFF +async def test_block_device_unique_ids(hass: HomeAssistant, mock_block_device) -> None: + """Test block device unique_ids.""" + await init_integration(hass, 1) + + registry = er.async_get(hass) + entry = registry.async_get("switch.test_name_channel_1") + assert entry + assert entry.unique_id == "123456789ABC-relay_0" + + async def test_block_set_state_connection_error( hass: HomeAssistant, mock_block_device, monkeypatch ) -> None: @@ -176,6 +186,18 @@ async def test_rpc_device_services( assert hass.states.get("switch.test_switch_0").state == STATE_OFF +async def test_rpc_device_unique_ids( + hass: HomeAssistant, mock_rpc_device, monkeypatch +) -> None: + """Test RPC device unique_ids.""" + await init_integration(hass, 2) + + registry = er.async_get(hass) + entry = registry.async_get("switch.test_switch_0") + assert entry + assert entry.unique_id == "123456789ABC-switch:0" + + async def test_rpc_device_switch_type_lights_mode( hass: HomeAssistant, mock_rpc_device, monkeypatch ) -> None: