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
This commit is contained in:
Lukas 2016-10-14 06:13:05 +02:00 committed by Paulus Schoutsen
parent 7771cc2ccf
commit 1373db8b60
2 changed files with 2 additions and 27 deletions

View File

@ -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)])

View File

@ -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: