예제 #1
0
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)

    # 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), value.index)

        if specific_sensor_key in DEVICE_MAPPINGS:
            if DEVICE_MAPPINGS[specific_sensor_key] == 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 value.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY:
        add_devices([ZWaveBinarySensor(value, None)])
예제 #2
0
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)])
예제 #3
0
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)

    # 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),
                               value.index)

        if specific_sensor_key in DEVICE_MAPPINGS:
            if DEVICE_MAPPINGS[specific_sensor_key] == 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 value.command_class == zwave.const.COMMAND_CLASS_SENSOR_BINARY:
        add_devices([ZWaveBinarySensor(value, None)])
예제 #4
0
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)])
예제 #5
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Z-Wave platform for sensors."""

    if discovery_info is None or NETWORK is None:
        return

    node = NETWORK.nodes[discovery_info[ATTR_NODE_ID]]
    value = node.values[discovery_info[ATTR_VALUE_ID]]

    specific_sensor_key = (int(value.node.manufacturer_id, 16),
                           int(value.node.product_id, 16),
                           value.index)

    value.set_change_verified(False)
    if specific_sensor_key in DEVICE_MAPPINGS:
        if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_NO_OFF_EVENT:
            # Default the multiplier to 4
            re_arm_multiplier = (get_config_value(value.node, 9) or 4)
            add_devices([
                ZWaveTriggerSensor(value, "motion",
                                   hass, re_arm_multiplier * 8)
            ])

    elif value.command_class == COMMAND_CLASS_SENSOR_BINARY:
        add_devices([ZWaveBinarySensor(value, None)])
예제 #6
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Z-Wave platform for sensors."""

    if discovery_info is None or NETWORK is None:
        return

    node = NETWORK.nodes[discovery_info[ATTR_NODE_ID]]
    value = node.values[discovery_info[ATTR_VALUE_ID]]

    specific_sensor_key = (int(value.node.manufacturer_id,
                               16), int(value.node.product_id,
                                        16), value.index)

    value.set_change_verified(False)
    if specific_sensor_key in DEVICE_MAPPINGS:
        if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_NO_OFF_EVENT:
            # Default the multiplier to 4
            re_arm_multiplier = (get_config_value(value.node, 9) or 4)
            add_devices([
                ZWaveTriggerSensor(value, "motion", hass,
                                   re_arm_multiplier * 8)
            ])

    elif value.command_class == COMMAND_CLASS_SENSOR_BINARY:
        add_devices([ZWaveBinarySensor(value, None)])
예제 #7
0
def test_config_access_error():
    """Test threading error accessing config values."""
    node = MagicMock()

    def side_effect():
        raise RuntimeError

    node.values.values.side_effect = side_effect
    result = zwave.get_config_value(node, 1)
    assert result is None
예제 #8
0
def test_config_access_error():
    """Test threading error accessing config values."""
    node = MagicMock()

    def side_effect():
        raise RuntimeError

    node.values.values.side_effect = side_effect
    result = zwave.get_config_value(node, 1)
    assert result is None
예제 #9
0
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
예제 #10
0
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
예제 #11
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """ Sets up Z-Wave sensors. """

    # Return on empty `discovery_info`. Given you configure HA with:
    #
    # sensor:
    #   platform: zwave
    #
    # `setup_platform` will be called without `discovery_info`.
    if discovery_info is None:
        return

    node = NETWORK.nodes[discovery_info[ATTR_NODE_ID]]
    value = node.values[discovery_info[ATTR_VALUE_ID]]

    value.set_change_verified(False)

    # if 1 in groups and (NETWORK.controller.node_id not in
    #                     groups[1].associations):
    #     node.groups[1].add_association(NETWORK.controller.node_id)

    specific_sensor_key = (value.node.manufacturer_id,
                           value.node.product_id,
                           value.index)

    # Check workaround mappings for specific devices
    if specific_sensor_key in DEVICE_MAPPINGS:
        if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_NO_OFF_EVENT:
            # Default the multiplier to 4
            re_arm_multiplier = (get_config_value(value.node, 9) or 4)
            add_devices([
                ZWaveTriggerSensor(value, hass, re_arm_multiplier * 8)
            ])
        elif DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_IGNORE:
            return

    # generic Device mappings
    elif value.command_class == COMMAND_CLASS_SENSOR_BINARY:
        add_devices([ZWaveBinarySensor(value)])

    elif value.command_class == COMMAND_CLASS_SENSOR_MULTILEVEL:
        add_devices([ZWaveMultilevelSensor(value)])

    elif (value.command_class == COMMAND_CLASS_METER and
          value.type == TYPE_DECIMAL):
        add_devices([ZWaveMultilevelSensor(value)])

    elif value.command_class == COMMAND_CLASS_ALARM:
        add_devices([ZWaveAlarmSensor(value)])
예제 #12
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """ Sets up Z-Wave sensors. """

    # Return on empty `discovery_info`. Given you configure HA with:
    #
    # sensor:
    #   platform: zwave
    #
    # `setup_platform` will be called without `discovery_info`.
    if discovery_info is None:
        return

    node = NETWORK.nodes[discovery_info[ATTR_NODE_ID]]
    value = node.values[discovery_info[ATTR_VALUE_ID]]

    value.set_change_verified(False)

    # if 1 in groups and (NETWORK.controller.node_id not in
    #                     groups[1].associations):
    #     node.groups[1].add_association(NETWORK.controller.node_id)

    specific_sensor_key = (value.node.manufacturer_id, value.node.product_id,
                           value.index)

    # Check workaround mappings for specific devices
    if specific_sensor_key in DEVICE_MAPPINGS:
        if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_NO_OFF_EVENT:
            # Default the multiplier to 4
            re_arm_multiplier = (get_config_value(value.node, 9) or 4)
            add_devices(
                [ZWaveTriggerSensor(value, hass, re_arm_multiplier * 8)])
        elif DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_IGNORE:
            return

    # generic Device mappings
    elif value.command_class == COMMAND_CLASS_SENSOR_BINARY:
        add_devices([ZWaveBinarySensor(value)])

    elif value.command_class == COMMAND_CLASS_SENSOR_MULTILEVEL:
        add_devices([ZWaveMultilevelSensor(value)])

    elif (value.command_class == COMMAND_CLASS_METER
          and value.type == TYPE_DECIMAL):
        add_devices([ZWaveMultilevelSensor(value)])

    elif value.command_class == COMMAND_CLASS_ALARM:
        add_devices([ZWaveAlarmSensor(value)])