From 97bfcac67e4a287fa5390ec7abf34457ced8d548 Mon Sep 17 00:00:00 2001 From: Daniel Claes Date: Sat, 16 Dec 2017 23:16:55 +0100 Subject: [PATCH 1/5] fix: hmip-etrv-2 now working with homeassistant (see also pull request at pyhomematic) --- homeassistant/components/climate/homematic.py | 6 ++++-- homeassistant/components/homematic/__init__.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/climate/homematic.py b/homeassistant/components/climate/homematic.py index 33a63b35530c..47190d152041 100644 --- a/homeassistant/components/climate/homematic.py +++ b/homeassistant/components/climate/homematic.py @@ -39,6 +39,7 @@ ] HM_CONTROL_MODE = 'CONTROL_MODE' +HM_IP_CONTROL_MODE = 'SET_POINT_MODE' SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE @@ -72,13 +73,14 @@ def temperature_unit(self): @property def current_operation(self): """Return current operation ie. heat, cool, idle.""" - if HM_CONTROL_MODE not in self._data: + if HM_CONTROL_MODE not in self._data and HM_IP_CONTROL_MODE in self._hmdevice.ATTRIBUTENODE: return None # read state and search + hm_code = getattr(self._hmdevice, "MODE", 0) for mode, state in HM_STATE_MAP.items(): code = getattr(self._hmdevice, mode, 0) - if self._data.get('CONTROL_MODE') == code: + if hm_code == code: return state @property diff --git a/homeassistant/components/homematic/__init__.py b/homeassistant/components/homematic/__init__.py index a11c8c0f22c7..38e9583d4055 100644 --- a/homeassistant/components/homematic/__init__.py +++ b/homeassistant/components/homematic/__init__.py @@ -90,6 +90,7 @@ 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 @@ 'POWER': ['power', {}], 'CURRENT': ['current', {}], 'VOLTAGE': ['voltage', {}], + 'OPERATING_VOLTAGE': ['voltage', {}], 'WORKING': ['working', {0: 'No', 1: 'Yes'}], } From 385801e40e94f99b49d7919c7809a2ec86305109 Mon Sep 17 00:00:00 2001 From: Daniel Claes Date: Sat, 16 Dec 2017 23:21:09 +0100 Subject: [PATCH 2/5] fix linting issue and typo --- homeassistant/components/climate/homematic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/climate/homematic.py b/homeassistant/components/climate/homematic.py index 47190d152041..c0bdb27ab06c 100644 --- a/homeassistant/components/climate/homematic.py +++ b/homeassistant/components/climate/homematic.py @@ -73,7 +73,8 @@ def temperature_unit(self): @property def current_operation(self): """Return current operation ie. heat, cool, idle.""" - if HM_CONTROL_MODE not in self._data and HM_IP_CONTROL_MODE in self._hmdevice.ATTRIBUTENODE: + if HM_CONTROL_MODE not in self._data \ + and HM_IP_CONTROL_MODE not in self._hmdevice.ATTRIBUTENODE: return None # read state and search From 0494ba0d7762651e33e9f5042f7374b7f1f7a8bd Mon Sep 17 00:00:00 2001 From: Daniel Claes Date: Sun, 17 Dec 2017 01:38:37 +0100 Subject: [PATCH 3/5] address comment @pvizeli --- homeassistant/components/climate/homematic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/climate/homematic.py b/homeassistant/components/climate/homematic.py index c0bdb27ab06c..fc1144967664 100644 --- a/homeassistant/components/climate/homematic.py +++ b/homeassistant/components/climate/homematic.py @@ -73,8 +73,7 @@ def temperature_unit(self): @property def current_operation(self): """Return current operation ie. heat, cool, idle.""" - if HM_CONTROL_MODE not in self._data \ - and HM_IP_CONTROL_MODE not in self._hmdevice.ATTRIBUTENODE: + if HM_CONTROL_MODE not in self._data: return None # read state and search @@ -144,7 +143,8 @@ def _init_data_struct(self): 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(): From 7464d0fbc65d13fdcb312b48d75eccaca4683d73 Mon Sep 17 00:00:00 2001 From: Daniel Claes Date: Fri, 29 Dec 2017 17:58:30 +0100 Subject: [PATCH 4/5] Only use cached data in current operation mode --- homeassistant/components/climate/homematic.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/climate/homematic.py b/homeassistant/components/climate/homematic.py index fc1144967664..3fcd9ec54db7 100644 --- a/homeassistant/components/climate/homematic.py +++ b/homeassistant/components/climate/homematic.py @@ -8,7 +8,7 @@ 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'] @@ -76,12 +76,25 @@ def current_operation(self): if HM_CONTROL_MODE not in self._data: return None - # read state and search - hm_code = getattr(self._hmdevice, "MODE", 0) - for mode, state in HM_STATE_MAP.items(): - code = getattr(self._hmdevice, mode, 0) - if hm_code == 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): @@ -127,6 +140,7 @@ def set_operation_mode(self, operation_mode): if state == operation_mode: code = getattr(self._hmdevice, mode, 0) self._hmdevice.MODE = code + return @property def min_temp(self): From 13dae30d63d455c8db2014c938a54d90dce574c7 Mon Sep 17 00:00:00 2001 From: Daniel Claes Date: Fri, 29 Dec 2017 18:18:02 +0100 Subject: [PATCH 5/5] fix linting issue --- homeassistant/components/climate/homematic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/climate/homematic.py b/homeassistant/components/climate/homematic.py index 3fcd9ec54db7..b8fb7a984fa3 100644 --- a/homeassistant/components/climate/homematic.py +++ b/homeassistant/components/climate/homematic.py @@ -8,7 +8,8 @@ from homeassistant.components.climate import ( ClimateDevice, STATE_AUTO, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE) -from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES, HM_ATTRIBUTE_SUPPORT +from homeassistant.components.homematic import ( + HMDevice, ATTR_DISCOVER_DEVICES, HM_ATTRIBUTE_SUPPORT) from homeassistant.const import TEMP_CELSIUS, STATE_UNKNOWN, ATTR_TEMPERATURE DEPENDENCIES = ['homematic']