Turn off Tuya fans when the speed is set to 0% (#181972)

This commit is contained in:
Franck Nijhof
2026-09-18 14:55:12 +00:00
committed by GitHub
parent ae3e6c8ce2
commit 51c5e9c3aa
2 changed files with 27 additions and 0 deletions
+5
View File
@@ -121,6 +121,11 @@ class TuyaFanEntity(TuyaEntity, FanEntity):
@override
async def async_set_percentage(self, percentage: int) -> None:
"""Set the speed of the fan, as a percentage."""
# The speed wrappers have no off position, 0% has to hit the switch
if percentage == 0 and self._switch_wrapper is not None:
await self.async_turn_off()
return
await self._async_send_wrapper_updates(self._speed_wrapper, percentage)
@override
+22
View File
@@ -11,6 +11,7 @@ from homeassistant.components.fan import (
DOMAIN as FAN_DOMAIN,
SERVICE_OSCILLATE,
SERVICE_SET_DIRECTION,
SERVICE_SET_PERCENTAGE,
SERVICE_SET_PRESET_MODE,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
@@ -91,6 +92,27 @@ async def test_platform_setup_and_discovery(
{"preset_mode": "sleep"},
[{"code": "switch", "value": True}, {"code": "mode", "value": "sleep"}],
),
(
"fs_g0ewlb1vmwqljzji",
"fan.ceiling_fan_with_light",
SERVICE_SET_PERCENTAGE,
{"percentage": 50},
[{"code": "fan_speed", "value": "3"}],
),
(
"fs_g0ewlb1vmwqljzji",
"fan.ceiling_fan_with_light",
SERVICE_SET_PERCENTAGE,
{"percentage": 0},
[{"code": "switch", "value": False}],
),
(
"ks_j9fa8ahzac8uvlfl",
"fan.tower_fan_ca_407g_smart",
SERVICE_SET_PERCENTAGE,
{"percentage": 0},
[{"code": "switch", "value": False}],
),
],
)
async def test_action(