Don't create switch entity for switch device type in XThings Cloud (#172828)

This commit is contained in:
zhangluofeng
2026-06-03 09:59:28 +00:00
committed by Franck Nijhof
parent 994b210588
commit 24037fcfa3
2 changed files with 2 additions and 21 deletions
@@ -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)
+1 -20
View File
@@ -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)