diff --git a/homeassistant/components/cover/zwave.py b/homeassistant/components/cover/zwave.py index 129dbd32ffe..3f26da183b5 100644 --- a/homeassistant/components/cover/zwave.py +++ b/homeassistant/components/cover/zwave.py @@ -20,12 +20,13 @@ _LOGGER = logging.getLogger(__name__) 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]): @@ -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: @@ -56,10 +58,9 @@ class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice): 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 diff --git a/homeassistant/components/zwave/__init__.py b/homeassistant/components/zwave/__init__.py index 83fa38862c3..4eea502d40a 100755 --- a/homeassistant/components/zwave/__init__.py +++ b/homeassistant/components/zwave/__init__.py @@ -45,6 +45,7 @@ CONF_POLLING_INTERVAL = 'polling_interval' 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' @@ -58,6 +59,7 @@ DEFAULT_CONF_USB_STICK_PATH = '/zwaveusbstick' 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 @@ -105,6 +107,8 @@ SET_WAKEUP_SCHEMA = vol.Schema({ 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): diff --git a/homeassistant/components/zwave/workaround.py b/homeassistant/components/zwave/workaround.py index 17dbf1437f3..27e98457a2d 100644 --- a/homeassistant/components/zwave/workaround.py +++ b/homeassistant/components/zwave/workaround.py @@ -30,7 +30,6 @@ WENZHOU_SLIM_SENSOR_MOTION_MTII = ( # 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' @@ -43,12 +42,10 @@ DEVICE_MAPPINGS_MTII = { } 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, } diff --git a/tests/components/cover/test_zwave.py b/tests/components/cover/test_zwave.py index 1b4ce015987..425331ff35c 100644 --- a/tests/components/cover/test_zwave.py +++ b/tests/components/cover/test_zwave.py @@ -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