From 04b1621b655e772dcdcd588dc3a0f051d951107f Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 11 Jul 2017 03:12:51 -0500 Subject: [PATCH] Fix radiothermostat -1 value issue (#8395) * Fix -1 value issue Fixed issue where thermostat will sometimes return a current temperature or set temperature value of -1 * Update radiotherm.py * Update radiotherm.py * Update radiotherm.py Added retry limit * Update radiotherm.py * Update radiotherm.py --- .../components/climate/radiotherm.py | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/climate/radiotherm.py b/homeassistant/components/climate/radiotherm.py index 8011f53f375..22e09ad0161 100644 --- a/homeassistant/components/climate/radiotherm.py +++ b/homeassistant/components/climate/radiotherm.py @@ -136,24 +136,53 @@ class RadioThermostat(ClimateDevice): return self._away def update(self): - """Update the data from the thermostat.""" - self._current_temperature = self.device.temp['raw'] + """Update and validate the data from the thermostat.""" + current_temp = self.device.temp['raw'] + if current_temp == -1: + _LOGGER.error("Couldn't get valid temperature reading") + return + self._current_temperature = current_temp self._name = self.device.name['raw'] - self._fmode = self.device.fmode['human'] - self._tmode = self.device.tmode['human'] - self._tstate = self.device.tstate['human'] + try: + self._fmode = self.device.fmode['human'] + except AttributeError: + _LOGGER.error("Couldn't get valid fan mode reading") + try: + self._tmode = self.device.tmode['human'] + except AttributeError: + _LOGGER.error("Couldn't get valid thermostat mode reading") + try: + self._tstate = self.device.tstate['human'] + except AttributeError: + _LOGGER.error("Couldn't get valid thermostat state reading") if self._tmode == 'Cool': - self._target_temperature = self.device.t_cool['raw'] + target_temp = self.device.t_cool['raw'] + if target_temp == -1: + _LOGGER.error("Couldn't get target reading") + return + self._target_temperature = target_temp self._current_operation = STATE_COOL elif self._tmode == 'Heat': - self._target_temperature = self.device.t_heat['raw'] + target_temp = self.device.t_heat['raw'] + if target_temp == -1: + _LOGGER.error("Couldn't get valid target reading") + return + self._target_temperature = target_temp self._current_operation = STATE_HEAT elif self._tmode == 'Auto': if self._tstate == 'Cool': - self._target_temperature = self.device.t_cool['raw'] + target_temp = self.device.t_cool['raw'] + if target_temp == -1: + _LOGGER.error("Couldn't get valid target reading") + return + self._target_temperature = target_temp elif self._tstate == 'Heat': - self._target_temperature = self.device.t_heat['raw'] + target_temp = self.device.t_heat['raw'] + if target_temp == -1: + _LOGGER.error("Couldn't get valid target reading") + return + self._target_temperature = target_temp self._current_operation = STATE_AUTO else: self._current_operation = STATE_IDLE