From fd45a07677495d2c92467011e93b3e0492185ed2 Mon Sep 17 00:00:00 2001 From: Peter Nijssen Date: Tue, 26 Oct 2021 11:05:03 +0200 Subject: [PATCH] Automatic spider supported fan speed and hvac (#58308) * Automatic fill of supported fan speed and hvac Automatic fill of supported fan speed and hvac * Update manifest of spiderpy to 1.5.0 Update manifest of spiderpy to 1.5.0 * Update spiderpy version to 1.5.0 in requirements files * Code formatted using Black * Move support fan and hvac values into a class variable * Move convert to HA value to hvac_modes method * Log a warning for any invalid operation mode * Update homeassistant/components/spider/climate.py Update as suggested by @mivn23 Co-authored-by: mvn23 * PR feedback update + dependency update * Remove logging Co-authored-by: Bennert Co-authored-by: mvn23 --- homeassistant/components/spider/climate.py | 13 +++++++------ homeassistant/components/spider/manifest.json | 4 ++-- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/spider/climate.py b/homeassistant/components/spider/climate.py index 52146518ee3..fbae603a239 100644 --- a/homeassistant/components/spider/climate.py +++ b/homeassistant/components/spider/climate.py @@ -11,10 +11,6 @@ from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from .const import DOMAIN -SUPPORT_FAN = ["Auto", "Low", "Medium", "High", "Boost 10", "Boost 20", "Boost 30"] - -SUPPORT_HVAC = [HVAC_MODE_HEAT, HVAC_MODE_COOL] - HA_STATE_TO_SPIDER = { HVAC_MODE_COOL: "Cool", HVAC_MODE_HEAT: "Heat", @@ -43,6 +39,11 @@ class SpiderThermostat(ClimateEntity): """Initialize the thermostat.""" self.api = api self.thermostat = thermostat + self.support_fan = thermostat.fan_speed_values + self.support_hvac = [] + for operation_value in thermostat.operation_values: + if operation_value in SPIDER_STATE_TO_HA: + self.support_hvac.append(SPIDER_STATE_TO_HA[operation_value]) @property def device_info(self): @@ -109,7 +110,7 @@ class SpiderThermostat(ClimateEntity): @property def hvac_modes(self): """Return the list of available operation modes.""" - return SUPPORT_HVAC + return self.support_hvac def set_temperature(self, **kwargs): """Set new target temperature.""" @@ -134,7 +135,7 @@ class SpiderThermostat(ClimateEntity): @property def fan_modes(self): """List of available fan modes.""" - return SUPPORT_FAN + return self.support_fan def update(self): """Get the latest data.""" diff --git a/homeassistant/components/spider/manifest.json b/homeassistant/components/spider/manifest.json index d25d2c97901..b80fa0926cd 100644 --- a/homeassistant/components/spider/manifest.json +++ b/homeassistant/components/spider/manifest.json @@ -2,8 +2,8 @@ "domain": "spider", "name": "Itho Daalderop Spider", "documentation": "https://www.home-assistant.io/integrations/spider", - "requirements": ["spiderpy==1.4.3"], + "requirements": ["spiderpy==1.6.1"], "codeowners": ["@peternijssen"], "config_flow": true, "iot_class": "cloud_polling" -} +} \ No newline at end of file diff --git a/requirements_all.txt b/requirements_all.txt index 54555279d2f..125337ccf19 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2205,7 +2205,7 @@ speak2mary==1.4.0 speedtest-cli==2.1.3 # homeassistant.components.spider -spiderpy==1.4.3 +spiderpy==1.6.1 # homeassistant.components.spotify spotipy==2.18.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 215ed38842d..13ddf117d4f 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1281,7 +1281,7 @@ speak2mary==1.4.0 speedtest-cli==2.1.3 # homeassistant.components.spider -spiderpy==1.4.3 +spiderpy==1.6.1 # homeassistant.components.spotify spotipy==2.18.0