From 2a5ca1c873203b86619bce8d59d72d897219d143 Mon Sep 17 00:00:00 2001 From: John Arild Berentsen Date: Sun, 28 Aug 2016 22:41:48 +0200 Subject: [PATCH] Map Modes to setpoint indexes (#3023) * Map Modes to setpoint indexes * Fixes devices with no thermostat mode * another try to fix devices without mode * another try to fix devices without mode 2 * another try to fix devices without mode 3 * fix setting setpoint for devices with no mode * fix setting setpoint for devices with no mode --- homeassistant/components/climate/zwave.py | 45 +++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/climate/zwave.py b/homeassistant/components/climate/zwave.py index 466fdcedf57..c8425ab4e8c 100755 --- a/homeassistant/components/climate/zwave.py +++ b/homeassistant/components/climate/zwave.py @@ -35,11 +35,21 @@ DEVICE_MAPPINGS = { REMOTEC_ZXT_120_THERMOSTAT: WORKAROUND_ZXT_120 } -ZXT_120_SET_TEMP = { +SET_TEMP_TO_INDEX = { 'Heat': 1, 'Cool': 2, + 'Auto': 3, + 'Aux Heat': 4, + 'Resume': 5, + 'Fan Only': 6, + 'Furnace': 7, 'Dry Air': 8, - 'Auto Changeover': 10 + 'Moist Air': 9, + 'Auto Changeover': 10, + 'Heat Econ': 11, + 'Cool Econ': 12, + 'Away': 13, + 'Unknown': 14 } @@ -109,7 +119,14 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice): for value in self._node.get_values( class_id=COMMAND_CLASS_THERMOSTAT_SETPOINT).values(): self._unit = value.units + if self.current_operation is not None: + if SET_TEMP_TO_INDEX.get(self._current_operation) \ + != value.index: + continue + if self._zxt_120: + continue self._target_temperature = int(value.data) + # Operation Mode for value in self._node.get_values( class_id=COMMAND_CLASS_THERMOSTAT_MODE).values(): @@ -203,21 +220,25 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice): """Set new target temperature.""" for value in self._node.get_values( class_id=COMMAND_CLASS_THERMOSTAT_SETPOINT).values(): - if self._zxt_120: - # ZXT-120 does not support get setpoint - self._target_temperature = temperature - if ZXT_120_SET_TEMP.get(self._current_operation) \ - != value.index: + if self.current_operation is not None: + if SET_TEMP_TO_INDEX.get(self._current_operation) \ + != value.index: continue - _LOGGER.debug("ZXT_120_SET_TEMP=%s and" + _LOGGER.debug("SET_TEMP_TO_INDEX=%s and" " self._current_operation=%s", - ZXT_120_SET_TEMP.get(self._current_operation), + SET_TEMP_TO_INDEX.get(self._current_operation), self._current_operation) - # ZXT-120 responds only to whole int - value.data = int(round(temperature, 0)) + if self._zxt_120: + # ZXT-120 does not support get setpoint + self._target_temperature = temperature + # ZXT-120 responds only to whole int + value.data = int(round(temperature, 0)) + else: + value.data = int(temperature) + break else: value.data = int(temperature) - break + break def set_fan_mode(self, fan): """Set new target fan mode."""