Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions homeassistant/components/cover/zwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
SUPPORT_GARAGE = SUPPORT_OPEN | SUPPORT_CLOSE


def get_device(values, **kwargs):
def get_device(values, node_config, **kwargs):
"""Create zwave entity device."""
invert_buttons = node_config.get(zwave.CONF_INVERT_OPENCLOSE_BUTTONS)
if (values.primary.command_class ==
zwave.const.COMMAND_CLASS_SWITCH_MULTILEVEL
and values.primary.index == 0):
return ZwaveRollershutter(values)
return ZwaveRollershutter(values, invert_buttons)
elif (values.primary.command_class in [
zwave.const.COMMAND_CLASS_SWITCH_BINARY,
zwave.const.COMMAND_CLASS_BARRIER_OPERATOR]):
Expand All @@ -36,13 +37,14 @@ def get_device(values, **kwargs):
class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice):
"""Representation of an Zwave roller shutter."""

def __init__(self, values):
def __init__(self, values, invert_buttons):
"""Initialize the zwave rollershutter."""
ZWaveDeviceEntity.__init__(self, values, DOMAIN)
# pylint: disable=no-member
self._open_id = None
self._close_id = None
self._current_position = None
self._invert_buttons = invert_buttons

self._workaround = workaround.get_device_mapping(values.primary)
if self._workaround:
Expand All @@ -56,10 +58,9 @@ def update_properties(self):

if self.values.open and self.values.close and \
self._open_id is None and self._close_id is None:
if self._workaround == workaround.WORKAROUND_REVERSE_OPEN_CLOSE:
if self._invert_buttons:
self._open_id = self.values.close.value_id
self._close_id = self.values.open.value_id
self._workaround = None
else:
self._open_id = self.values.open.value_id
self._close_id = self.values.close.value_id
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/zwave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
CONF_USB_STICK_PATH = 'usb_path'
CONF_CONFIG_PATH = 'config_path'
CONF_IGNORED = 'ignored'
CONF_INVERT_OPENCLOSE_BUTTONS = 'invert_openclose_buttons'
CONF_REFRESH_VALUE = 'refresh_value'
CONF_REFRESH_DELAY = 'delay'
CONF_DEVICE_CONFIG = 'device_config'
Expand All @@ -58,6 +59,7 @@
DEFAULT_POLLING_INTERVAL = 60000
DEFAULT_DEBUG = False
DEFAULT_CONF_IGNORED = False
DEFAULT_CONF_INVERT_OPENCLOSE_BUTTONS = False
DEFAULT_CONF_REFRESH_VALUE = False
DEFAULT_CONF_REFRESH_DELAY = 5

Expand Down Expand Up @@ -105,6 +107,8 @@
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({
vol.Optional(CONF_POLLING_INTENSITY): cv.positive_int,
vol.Optional(CONF_IGNORED, default=DEFAULT_CONF_IGNORED): cv.boolean,
vol.Optional(CONF_INVERT_OPENCLOSE_BUTTONS,
default=DEFAULT_CONF_INVERT_OPENCLOSE_BUTTONS): cv.boolean,
vol.Optional(CONF_REFRESH_VALUE, default=DEFAULT_CONF_REFRESH_VALUE):
cv.boolean,
vol.Optional(CONF_REFRESH_DELAY, default=DEFAULT_CONF_REFRESH_DELAY):
Expand Down
3 changes: 0 additions & 3 deletions homeassistant/components/zwave/workaround.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
# Workarounds
WORKAROUND_NO_OFF_EVENT = 'trigger_no_off_event'
WORKAROUND_NO_POSITION = 'workaround_no_position'
WORKAROUND_REVERSE_OPEN_CLOSE = 'reverse_open_close'
WORKAROUND_REFRESH_NODE_ON_UPDATE = 'refresh_node_on_update'
WORKAROUND_IGNORE = 'workaround_ignore'

Expand All @@ -43,12 +42,10 @@
}

SOMFY_ZRTSI_CONTROLLER_MT = (SOMFY, SOMFY_ZRTSI)
FIBARO_FGRM222_MT = (FIBARO, FGRM222_SHUTTER2)

# List of workarounds by (manufacturer_id, product_type)
DEVICE_MAPPINGS_MT = {
SOMFY_ZRTSI_CONTROLLER_MT: WORKAROUND_NO_POSITION,
FIBARO_FGRM222_MT: WORKAROUND_REVERSE_OPEN_CLOSE,
}


Expand Down
7 changes: 5 additions & 2 deletions tests/components/cover/test_zwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@ def test_roller_commands(mock_network, mock_openzwave):
@patch('homeassistant.components.zwave.NETWORK')
def test_roller_reverse_open_close(mock_network, mock_openzwave):
"""Test position changed."""
node = MockNode(manufacturer_id='010f', product_type='0301')
node = MockNode()
value = MockValue(data=50, node=node,
command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL)
open_value = MockValue(data=False, node=node)
close_value = MockValue(data=False, node=node)
values = MockEntityValues(primary=value, open=open_value,
close=close_value, node=node)
device = zwave.get_device(node=node, values=values, node_config={})
device = zwave.get_device(
node=node,
values=values,
node_config={zwave.zwave.CONF_INVERT_OPENCLOSE_BUTTONS: True})

device.open_cover()
assert mock_network.manager.pressButton.called
Expand Down