From e504500d172625b471535a49829b8b1bc7715d7f Mon Sep 17 00:00:00 2001 From: qfina <110172093+qfina@users.noreply.github.com> Date: Wed, 7 May 2025 09:32:51 +0200 Subject: [PATCH] Added Pet Mode - Added VS_MODE_PET constant - Included pet mode in preset_modes list when supported - Called pet_mode() method safely if it exists on the device --- custom_components/vesync/const.py | 1 + custom_components/vesync/fan.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/custom_components/vesync/const.py b/custom_components/vesync/const.py index 70819ea..61ca729 100644 --- a/custom_components/vesync/const.py +++ b/custom_components/vesync/const.py @@ -28,6 +28,7 @@ VS_MODE_MANUAL = "manual" VS_MODE_SLEEP = "sleep" VS_MODE_TURBO = "turbo" +VS_MODE_PET = "pet" VS_TO_HA_ATTRIBUTES = {"humidity": "current_humidity"} diff --git a/custom_components/vesync/fan.py b/custom_components/vesync/fan.py index b54e05b..e69742f 100644 --- a/custom_components/vesync/fan.py +++ b/custom_components/vesync/fan.py @@ -23,6 +23,7 @@ VS_MODE_MANUAL, VS_MODE_SLEEP, VS_MODE_TURBO, + VS_MODE_PET, VS_MODES, VS_TO_HA_ATTRIBUTES, ) @@ -81,6 +82,9 @@ def __init__(self, fan, coordinator) -> None: if mode in self.smartfan._config_dict[VS_MODES] ], ] + if hasattr(self.smartfan, "pet_mode"): + self._attr_preset_modes.append(VS_MODE_PET) + if self.smartfan.device_type == "LV-PUR131S": self._speed_range = (1, 3) @@ -169,6 +173,9 @@ def set_preset_mode(self, preset_mode): self.smartfan.manual_mode() elif preset_mode == VS_MODE_TURBO: self.smartfan.turbo_mode() + elif preset_mode == VS_MODE_PET: + if hasattr(self.smartfan, "pet_mode"): + self.smartfan.pet_mode() self.schedule_update_ha_state()