From 2e49303401f18bd3b99e3ab68be7b6122e607b7e Mon Sep 17 00:00:00 2001 From: Mark Coombes Date: Fri, 4 Oct 2019 20:35:31 -0400 Subject: [PATCH] Add turn_on method to ecobee climate platform (#27103) * Add turn on method to ecobee climate * Update climate.py * Update value in async_update * Fix update in async_update * Simplify async_update * Fix lint complaining about log string * Cleanup inline if statement --- homeassistant/components/ecobee/climate.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/homeassistant/components/ecobee/climate.py b/homeassistant/components/ecobee/climate.py index 491fd8d686a..e29e2381008 100644 --- a/homeassistant/components/ecobee/climate.py +++ b/homeassistant/components/ecobee/climate.py @@ -264,6 +264,7 @@ class Thermostat(ClimateDevice): self.thermostat = self.data.ecobee.get_thermostat(self.thermostat_index) self._name = self.thermostat["name"] self.vacation = None + self._last_active_hvac_mode = HVAC_MODE_AUTO self._operation_list = [] if self.thermostat["settings"]["heatStages"]: @@ -289,6 +290,8 @@ class Thermostat(ClimateDevice): else: await self.data.update() self.thermostat = self.data.ecobee.get_thermostat(self.thermostat_index) + if self.hvac_mode is not HVAC_MODE_OFF: + self._last_active_hvac_mode = self.hvac_mode @property def available(self): @@ -700,3 +703,12 @@ class Thermostat(ClimateDevice): vacation_name, ) self.data.ecobee.delete_vacation(self.thermostat_index, vacation_name) + + def turn_on(self): + """Set the thermostat to the last active HVAC mode.""" + _LOGGER.debug( + "Turning on ecobee thermostat %s in %s mode", + self.name, + self._last_active_hvac_mode, + ) + self.set_hvac_mode(self._last_active_hvac_mode)