fix: hmip-etrv-2 now working with homeassistant (#11175)

* fix: hmip-etrv-2 now working with homeassistant (see also pull request at pyhomematic)

* fix linting issue and typo

* address comment @pvizeli

* Only use cached data in current operation mode

* fix linting issue
This commit is contained in:
Daniel Claes 2018-01-03 19:36:25 +01:00 committed by Pascal Vizeli
parent 36c7fbe06a
commit 75a39352ff
2 changed files with 27 additions and 7 deletions

View File

@ -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():

View File

@ -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'}],
}