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
pull/2818/head
Heiko Rothe 2016-08-14 10:20:28 +02:00 committed by Paulus Schoutsen
parent bb14239d91
commit 8210d65850
1 changed files with 6 additions and 4 deletions

View File

@ -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