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
This commit is contained in:
parent
7c041f0797
commit
12ce3deffc
1 changed files with 6 additions and 4 deletions
|
@ -139,7 +139,7 @@ class RoundThermostat(ThermostatDevice):
|
||||||
@property
|
@property
|
||||||
def operation(self: ThermostatDevice) -> str:
|
def operation(self: ThermostatDevice) -> str:
|
||||||
"""Get the current operation of the system."""
|
"""Get the current operation of the system."""
|
||||||
return self.device.system_mode
|
return getattr(self.device, 'system_mode', None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_away_mode_on(self):
|
def is_away_mode_on(self):
|
||||||
|
@ -148,6 +148,7 @@ class RoundThermostat(ThermostatDevice):
|
||||||
|
|
||||||
def set_hvac_mode(self: ThermostatDevice, hvac_mode: str) -> None:
|
def set_hvac_mode(self: ThermostatDevice, hvac_mode: str) -> None:
|
||||||
"""Set the HVAC mode for the thermostat."""
|
"""Set the HVAC mode for the thermostat."""
|
||||||
|
if hasattr(self.device, 'system_mode'):
|
||||||
self.device.system_mode = hvac_mode
|
self.device.system_mode = hvac_mode
|
||||||
|
|
||||||
def turn_away_mode_on(self):
|
def turn_away_mode_on(self):
|
||||||
|
@ -231,7 +232,7 @@ class HoneywellUSThermostat(ThermostatDevice):
|
||||||
@property
|
@property
|
||||||
def operation(self: ThermostatDevice) -> str:
|
def operation(self: ThermostatDevice) -> str:
|
||||||
"""Return current operation ie. heat, cool, idle."""
|
"""Return current operation ie. heat, cool, idle."""
|
||||||
return self._device.system_mode
|
return getattr(self._device, 'system_mode', None)
|
||||||
|
|
||||||
def set_temperature(self, temperature):
|
def set_temperature(self, temperature):
|
||||||
"""Set target temperature."""
|
"""Set target temperature."""
|
||||||
|
@ -261,4 +262,5 @@ class HoneywellUSThermostat(ThermostatDevice):
|
||||||
|
|
||||||
def set_hvac_mode(self: ThermostatDevice, hvac_mode: str) -> None:
|
def set_hvac_mode(self: ThermostatDevice, hvac_mode: str) -> None:
|
||||||
"""Set the system mode (Cool, Heat, etc)."""
|
"""Set the system mode (Cool, Heat, etc)."""
|
||||||
|
if hasattr(self._device, 'system_mode'):
|
||||||
self._device.system_mode = hvac_mode
|
self._device.system_mode = hvac_mode
|
||||||
|
|
Loading…
Add table
Reference in a new issue