From 12ce3deffc688d3569b13e82f0f1392276c7b0a4 Mon Sep 17 00:00:00 2001 From: Heiko Rothe Date: Sun, 14 Aug 2016 10:20:28 +0200 Subject: [PATCH] Check for existence of system mode on Honeywell thermostats (#2815) * Check for existence of system mode on Honeywell thermostats * Return None instead of undefined * Use getattr instead of if/else --- homeassistant/components/thermostat/honeywell.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/thermostat/honeywell.py b/homeassistant/components/thermostat/honeywell.py index b31dfea0b4b..6d9a4b790eb 100644 --- a/homeassistant/components/thermostat/honeywell.py +++ b/homeassistant/components/thermostat/honeywell.py @@ -139,7 +139,7 @@ class RoundThermostat(ThermostatDevice): @property def operation(self: ThermostatDevice) -> str: """Get the current operation of the system.""" - return self.device.system_mode + return getattr(self.device, 'system_mode', None) @property def is_away_mode_on(self): @@ -148,7 +148,8 @@ class RoundThermostat(ThermostatDevice): def set_hvac_mode(self: ThermostatDevice, hvac_mode: str) -> None: """Set the HVAC mode for the thermostat.""" - self.device.system_mode = hvac_mode + if hasattr(self.device, 'system_mode'): + self.device.system_mode = hvac_mode def turn_away_mode_on(self): """Turn away on. @@ -231,7 +232,7 @@ class HoneywellUSThermostat(ThermostatDevice): @property def operation(self: ThermostatDevice) -> str: """Return current operation ie. heat, cool, idle.""" - return self._device.system_mode + return getattr(self._device, 'system_mode', None) def set_temperature(self, temperature): """Set target temperature.""" @@ -261,4 +262,5 @@ class HoneywellUSThermostat(ThermostatDevice): def set_hvac_mode(self: ThermostatDevice, hvac_mode: str) -> None: """Set the system mode (Cool, Heat, etc).""" - self._device.system_mode = hvac_mode + if hasattr(self._device, 'system_mode'): + self._device.system_mode = hvac_mode