Cover all possible values for venstar operation_mode (#27949)

* cover all possible values for operation_mode

* Update climate.py

* Update climate.py

* Update climate.py

mapped homeassistant constants to client ones so we don't have to check for both

* black + pylint

* move mode_map to __init__()

* Update climate.py

* Update climate.py
This commit is contained in:
Tyler Page 2019-10-24 00:10:57 +00:00 committed by Martin Hjelmare
parent 160c201be1
commit 6a1501b59c

View File

@ -98,6 +98,11 @@ class VenstarThermostat(ClimateDevice):
"""Initialize the thermostat."""
self._client = client
self._humidifier = humidifier
self._mode_map = {
HVAC_MODE_HEAT: self._client.MODE_HEAT,
HVAC_MODE_COOL: self._client.MODE_COOL,
HVAC_MODE_AUTO: self._client.MODE_AUTO,
}
def update(self):
"""Update the data from the thermostat."""
@ -266,20 +271,20 @@ class VenstarThermostat(ClimateDevice):
def set_temperature(self, **kwargs):
"""Set a new target temperature."""
set_temp = True
operation_mode = kwargs.get(ATTR_HVAC_MODE, self._client.mode)
operation_mode = kwargs.get(ATTR_HVAC_MODE)
temp_low = kwargs.get(ATTR_TARGET_TEMP_LOW)
temp_high = kwargs.get(ATTR_TARGET_TEMP_HIGH)
temperature = kwargs.get(ATTR_TEMPERATURE)
if operation_mode != self._client.mode:
set_temp = self._set_operation_mode(operation_mode)
if operation_mode and self._mode_map.get(operation_mode) != self._client.mode:
set_temp = self._set_operation_mode(self._mode_map.get(operation_mode))
if set_temp:
if operation_mode == self._client.MODE_HEAT:
if self._mode_map.get(operation_mode, self._client.mode) == self._client.MODE_HEAT:
success = self._client.set_setpoints(temperature, self._client.cooltemp)
elif operation_mode == self._client.MODE_COOL:
elif self._mode_map.get(operation_mode, self._client.mode) == self._client.MODE_COOL:
success = self._client.set_setpoints(self._client.heattemp, temperature)
elif operation_mode == self._client.MODE_AUTO:
elif self._mode_map.get(operation_mode, self._client.mode) == self._client.MODE_AUTO:
success = self._client.set_setpoints(temp_low, temp_high)
else:
success = False