From 960b5b7d86dcb32a720b8e87e5403df9e5ae466b Mon Sep 17 00:00:00 2001 From: Mark Coombes Date: Tue, 16 Feb 2021 12:06:20 -0500 Subject: [PATCH] Fix climate hold bug in ecobee (#46613) --- homeassistant/components/ecobee/climate.py | 15 +++++++++++---- homeassistant/components/ecobee/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/ecobee/test_climate.py | 10 +++++----- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/ecobee/climate.py b/homeassistant/components/ecobee/climate.py index c61428cbc78..089f0950854 100644 --- a/homeassistant/components/ecobee/climate.py +++ b/homeassistant/components/ecobee/climate.py @@ -559,7 +559,7 @@ class Thermostat(ClimateEntity): if preset_mode == PRESET_AWAY: self.data.ecobee.set_climate_hold( - self.thermostat_index, "away", "indefinite" + self.thermostat_index, "away", "indefinite", self.hold_hours() ) elif preset_mode == PRESET_TEMPERATURE: @@ -570,6 +570,7 @@ class Thermostat(ClimateEntity): self.thermostat_index, PRESET_TO_ECOBEE_HOLD[preset_mode], self.hold_preference(), + self.hold_hours(), ) elif preset_mode == PRESET_NONE: @@ -585,14 +586,20 @@ class Thermostat(ClimateEntity): if climate_ref is not None: self.data.ecobee.set_climate_hold( - self.thermostat_index, climate_ref, self.hold_preference() + self.thermostat_index, + climate_ref, + self.hold_preference(), + self.hold_hours(), ) else: _LOGGER.warning("Received unknown preset mode: %s", preset_mode) else: self.data.ecobee.set_climate_hold( - self.thermostat_index, preset_mode, self.hold_preference() + self.thermostat_index, + preset_mode, + self.hold_preference(), + self.hold_hours(), ) @property @@ -743,7 +750,7 @@ class Thermostat(ClimateEntity): "useEndTime2hour": 2, "useEndTime4hour": 4, } - return hold_hours_map.get(device_preference, 0) + return hold_hours_map.get(device_preference) def create_vacation(self, service_data): """Create a vacation with user-specified parameters.""" diff --git a/homeassistant/components/ecobee/manifest.json b/homeassistant/components/ecobee/manifest.json index 040744b27aa..de7a7d325b3 100644 --- a/homeassistant/components/ecobee/manifest.json +++ b/homeassistant/components/ecobee/manifest.json @@ -3,6 +3,6 @@ "name": "ecobee", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/ecobee", - "requirements": ["python-ecobee-api==0.2.8"], + "requirements": ["python-ecobee-api==0.2.10"], "codeowners": ["@marthoc"] } diff --git a/requirements_all.txt b/requirements_all.txt index 1b2409a8e6f..24bb508c713 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1747,7 +1747,7 @@ python-clementine-remote==1.0.1 python-digitalocean==1.13.2 # homeassistant.components.ecobee -python-ecobee-api==0.2.8 +python-ecobee-api==0.2.10 # homeassistant.components.eq3btsmart # python-eq3bt==0.1.11 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 11064b63db8..e22ab3fa0e2 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -914,7 +914,7 @@ pysqueezebox==0.5.5 pysyncthru==0.7.0 # homeassistant.components.ecobee -python-ecobee-api==0.2.8 +python-ecobee-api==0.2.10 # homeassistant.components.darksky python-forecastio==1.4.0 diff --git a/tests/components/ecobee/test_climate.py b/tests/components/ecobee/test_climate.py index a9b9165d713..975fabcf9ab 100644 --- a/tests/components/ecobee/test_climate.py +++ b/tests/components/ecobee/test_climate.py @@ -209,14 +209,14 @@ async def test_set_temperature(ecobee_fixture, thermostat, data): data.reset_mock() thermostat.set_temperature(target_temp_low=20, target_temp_high=30) data.ecobee.set_hold_temp.assert_has_calls( - [mock.call(1, 30, 20, "nextTransition", 0)] + [mock.call(1, 30, 20, "nextTransition", None)] ) # Auto -> Hold data.reset_mock() thermostat.set_temperature(temperature=20) data.ecobee.set_hold_temp.assert_has_calls( - [mock.call(1, 25, 15, "nextTransition", 0)] + [mock.call(1, 25, 15, "nextTransition", None)] ) # Cool -> Hold @@ -224,7 +224,7 @@ async def test_set_temperature(ecobee_fixture, thermostat, data): ecobee_fixture["settings"]["hvacMode"] = "cool" thermostat.set_temperature(temperature=20.5) data.ecobee.set_hold_temp.assert_has_calls( - [mock.call(1, 20.5, 20.5, "nextTransition", 0)] + [mock.call(1, 20.5, 20.5, "nextTransition", None)] ) # Heat -> Hold @@ -232,7 +232,7 @@ async def test_set_temperature(ecobee_fixture, thermostat, data): ecobee_fixture["settings"]["hvacMode"] = "heat" thermostat.set_temperature(temperature=20) data.ecobee.set_hold_temp.assert_has_calls( - [mock.call(1, 20, 20, "nextTransition", 0)] + [mock.call(1, 20, 20, "nextTransition", None)] ) # Heat -> Auto @@ -311,7 +311,7 @@ def test_hold_hours(ecobee_fixture, thermostat): "askMe", ]: ecobee_fixture["settings"]["holdAction"] = action - assert thermostat.hold_hours() == 0 + assert thermostat.hold_hours() is None async def test_set_fan_mode_on(thermostat, data):