From d326d187d1fb394940d891ec49ae203eeeabd3d5 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Thu, 30 Jun 2016 23:54:04 +0200 Subject: [PATCH] fix bug in event handling and add cast for watersensor --- homeassistant/components/homematic.py | 12 ++++++++---- homeassistant/components/sensor/homematic.py | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/homematic.py b/homeassistant/components/homematic.py index fb31408bd82..b2bfc94087a 100644 --- a/homeassistant/components/homematic.py +++ b/homeassistant/components/homematic.py @@ -288,15 +288,19 @@ def setup_hmdevice_discovery_helper(hmdevicetype, discovery_info, def _hm_event_handler(hass, device, caller, attribute, value): """Handle all pyhomematic device events.""" - channel = device.split(":")[1] - address = device.split(":")[0] - hmdevice = HOMEMATIC.devices.get(address) + try: + channel = int(device.split(":")[1]) + address = device.split(":")[0] + hmdevice = HOMEMATIC.devices.get(address) + except (TypeError, ValueError): + _LOGGER.error("Event handling channel convert error!") + return # is not a event? if attribute not in hmdevice.EVENTNODE: return - _LOGGER.debug("Event %s for %s channel %s", attribute, + _LOGGER.debug("Event %s for %s channel %i", attribute, hmdevice.NAME, channel) # a keypress event diff --git a/homeassistant/components/sensor/homematic.py b/homeassistant/components/sensor/homematic.py index 2efa4fdef38..efd22b6cd69 100644 --- a/homeassistant/components/sensor/homematic.py +++ b/homeassistant/components/sensor/homematic.py @@ -17,7 +17,8 @@ _LOGGER = logging.getLogger(__name__) DEPENDENCIES = ['homematic'] HM_STATE_HA_CAST = { - "RotaryHandleSensor": {0: "closed", 1: "tilted", 2: "open"} + "RotaryHandleSensor": {0: "closed", 1: "tilted", 2: "open"}, + "WaterSensor": {0: "dry", 1: "wet", 2: "water"} } HM_UNIT_HA_CAST = {