def test_get_device_mapping_mti_instance(): """Test that device mapping mti_instance is returned.""" node = MockNode(manufacturer_id='013c', product_type='0001', product_id='0005') value = MockValue(data=0, node=node, instance=1) assert workaround.get_device_mapping(value) == 'refresh_node_on_update' value = MockValue(data=0, node=node, instance=2) assert workaround.get_device_mapping(value) is None
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Z-Wave platform for binary sensors.""" if discovery_info is None or zwave.NETWORK is None: return node = zwave.NETWORK.nodes[discovery_info[zwave.const.ATTR_NODE_ID]] value = node.values[discovery_info[zwave.const.ATTR_VALUE_ID]] value.set_change_verified(False) device_mapping = workaround.get_device_mapping(value) if device_mapping == workaround.WORKAROUND_NO_OFF_EVENT: # Default the multiplier to 4 re_arm_multiplier = (zwave.get_config_value(value.node, 9) or 4) add_devices([ ZWaveTriggerSensor(value, "motion", hass, re_arm_multiplier * 8) ]) return if workaround.get_device_component_mapping(value) == DOMAIN: add_devices([ZWaveBinarySensor(value, None)]) return if value.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY: add_devices([ZWaveBinarySensor(value, None)])
def test_get_device_mapping_mtii(): """Test that device mapping mtii is returned.""" node = MockNode(manufacturer_id="013c", product_type="0002", product_id="0002") value = MockValue(data=0, node=node, index=0) assert workaround.get_device_mapping(value) == "trigger_no_off_event"
def __init__(self, values): """Initialize the Z-Wave switch device.""" zwave.ZWaveDeviceEntity.__init__(self, values, DOMAIN) self.refresh_on_update = (workaround.get_device_mapping( values.primary) == workaround.WORKAROUND_REFRESH_NODE_ON_UPDATE) self.last_update = time.perf_counter() self._state = self.values.primary.data
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Z-Wave platform for binary sensors.""" if discovery_info is None or zwave.NETWORK is None: return node = zwave.NETWORK.nodes[discovery_info[zwave.const.ATTR_NODE_ID]] value = node.values[discovery_info[zwave.const.ATTR_VALUE_ID]] value.set_change_verified(False) device_mapping = workaround.get_device_mapping(value) if device_mapping == workaround.WORKAROUND_NO_OFF_EVENT: # Default the multiplier to 4 re_arm_multiplier = (zwave.get_config_value(value.node, 9) or 4) add_devices([ ZWaveTriggerSensor(value, "motion", hass, re_arm_multiplier * 8) ]) return if workaround.get_device_component_mapping(value) == DOMAIN: add_devices([ZWaveBinarySensor(value, None)]) return if value.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY: add_devices([ZWaveBinarySensor(value, None)])
def __init__(self, value): """Initialize the Z-Wave switch device.""" zwave.ZWaveDeviceEntity.__init__(self, value, DOMAIN) self.refresh_on_update = (workaround.get_device_mapping(value) == workaround.WORKAROUND_REFRESH_NODE_ON_UPDATE) self.last_update = time.perf_counter() self._state = self._value.data
def get_device(values, **kwargs): """Create Z-Wave entity device.""" device_mapping = workaround.get_device_mapping(values.primary) if device_mapping == workaround.WORKAROUND_NO_OFF_EVENT: return ZWaveTriggerSensor(values, "motion") if workaround.get_device_component_mapping(values.primary) == DOMAIN: return ZWaveBinarySensor(values, None) if values.primary.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY: return ZWaveBinarySensor(values, None) return None
def get_device(values, **kwargs): """Create Z-Wave entity device.""" device_mapping = workaround.get_device_mapping(values.primary) if device_mapping == workaround.WORKAROUND_NO_OFF_EVENT: return ZWaveTriggerSensor(values, "motion") if workaround.get_device_component_mapping(values.primary) == DOMAIN: return ZWaveBinarySensor(values, None) if values.primary.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY: return ZWaveBinarySensor(values, None) return None
def __init__(self, values): """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._workaround = workaround.get_device_mapping(values.primary) if self._workaround: _LOGGER.debug("Using workaround %s", self._workaround) self.update_properties()
def __init__(self, values): """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._workaround = workaround.get_device_mapping(values.primary) if self._workaround: _LOGGER.debug("Using workaround %s", self._workaround) self.update_properties()
def __init__(self, hass, values, invert_buttons): """Initialize the Z-Wave rollershutter.""" ZWaveDeviceEntity.__init__(self, values, DOMAIN) self._network = hass.data[zwave.const.DATA_NETWORK] 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: _LOGGER.debug("Using workaround %s", self._workaround) self.update_properties()
def __init__(self, hass, values, invert_buttons): """Initialize the Z-Wave rollershutter.""" ZWaveDeviceEntity.__init__(self, values, DOMAIN) self._network = hass.data[zwave.const.DATA_NETWORK] 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: _LOGGER.debug("Using workaround %s", self._workaround) self.update_properties()
def get_device(values, **kwargs): """Create zwave entity device.""" device_mapping = workaround.get_device_mapping(values.primary) if device_mapping == workaround.WORKAROUND_NO_OFF_EVENT: # Default the multiplier to 4 re_arm_multiplier = zwave.get_config_value(values.primary.node, 9) or 4 return ZWaveTriggerSensor(values, "motion", re_arm_multiplier * 8) if workaround.get_device_component_mapping(values.primary) == DOMAIN: return ZWaveBinarySensor(values, None) if values.primary.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY: return ZWaveBinarySensor(values, None) return None
def get_device(values, **kwargs): """Create zwave entity device.""" device_mapping = workaround.get_device_mapping(values.primary) if device_mapping == workaround.WORKAROUND_NO_OFF_EVENT: # Default the multiplier to 4 re_arm_multiplier = zwave.get_config_value(values.primary.node, 9) or 4 return ZWaveTriggerSensor(values, "motion", re_arm_multiplier * 8) if workaround.get_device_component_mapping(values.primary) == DOMAIN: return ZWaveBinarySensor(values, None) if values.primary.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY: return ZWaveBinarySensor(values, None) return None
def test_get_device_mapping_mtii(): """Test that device mapping mtii is returned.""" node = MockNode(manufacturer_id='013c', product_type='0002', product_id='0002') value = MockValue(data=0, node=node, index=0) assert workaround.get_device_mapping(value) == 'trigger_no_off_event'
def test_get_device_mapping_mt(): """Test that device mapping mt is returned.""" node = MockNode(manufacturer_id='0047', product_type='5a52') value = MockValue(data=0, node=node) assert workaround.get_device_mapping(value) == 'workaround_no_position'
def test_get_device_no_mapping(): """Test that no device mapping is returned.""" node = MockNode(manufacturer_id=' ') value = MockValue(data=0, node=node) assert workaround.get_device_mapping(value) is None
def test_get_device_no_mapping(): """Test that no device mapping is returned.""" node = MockNode(manufacturer_id=" ") value = MockValue(data=0, node=node) assert workaround.get_device_mapping(value) is None
def test_get_device_mapping_mt(): """Test that device mapping mt is returned.""" node = MockNode(manufacturer_id="0047", product_type="5a52") value = MockValue(data=0, node=node) assert workaround.get_device_mapping(value) == "workaround_no_position"