mirror of
https://github.com/home-assistant/core.git
synced 2026-10-06 22:38:02 -04:00
Add Tuya switch platform support for category hwsb (#183499)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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}]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user