From c586111c8c112d197ce9064708c2ae6f2ae9a248 Mon Sep 17 00:00:00 2001 From: Stefan Jonasson Date: Mon, 29 Feb 2016 11:05:11 +0100 Subject: [PATCH] Fixed the z-wave sensor workarounds for empty manufacturer ids --- .../components/binary_sensor/zwave.py | 32 +++++++++++-------- homeassistant/components/sensor/zwave.py | 19 ++++++----- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/binary_sensor/zwave.py b/homeassistant/components/binary_sensor/zwave.py index bd3ff69e8cf..683dbe117b5 100644 --- a/homeassistant/components/binary_sensor/zwave.py +++ b/homeassistant/components/binary_sensor/zwave.py @@ -39,22 +39,26 @@ def setup_platform(hass, config, add_devices, discovery_info=None): 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: + # 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 = (get_config_value(value.node, 9) or 4) + add_devices([ + ZWaveTriggerSensor(value, "motion", + hass, re_arm_multiplier * 8) + ]) + return + + if value.command_class == COMMAND_CLASS_SENSOR_BINARY: add_devices([ZWaveBinarySensor(value, None)]) diff --git a/homeassistant/components/sensor/zwave.py b/homeassistant/components/sensor/zwave.py index 066ada12546..a441676c6f2 100644 --- a/homeassistant/components/sensor/zwave.py +++ b/homeassistant/components/sensor/zwave.py @@ -50,17 +50,20 @@ def setup_platform(hass, config, add_devices, discovery_info=None): # groups[1].associations): # node.groups[1].add_association(NETWORK.controller.node_id) - specific_sensor_key = (int(value.node.manufacturer_id, 16), - int(value.node.product_id, 16), - value.index) + # 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) - # Check workaround mappings for specific devices. - if specific_sensor_key in DEVICE_MAPPINGS: - if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_IGNORE: - return + # Check workaround mappings for specific devices. + if specific_sensor_key in DEVICE_MAPPINGS: + if DEVICE_MAPPINGS[specific_sensor_key] == WORKAROUND_IGNORE: + return # Generic Device mappings - elif value.command_class == COMMAND_CLASS_SENSOR_MULTILEVEL: + if value.command_class == COMMAND_CLASS_SENSOR_MULTILEVEL: add_devices([ZWaveMultilevelSensor(value)]) elif (value.command_class == COMMAND_CLASS_METER and