Add Tuya switch platform support for category hwsb (#183499)

This commit is contained in:
alainmic
2026-09-29 17:21:04 +02:00
committed by GitHub
parent 6af7c031de
commit ad47bc731e
3 changed files with 35 additions and 0 deletions
+2
View File
@@ -221,6 +221,8 @@ class DeviceCategory(StrEnum):
https://developer.tuya.com/en/docs/iot/categoryhps?id=Kaiuz42yhn1hs
"""
HWSB = "hwsb"
"""Outdoor equipment"""
JS = "js"
"""Water purifier"""
JSQ = "jsq"
+6
View File
@@ -344,6 +344,12 @@ SWITCHES: dict[DeviceCategory, tuple[TuyaSwitchEntityDescription, ...]] = {
translation_key="sleep_aid",
),
),
DeviceCategory.HWSB: (
TuyaSwitchEntityDescription(
key=DPCode.SWITCH,
name=None,
),
),
DeviceCategory.JSQ: (
TuyaSwitchEntityDescription(
key=DPCode.SWITCH_SOUND,
+27
View File
@@ -165,3 +165,30 @@ async def test_state(
state = hass.states.get(entity_id)
assert state is not None, f"{entity_id} does not exist"
assert state.state == expected_state
@pytest.mark.parametrize("mock_device_code", ["hwsb_ircs2n82vgrozoew"])
async def test_hwsb_switch_with_quirk(
hass: HomeAssistant,
mock_manager: Manager,
mock_config_entry: MockConfigEntry,
mock_device: CustomerDevice,
) -> None:
"""Test HWSB outdoor equipment switch with quirk applied."""
mock_device.status["switch"] = True
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
entity_id = "switch.inverflow"
state = hass.states.get(entity_id)
assert state is not None
assert state.state == "on"
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
mock_manager.send_commands.assert_called_once_with(
mock_device.id, [{"code": "switch", "value": False}]
)