From 1373db8b60f310f684affaf8066f01aa4a3f3a14 Mon Sep 17 00:00:00 2001 From: Lukas Date: Fri, 14 Oct 2016 06:13:05 +0200 Subject: [PATCH] Include index and instance in object_id of zwave devices (#3759) * Include index and instance in object_id of zwave devices * Add the instance id if there is more than one instance for the value --- homeassistant/components/sensor/zwave.py | 26 ---------------------- homeassistant/components/zwave/__init__.py | 3 ++- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/homeassistant/components/sensor/zwave.py b/homeassistant/components/sensor/zwave.py index 4f474dbe73f..3a70e0d521f 100644 --- a/homeassistant/components/sensor/zwave.py +++ b/homeassistant/components/sensor/zwave.py @@ -12,20 +12,6 @@ from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.helpers.entity import Entity -FIBARO = 0x010f -FIBARO_WALL_PLUG = 0x1000 -FIBARO_WALL_PLUG_SENSOR_METER = (FIBARO, FIBARO_WALL_PLUG, 8) - -WORKAROUND_IGNORE = 'ignore' - -DEVICE_MAPPINGS = { - # For some reason Fibaro Wall Plug reports 2 power consumptions. - # One value updates as the power consumption changes - # and the other does not change. - FIBARO_WALL_PLUG_SENSOR_METER: WORKAROUND_IGNORE, -} - - def setup_platform(hass, config, add_devices, discovery_info=None): """Setup Z-Wave sensors.""" # Return on empty `discovery_info`. Given you configure HA with: @@ -46,18 +32,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None): # groups[1].associations): # node.groups[1].add_association(NETWORK.controller.node_id) - # 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 - # Generic Device mappings if node.has_command_class(zwave.const.COMMAND_CLASS_SENSOR_MULTILEVEL): add_devices([ZWaveMultilevelSensor(value)]) diff --git a/homeassistant/components/zwave/__init__.py b/homeassistant/components/zwave/__init__.py index 32d4f42c1a1..deec40062ab 100644 --- a/homeassistant/components/zwave/__init__.py +++ b/homeassistant/components/zwave/__init__.py @@ -181,7 +181,8 @@ def _object_id(value): The object_id contains node_id and value instance id to not collide with other entity_ids. """ - object_id = "{}_{}".format(slugify(_value_name(value)), value.node.node_id) + object_id = "{}_{}_{}".format(slugify(_value_name(value)), + value.node.node_id, value.index) # Add the instance id if there is more than one instance for the value if value.instance > 1: