def test_get_device_component_mapping_mti(): """Test that component is returned.""" # GE Fan controller node = MockNode(manufacturer_id='0063', product_type='4944', product_id='3034') value = MockValue(data=0, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL) assert workaround.get_device_component_mapping(value) == 'fan' # GE Dimmer node = MockNode(manufacturer_id='0063', product_type='4944', product_id='3031') value = MockValue(data=0, node=node, command_class=const.COMMAND_CLASS_SWITCH_MULTILEVEL) assert workaround.get_device_component_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 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_component_mapping(): """Test that component is returned.""" node = MockNode(manufacturer_id="010f", product_type="0b00") value = MockValue(data=0, node=node, command_class=const.COMMAND_CLASS_SENSOR_ALARM) assert workaround.get_device_component_mapping(value) == "binary_sensor"
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 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_no_component_mapping(): """Test that None is returned.""" node = MockNode(manufacturer_id=' ') value = MockValue(data=0, node=node) assert workaround.get_device_component_mapping(value) is None
def test_get_device_component_mapping(): """Test that component is returned.""" node = MockNode(manufacturer_id='010f', product_type='0b00') value = MockValue(data=0, node=node, command_class=const.COMMAND_CLASS_SENSOR_ALARM) assert workaround.get_device_component_mapping(value) == 'binary_sensor'
def test_get_device_no_component_mapping(): """Test that None is returned.""" node = MockNode(manufacturer_id=" ") value = MockValue(data=0, node=node) assert workaround.get_device_component_mapping(value) is None