diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index efc50b1af2f..cb684785207 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -122,8 +122,6 @@ def set_away_mode(hass, away_mode, entity_id=None): if entity_id: data[ATTR_ENTITY_ID] = entity_id - _LOGGER.warning( - 'This service has been deprecated; use climate.set_hold_mode') hass.services.call(DOMAIN, SERVICE_SET_AWAY_MODE, data) @@ -243,8 +241,6 @@ def async_setup(hass, config): away_mode = service.data.get(ATTR_AWAY_MODE) - _LOGGER.warning( - 'This service has been deprecated; use climate.set_hold_mode') for climate in target_climate: if away_mode: yield from climate.async_turn_away_mode_on() diff --git a/homeassistant/components/climate/ecobee.py b/homeassistant/components/climate/ecobee.py index cdd8bc98169..18ccff459b0 100644 --- a/homeassistant/components/climate/ecobee.py +++ b/homeassistant/components/climate/ecobee.py @@ -186,12 +186,27 @@ class Thermostat(ClimateDevice): @property def current_hold_mode(self): """Return current hold mode.""" - if self.is_away_mode_on: + events = self.thermostat['events'] + if any((event['holdClimateRef'] == 'away' and + int(event['endDate'][0:4])-int(event['startDate'][0:4]) <= 1) + or event['type'] == 'autoAway' + for event in events): + # away hold is auto away or a temporary hold from away climate hold = 'away' - elif self.is_home_mode_on: + elif any(event['holdClimateRef'] == 'away' and + int(event['endDate'][0:4])-int(event['startDate'][0:4]) > 1 + for event in events): + # a permanent away is not considered a hold, but away_mode + hold = None + elif any(event['holdClimateRef'] == 'home' or + event['type'] == 'autoHome' + for event in events): + # home mode is auto home or any home hold hold = 'home' - elif self.is_temp_hold_on(): + elif any(event['type'] == 'hold' and event['running'] + for event in events): hold = 'temp' + # temperature hold is any other hold not based on climate else: hold = None return hold @@ -255,42 +270,23 @@ class Thermostat(ClimateDevice): return any(event['type'] == 'vacation' and event['running'] for event in events) - def is_temp_hold_on(self): - """Return true if temperature hold is on.""" - events = self.thermostat['events'] - return any(event['type'] == 'hold' and event['running'] - for event in events) - @property def is_away_mode_on(self): """Return true if away mode is on.""" events = self.thermostat['events'] - return any(event['holdClimateRef'] == 'away' or - event['type'] == 'autoAway' + return any(event['holdClimateRef'] == 'away' and + int(event['endDate'][0:4])-int(event['startDate'][0:4]) > 1 for event in events) def turn_away_mode_on(self): """Turn away on.""" self.data.ecobee.set_climate_hold(self.thermostat_index, - "away", self.hold_preference()) + "away", 'indefinite') self.update_without_throttle = True def turn_away_mode_off(self): """Turn away off.""" - self.set_hold_mode(None) - - @property - def is_home_mode_on(self): - """Return true if home mode is on.""" - events = self.thermostat['events'] - return any(event['holdClimateRef'] == 'home' or - event['type'] == 'autoHome' - for event in events) - - def turn_home_mode_on(self): - """Turn home on.""" - self.data.ecobee.set_climate_hold(self.thermostat_index, - "home", self.hold_preference()) + self.data.ecobee.resume_program(self.thermostat_index) self.update_without_throttle = True def set_hold_mode(self, hold_mode): @@ -298,11 +294,14 @@ class Thermostat(ClimateDevice): hold = self.current_hold_mode if hold == hold_mode: + # no change, so no action required return elif hold_mode == 'away': - self.turn_away_mode_on() + self.data.ecobee.set_climate_hold(self.thermostat_index, + "away", self.hold_preference()) elif hold_mode == 'home': - self.turn_home_mode_on() + self.data.ecobee.set_climate_hold(self.thermostat_index, + "home", self.hold_preference()) elif hold_mode == 'temp': self.set_temp_hold(int(self.current_temperature)) else: @@ -378,7 +377,8 @@ class Thermostat(ClimateDevice): default = self.thermostat['settings']['holdAction'] if default == 'nextTransition': return default - elif default == 'indefinite': - return default + # add further conditions if other hold durations should be + # supported; note that this should not include 'indefinite' + # as an indefinite away hold is interpreted as away_mode else: return 'nextTransition'