diff --git a/homeassistant/components/climate/homematic.py b/homeassistant/components/climate/homematic.py index 33a63b35530..b8fb7a984fa 100644 --- a/homeassistant/components/climate/homematic.py +++ b/homeassistant/components/climate/homematic.py @@ -8,7 +8,8 @@ import logging from homeassistant.components.climate import ( ClimateDevice, STATE_AUTO, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE) -from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES +from homeassistant.components.homematic import ( + HMDevice, ATTR_DISCOVER_DEVICES, HM_ATTRIBUTE_SUPPORT) from homeassistant.const import TEMP_CELSIUS, STATE_UNKNOWN, ATTR_TEMPERATURE DEPENDENCIES = ['homematic'] @@ -39,6 +40,7 @@ HM_HUMI_MAP = [ ] HM_CONTROL_MODE = 'CONTROL_MODE' +HM_IP_CONTROL_MODE = 'SET_POINT_MODE' SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE @@ -75,11 +77,25 @@ class HMThermostat(HMDevice, ClimateDevice): if HM_CONTROL_MODE not in self._data: return None - # read state and search - for mode, state in HM_STATE_MAP.items(): - code = getattr(self._hmdevice, mode, 0) - if self._data.get('CONTROL_MODE') == code: - return state + set_point_mode = self._data.get('SET_POINT_MODE', -1) + control_mode = self._data.get('CONTROL_MODE', -1) + boost_mode = self._data.get('BOOST_MODE', False) + + # boost mode is active + if boost_mode: + return STATE_BOOST + + # HM ip etrv 2 uses the set_point_mode to say if its + # auto or manual + elif not set_point_mode == -1: + code = set_point_mode + # Other devices use the control_mode + else: + code = control_mode + + # get the name of the mode + name = HM_ATTRIBUTE_SUPPORT[HM_CONTROL_MODE][1][code] + return name.lower() @property def operation_list(self): @@ -125,6 +141,7 @@ class HMThermostat(HMDevice, ClimateDevice): if state == operation_mode: code = getattr(self._hmdevice, mode, 0) self._hmdevice.MODE = code + return @property def min_temp(self): @@ -141,7 +158,8 @@ class HMThermostat(HMDevice, ClimateDevice): self._state = next(iter(self._hmdevice.WRITENODE.keys())) self._data[self._state] = STATE_UNKNOWN - if HM_CONTROL_MODE in self._hmdevice.ATTRIBUTENODE: + if HM_CONTROL_MODE in self._hmdevice.ATTRIBUTENODE or \ + HM_IP_CONTROL_MODE in self._hmdevice.ATTRIBUTENODE: self._data[HM_CONTROL_MODE] = STATE_UNKNOWN for node in self._hmdevice.SENSORNODE.keys(): diff --git a/homeassistant/components/homematic/__init__.py b/homeassistant/components/homematic/__init__.py index 08e8455b302..117d04c88f6 100644 --- a/homeassistant/components/homematic/__init__.py +++ b/homeassistant/components/homematic/__init__.py @@ -90,6 +90,7 @@ HM_IGNORE_DISCOVERY_NODE = [ HM_ATTRIBUTE_SUPPORT = { 'LOWBAT': ['battery', {0: 'High', 1: 'Low'}], + 'LOW_BAT': ['battery', {0: 'High', 1: 'Low'}], 'ERROR': ['sabotage', {0: 'No', 1: 'Yes'}], 'RSSI_DEVICE': ['rssi', {}], 'VALVE_STATE': ['valve', {}], @@ -105,6 +106,7 @@ HM_ATTRIBUTE_SUPPORT = { 'POWER': ['power', {}], 'CURRENT': ['current', {}], 'VOLTAGE': ['voltage', {}], + 'OPERATING_VOLTAGE': ['voltage', {}], 'WORKING': ['working', {0: 'No', 1: 'Yes'}], }