From 0ed0c7c02603e4917f1dcf52901cfcb022ac9e7d Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 18 Feb 2021 21:54:40 -1000 Subject: [PATCH] Fix backwards compatibility with vesync fans (#45950) --- homeassistant/components/vesync/fan.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/vesync/fan.py b/homeassistant/components/vesync/fan.py index e9f421215fb..1d1320d8d78 100644 --- a/homeassistant/components/vesync/fan.py +++ b/homeassistant/components/vesync/fan.py @@ -91,8 +91,8 @@ class VeSyncFanHA(VeSyncDevice, FanEntity): @property def preset_mode(self): """Get the current preset mode.""" - if self.smartfan.mode == FAN_MODE_AUTO: - return FAN_MODE_AUTO + if self.smartfan.mode in (FAN_MODE_AUTO, FAN_MODE_SLEEP): + return self.smartfan.mode return None @property @@ -136,7 +136,11 @@ class VeSyncFanHA(VeSyncDevice, FanEntity): if not self.smartfan.is_on: self.smartfan.turn_on() - self.smartfan.auto_mode() + if preset_mode == FAN_MODE_AUTO: + self.smartfan.auto_mode() + elif preset_mode == FAN_MODE_SLEEP: + self.smartfan.sleep_mode() + self.schedule_update_ha_state() def turn_on( @@ -150,4 +154,6 @@ class VeSyncFanHA(VeSyncDevice, FanEntity): if preset_mode: self.set_preset_mode(preset_mode) return + if percentage is None: + percentage = 50 self.set_percentage(percentage)