Improve target temperature selection logic

When picking which of the high/low temperatures to display as the
"target", it makes more sense to take the outside temperature into
consideration, rather than the current temperature of the thermostat.

If the temperature outside is less than the temperature of the
thermostat, then we are far more likely to end up in "heating" mode
eventually, and vice versa, regardless of where the current inside
temp falls in the range between high and low.
This commit is contained in:
Josh Wright 2016-04-12 18:25:24 -04:00
parent c4a71fbfa7
commit 942d722dcf

View File

@ -88,8 +88,10 @@ class NestThermostat(ThermostatDevice):
elif self.operation == STATE_HEAT:
temp = low
else:
range_average = (low + high)/2
if self.current_temperature < range_average:
# If the outside temp is lower than the current temp, consider
# the 'low' temp to the target, otherwise use the high temp
if (self.device.structure.weather.current.temperature <
self.current_temperature):
temp = low
elif self.current_temperature >= range_average:
temp = high