mirror of
https://github.com/home-assistant/core.git
synced 2026-10-06 22:38:02 -04:00
Add Tuya number platform support for category hwsb (#183758)
This commit is contained in:
@@ -893,6 +893,7 @@ class DPCode(StrEnum):
|
||||
SOS = "sos" # Emergency State
|
||||
SOS_STATE = "sos_state" # Emergency mode
|
||||
SPEED = "speed" # Speed level
|
||||
SPEED_SET = "speed_set"
|
||||
SPRAY_MODE = "spray_mode" # Spraying mode
|
||||
START = "start" # Start
|
||||
STATUS = "status"
|
||||
|
||||
@@ -83,6 +83,9 @@
|
||||
"near_detection": {
|
||||
"default": "mdi:signal-distance-variant"
|
||||
},
|
||||
"speed": {
|
||||
"default": "mdi:speedometer"
|
||||
},
|
||||
"temperature": {
|
||||
"default": "mdi:thermometer"
|
||||
},
|
||||
|
||||
@@ -150,6 +150,13 @@ NUMBERS: dict[DeviceCategory, tuple[TuyaNumberEntityDescription, ...]] = {
|
||||
device_class=NumberDeviceClass.DISTANCE,
|
||||
),
|
||||
),
|
||||
DeviceCategory.HWSB: (
|
||||
TuyaNumberEntityDescription(
|
||||
key=DPCode.SPEED_SET,
|
||||
translation_key="speed",
|
||||
native_unit_of_measurement=UnitOfRatio.PERCENTAGE,
|
||||
),
|
||||
),
|
||||
DeviceCategory.JSQ: (
|
||||
TuyaNumberEntityDescription(
|
||||
key=DPCode.TEMP_SET,
|
||||
|
||||
@@ -275,6 +275,9 @@
|
||||
"siren_duration": {
|
||||
"name": "Siren duration"
|
||||
},
|
||||
"speed": {
|
||||
"name": "[%key:component::sensor::entity_component::speed::name%]"
|
||||
},
|
||||
"target_dis_closest": {
|
||||
"name": "Closest target distance"
|
||||
},
|
||||
|
||||
@@ -249,3 +249,37 @@ async def test_temp_unit_convert_number_invalid(
|
||||
assert state is not None
|
||||
assert state.attributes.get("device_class") is None
|
||||
assert state.attributes.get("unit_of_measurement") == ""
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mock_device_code", ["hwsb_ircs2n82vgrozoew"])
|
||||
async def test_hwsb_number_with_quirk(
|
||||
hass: HomeAssistant,
|
||||
mock_manager: Manager,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
mock_device: CustomerDevice,
|
||||
) -> None:
|
||||
"""Test HWSB outdoor equipment number with quirk applied."""
|
||||
mock_device.status["speed_set"] = 50
|
||||
await initialize_entry(hass, mock_manager, mock_config_entry, mock_device)
|
||||
|
||||
entity_id = "number.inverflow_speed"
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == "50.0"
|
||||
assert state.attributes["min"] == 30
|
||||
assert state.attributes["max"] == 120
|
||||
assert state.attributes["step"] == 5
|
||||
assert state.attributes["unit_of_measurement"] == "%"
|
||||
|
||||
await hass.services.async_call(
|
||||
NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
ATTR_VALUE: 75,
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
mock_manager.send_commands.assert_called_once_with(
|
||||
mock_device.id, [{"code": "speed_set", "value": 75}]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user