From ad47bc731e87fdd52ec81b76c48e85a15aff0a8d Mon Sep 17 00:00:00 2001 From: alainmic <56118503+alainmic@users.noreply.github.com> Date: Tue, 29 Sep 2026 11:21:04 -0400 Subject: [PATCH] Add Tuya switch platform support for category hwsb (#183499) --- homeassistant/components/tuya/const.py | 2 ++ homeassistant/components/tuya/switch.py | 6 ++++++ tests/components/tuya/test_switch.py | 27 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/homeassistant/components/tuya/const.py b/homeassistant/components/tuya/const.py index bb714275b4f6..2f7a267845eb 100644 --- a/homeassistant/components/tuya/const.py +++ b/homeassistant/components/tuya/const.py @@ -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" diff --git a/homeassistant/components/tuya/switch.py b/homeassistant/components/tuya/switch.py index 7264f24023b2..50c18059ef38 100644 --- a/homeassistant/components/tuya/switch.py +++ b/homeassistant/components/tuya/switch.py @@ -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, diff --git a/tests/components/tuya/test_switch.py b/tests/components/tuya/test_switch.py index 37e13cefbb28..6efd1d4423ed 100644 --- a/tests/components/tuya/test_switch.py +++ b/tests/components/tuya/test_switch.py @@ -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}] + )