From 5223e0e80b666d81e834600fc436de504fa554b0 Mon Sep 17 00:00:00 2001 From: Nuno Sousa Date: Wed, 15 Jun 2016 12:49:11 +0100 Subject: [PATCH] Fix zwave rollershutter (#4) Fix zwave rollershutter by nunofgs --- .../components/rollershutter/zwave.py | 6 +++-- homeassistant/components/switch/zwave.py | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/rollershutter/zwave.py b/homeassistant/components/rollershutter/zwave.py index b12edbd3f51ab6..51eb617a447ebc 100644 --- a/homeassistant/components/rollershutter/zwave.py +++ b/homeassistant/components/rollershutter/zwave.py @@ -28,7 +28,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): if value.command_class != zwave.COMMAND_CLASS_SWITCH_MULTILEVEL: return - if value.index != 0: + if value.index != 1: return value.set_change_verified(False) @@ -81,4 +81,6 @@ def stop(self, **kwargs): """Stop the roller shutter.""" for value in self._node.get_values( class_id=COMMAND_CLASS_SWITCH_BINARY).values(): - value.data = False + # This binary switch will toggle between UP (true), DOWN (False). + # It also stops the shutter if sent the same value while the shutter is moving. + value.data = value.data diff --git a/homeassistant/components/switch/zwave.py b/homeassistant/components/switch/zwave.py index f59d830f4c012f..7dba57b8e7e63b 100644 --- a/homeassistant/components/switch/zwave.py +++ b/homeassistant/components/switch/zwave.py @@ -6,9 +6,22 @@ """ # Because we do not compile openzwave on CI # pylint: disable=import-error +import logging from homeassistant.components.switch import DOMAIN, SwitchDevice from homeassistant.components import zwave +FIBARO = 0x010F +FIBARO_FGRM_222 = 0x1000 +FIBARO_FGRM_222_ROLLERSHUTTER = (FIBARO, FIBARO_FGRM_222) + +WORKAROUND_IGNORE = 'ignore' + +DEVICE_MAPPINGS = { + FIBARO_FGRM_222_ROLLERSHUTTER: WORKAROUND_IGNORE +} + +_LOGGER = logging.getLogger(__name__) + # pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): @@ -18,6 +31,15 @@ def setup_platform(hass, config, add_devices, discovery_info=None): node = zwave.NETWORK.nodes[discovery_info[zwave.ATTR_NODE_ID]] value = node.values[discovery_info[zwave.ATTR_VALUE_ID]] + # Make sure that we have values for the key before converting to int + if (value.node.manufacturer_id.strip() and + value.node.product_id.strip()): + specific_sensor_key = (int(value.node.manufacturer_id, 16), + int(value.node.product_id, 16)) + if specific_sensor_key in DEVICE_MAPPINGS: + if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_IGNORE: + _LOGGER.debug("Fibaro FGRM-222 Rollershutter, ignoring") + return if value.command_class != zwave.COMMAND_CLASS_SWITCH_BINARY: return