Skip to content

Commit

Permalink
Fix zwave rollershutter (home-assistant#4)
Browse files Browse the repository at this point in the history
Fix zwave rollershutter by nunofgs
  • Loading branch information
nunofgs authored and turbokongen committed Jun 15, 2016
1 parent 40a0172 commit 5223e0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions homeassistant/components/rollershutter/zwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
22 changes: 22 additions & 0 deletions homeassistant/components/switch/zwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 5223e0e

Please sign in to comment.