Homematic fixes + device support (#5503)

* Using new MaxShutterContact class

* Skip unnecessary function calls

* Added casting for VALUE

* Some renaming to clarify what's happening

* Bumped dependency version

* Bumped version in requirements
This commit is contained in:
Daniel Perna 2017-01-22 14:20:49 +01:00 committed by Pascal Vizeli
parent 75adb7ff46
commit 59b0491d29
4 changed files with 15 additions and 12 deletions

View file

@ -17,6 +17,7 @@ DEPENDENCIES = ['homematic']
SENSOR_TYPES_CLASS = {
"Remote": None,
"ShutterContact": "opening",
"MaxShutterContact": "opening",
"IPShutterContact": "opening",
"Smoke": "smoke",
"SmokeV2": "smoke",

View file

@ -23,7 +23,7 @@ from homeassistant.config import load_yaml_config_file
from homeassistant.util import Throttle
DOMAIN = 'homematic'
REQUIREMENTS = ["pyhomematic==0.1.19"]
REQUIREMENTS = ["pyhomematic==0.1.20"]
MIN_TIME_BETWEEN_UPDATE_HUB = timedelta(seconds=300)
SCAN_INTERVAL = timedelta(seconds=30)
@ -432,8 +432,8 @@ def _system_callback_handler(hass, config, src, *args):
}, config)
def _get_devices(hass, device_type, keys, proxy):
"""Get the Homematic devices."""
def _get_devices(hass, discovery_type, keys, proxy):
"""Get the Homematic devices for given discovery_type."""
device_arr = []
for key in keys:
@ -441,14 +441,14 @@ def _get_devices(hass, device_type, keys, proxy):
class_name = device.__class__.__name__
metadata = {}
# is class supported by discovery type
if class_name not in HM_DEVICE_TYPES[device_type]:
# Class supported by discovery type
if class_name not in HM_DEVICE_TYPES[discovery_type]:
continue
# Load metadata if needed to generate a param list
if device_type == DISCOVER_SENSORS:
if discovery_type == DISCOVER_SENSORS:
metadata.update(device.SENSORNODE)
elif device_type == DISCOVER_BINARY_SENSORS:
elif discovery_type == DISCOVER_BINARY_SENSORS:
metadata.update(device.BINARYNODE)
else:
metadata.update({None: device.ELEMENT})
@ -459,8 +459,9 @@ def _get_devices(hass, device_type, keys, proxy):
if param in HM_IGNORE_DISCOVERY_NODE:
continue
# add devices
_LOGGER.debug("Handling %s: %s", param, channels)
# Add devices
_LOGGER.debug("%s: Handling %s: %s: %s",
discovery_type, key, param, channels)
for channel in channels:
name = _create_ha_name(
name=device.NAME, channel=channel, param=param,
@ -485,7 +486,7 @@ def _get_devices(hass, device_type, keys, proxy):
str(err))
else:
_LOGGER.debug("Got no params for %s", key)
_LOGGER.debug("%s autodiscovery: %s", device_type, str(device_arr))
_LOGGER.debug("%s autodiscovery done: %s", discovery_type, str(device_arr))
return device_arr
@ -873,7 +874,7 @@ class HMDevice(Entity):
(self._hmdevice.SENSORNODE, self._hmdevice.getSensorData),
(self._hmdevice.BINARYNODE, self._hmdevice.getBinaryData)):
for node in metadata:
if node in self._data:
if metadata[node] and node in self._data:
self._data[node] = funct(name=node, channel=self._channel)
return True

View file

@ -41,6 +41,7 @@ HM_UNIT_HA_CAST = {
"SUNSHINEDURATION": "#",
"AIR_PRESSURE": "hPa",
"FREQUENCY": "Hz",
"VALUE": "#"
}

View file

@ -435,7 +435,7 @@ pyharmony==1.0.12
pyhik==0.0.7
# homeassistant.components.homematic
pyhomematic==0.1.19
pyhomematic==0.1.20
# homeassistant.components.device_tracker.icloud
pyicloud==0.9.1