mirror of
https://github.com/home-assistant/core.git
synced 2026-09-26 17:31:15 -04:00
Turn off Tuya fans when the speed is set to 0% (#181972)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user