Update Ecobee state after making changes to climate (#3436)

* Update Ecobee state after making changes to climate

Without this, climate and sensor state will take up to 3 minutes
(the MIN_TIME_BETWEEN_UPDATES on its update throttle) to update in
the interface, which makes it more difficult to do automation around the
state.

* Use a boolean instance variable that update can check, rather than always calling update
pull/2930/merge
Josh Nichols 2016-09-18 16:20:06 -04:00 committed by Paulus Schoutsen
parent 11c07440fe
commit b34101b277
1 changed files with 12 additions and 1 deletions

View File

@ -86,10 +86,16 @@ class Thermostat(ClimateDevice):
self.hold_temp = hold_temp
self._operation_list = ['auto', 'auxHeatOnly', 'cool',
'heat', 'off']
self.update_without_throttle = False
def update(self):
"""Get the latest state from the thermostat."""
self.data.update()
if self.update_without_throttle:
self.data.update(no_throttle=True)
self.update_without_throttle = False
else:
self.data.update()
self.thermostat = self.data.ecobee.get_thermostat(
self.thermostat_index)
@ -211,10 +217,12 @@ class Thermostat(ClimateDevice):
"away", "indefinite")
else:
self.data.ecobee.set_climate_hold(self.thermostat_index, "away")
self.update_without_throttle = True
def turn_away_mode_off(self):
"""Turn away off."""
self.data.ecobee.resume_program(self.thermostat_index)
self.update_without_throttle = True
def set_temperature(self, **kwargs):
"""Set new target temperature."""
@ -241,15 +249,18 @@ class Thermostat(ClimateDevice):
"high=%s, is=%s", low_temp, isinstance(
low_temp, (int, float)), high_temp,
isinstance(high_temp, (int, float)))
self.update_without_throttle = True
def set_operation_mode(self, operation_mode):
"""Set HVAC mode (auto, auxHeatOnly, cool, heat, off)."""
self.data.ecobee.set_hvac_mode(self.thermostat_index, operation_mode)
self.update_without_throttle = True
def set_fan_min_on_time(self, fan_min_on_time):
"""Set the minimum fan on time."""
self.data.ecobee.set_fan_min_on_time(self.thermostat_index,
fan_min_on_time)
self.update_without_throttle = True
# Home and Sleep mode aren't used in UI yet: