From 24037fcfa32aba2eedd2256f74a460c53b0e15dc Mon Sep 17 00:00:00 2001 From: zhangluofeng <30921940+zhangluofeng@users.noreply.github.com> Date: Tue, 2 Jun 2026 19:05:00 +0800 Subject: [PATCH] Don't create switch entity for switch device type in XThings Cloud (#172828) --- .../components/xthings_cloud/switch.py | 2 +- tests/components/xthings_cloud/test_switch.py | 21 +------------------ 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/xthings_cloud/switch.py b/homeassistant/components/xthings_cloud/switch.py index 26422a19d28e..c62240b07bf4 100644 --- a/homeassistant/components/xthings_cloud/switch.py +++ b/homeassistant/components/xthings_cloud/switch.py @@ -20,7 +20,7 @@ async def async_setup_entry( entities = [ XthingsCloudSwitch(coordinator, device_id, device_data) for device_id, device_data in coordinator.data.items() - if device_data["type"] in ("switch", "plug") + if device_data["type"] == "plug" ] async_add_entities(entities) diff --git a/tests/components/xthings_cloud/test_switch.py b/tests/components/xthings_cloud/test_switch.py index d1a8fd6c90e6..d1b519616c23 100644 --- a/tests/components/xthings_cloud/test_switch.py +++ b/tests/components/xthings_cloud/test_switch.py @@ -40,36 +40,20 @@ async def test_switches( @pytest.mark.parametrize( - ("entity_id", "device_id", "device_type", "service", "method"), + ("entity_id", "device_id", "service", "method"), [ ( "switch.smart_plug_50", "dev_plug_001", - "plug", SERVICE_TURN_ON, "async_plug_on", ), ( "switch.smart_plug_50", "dev_plug_001", - "plug", SERVICE_TURN_OFF, "async_plug_off", ), - ( - "switch.smart_plug_100", - "dev_plug_002", - "switch", - SERVICE_TURN_ON, - "async_switch_on", - ), - ( - "switch.smart_plug_100", - "dev_plug_002", - "switch", - SERVICE_TURN_OFF, - "async_switch_off", - ), ], ) async def test_turn_on_off( @@ -78,13 +62,10 @@ async def test_turn_on_off( mock_api_client: AsyncMock, entity_id: str, device_id: str, - device_type: str, service: str, method: str, ) -> None: """Test turning on and off a device.""" - get_device_by_id(mock_api_client, device_id)["type"] = device_type - with patch("homeassistant.components.xthings_cloud.PLATFORMS", [Platform.SWITCH]): await setup_integration(hass, mock_config_entry)