From 3b3d6e0da53db2a0c9a65a649776ac3bd4e8906f Mon Sep 17 00:00:00 2001 From: Kevin Anthony Date: Thu, 13 May 2021 01:02:24 -0300 Subject: [PATCH] Add vesync Core200S air purifier (#50216) --- homeassistant/components/vesync/fan.py | 39 ++++++++++++++----- homeassistant/components/vesync/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/vesync/fan.py b/homeassistant/components/vesync/fan.py index d01d3d4dc5d..6641f43d17b 100644 --- a/homeassistant/components/vesync/fan.py +++ b/homeassistant/components/vesync/fan.py @@ -18,12 +18,16 @@ _LOGGER = logging.getLogger(__name__) DEV_TYPE_TO_HA = { "LV-PUR131S": "fan", + "Core200S": "fan", } FAN_MODE_AUTO = "auto" FAN_MODE_SLEEP = "sleep" -PRESET_MODES = [FAN_MODE_AUTO, FAN_MODE_SLEEP] +PRESET_MODES = { + "LV-PUR131S": [FAN_MODE_AUTO, FAN_MODE_SLEEP], + "Core200S": [FAN_MODE_SLEEP], +} SPEED_RANGE = (1, 3) # off is not included @@ -86,7 +90,7 @@ class VeSyncFanHA(VeSyncDevice, FanEntity): @property def preset_modes(self): """Get the list of available preset modes.""" - return PRESET_MODES + return PRESET_MODES[self.device.device_type] @property def preset_mode(self): @@ -103,13 +107,30 @@ class VeSyncFanHA(VeSyncDevice, FanEntity): @property def extra_state_attributes(self): """Return the state attributes of the fan.""" - return { - "mode": self.smartfan.mode, - "active_time": self.smartfan.active_time, - "filter_life": self.smartfan.filter_life, - "air_quality": self.smartfan.air_quality, - "screen_status": self.smartfan.screen_status, - } + attr = {} + + if hasattr(self.smartfan, "active_time"): + attr["active_time"] = self.smartfan.active_time + + if hasattr(self.smartfan, "screen_status"): + attr["screen_status"] = self.smartfan.screen_status + + if hasattr(self.smartfan, "child_lock"): + attr["child_lock"] = self.smartfan.child_lock + + if hasattr(self.smartfan, "night_light"): + attr["night_light"] = self.smartfan.night_light + + if hasattr(self.smartfan, "air_quality"): + attr["air_quality"] = self.smartfan.air_quality + + if hasattr(self.smartfan, "mode"): + attr["mode"] = self.smartfan.mode + + if hasattr(self.smartfan, "filter_life"): + attr["filter_life"] = self.smartfan.filter_life + + return attr def set_percentage(self, percentage): """Set the speed of the device.""" diff --git a/homeassistant/components/vesync/manifest.json b/homeassistant/components/vesync/manifest.json index f09a58e4696..70c46d0f02e 100644 --- a/homeassistant/components/vesync/manifest.json +++ b/homeassistant/components/vesync/manifest.json @@ -3,7 +3,7 @@ "name": "VeSync", "documentation": "https://www.home-assistant.io/integrations/vesync", "codeowners": ["@markperdue", "@webdjoe", "@thegardenmonkey"], - "requirements": ["pyvesync==1.3.1"], + "requirements": ["pyvesync==1.4.0"], "config_flow": true, "iot_class": "cloud_polling" } diff --git a/requirements_all.txt b/requirements_all.txt index 13c07db65c9..43e2cd5e846 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1919,7 +1919,7 @@ pyvera==0.3.13 pyversasense==0.0.6 # homeassistant.components.vesync -pyvesync==1.3.1 +pyvesync==1.4.0 # homeassistant.components.vizio pyvizio==0.1.57 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 74f17affea3..3db0b015696 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1034,7 +1034,7 @@ pytradfri[async]==7.0.6 pyvera==0.3.13 # homeassistant.components.vesync -pyvesync==1.3.1 +pyvesync==1.4.0 # homeassistant.components.vizio pyvizio==0.1.57