mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Updated teh entity_id generation
Entity ids will now look like this: sensor.philio_technology_corporation_psm021_slim_multisensor_doorwindow_sensor_7 sensor.philio_technology_corporation_psm021_slim_multisensor_luminance_7 sensor.philio_technology_corporation_psm021_slim_multisensor_motion_sensor_7 sensor.philio_technology_corporation_psm021_slim_multisensor_tamper_sensor_7 sensor.philio_technology_corporation_psm021_slim_multisensor_temperature_7 sensor.philio_technology_corporation_psm021_slim_multisensor_doorwindow_sensor_8 sensor.philio_technology_corporation_psm021_slim_multisensor_luminance_8 sensor.philio_technology_corporation_psm021_slim_multisensor_motion_sensor_8 sensor.philio_technology_corporation_psm021_slim_multisensor_tamper_sensor_8 sensor.philio_technology_corporation_psm021_slim_multisensor_temperature_8 And if there is several values of the same type in a node the instance id will be appended like this (three switches in the same device): switch.fibaro_system_unknown_type0202_id1002_switch_9 switch.fibaro_system_unknown_type0202_id1002_switch_9_2 switch.fibaro_system_unknown_type0202_id1002_switch_9_3
This commit is contained in:
parent
c10a86d1bf
commit
f4c9540a1b
@ -12,6 +12,7 @@ from threading import Timer
|
|||||||
|
|
||||||
from homeassistant.const import STATE_ON, STATE_OFF
|
from homeassistant.const import STATE_ON, STATE_OFF
|
||||||
from homeassistant.components.light import (Light, ATTR_BRIGHTNESS)
|
from homeassistant.components.light import (Light, ATTR_BRIGHTNESS)
|
||||||
|
from homeassistant.util import slugify
|
||||||
import homeassistant.components.zwave as zwave
|
import homeassistant.components.zwave as zwave
|
||||||
|
|
||||||
|
|
||||||
@ -92,11 +93,32 @@ class ZwaveDimmer(Light):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def unique_id(self):
|
||||||
""" Returns the name of the device if any. """
|
""" Returns a unique id. """
|
||||||
name = self._node.name or "{}".format(self._node.product_name)
|
return "ZWAVE-{}-{}".format(self._node.node_id, self._value.object_id)
|
||||||
|
|
||||||
return "{}".format(name or self._value.label)
|
@property
|
||||||
|
def name(self):
|
||||||
|
""" Returns the name of the device. """
|
||||||
|
name = self._node.name or "{} {}".format(
|
||||||
|
self._node.manufacturer_name, self._node.product_name)
|
||||||
|
|
||||||
|
return "{} {}".format(name, self._value.label)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_id(self):
|
||||||
|
""" Returns the entity_id of the device if any.
|
||||||
|
The entity_id contains node_id and value instance id
|
||||||
|
to not collide with other entity_ids"""
|
||||||
|
|
||||||
|
entity_id = "light.{}_{}".format(slugify(self.name),
|
||||||
|
self._node.node_id)
|
||||||
|
|
||||||
|
# Add the instance id if there is more than one instance for the value
|
||||||
|
if self._value.instance > 1:
|
||||||
|
return "{}_{}".format(entity_id, self._value.instance)
|
||||||
|
|
||||||
|
return entity_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
|
@ -14,6 +14,7 @@ from homeassistant.helpers.event import track_point_in_time
|
|||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
import homeassistant.components.zwave as zwave
|
import homeassistant.components.zwave as zwave
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.util import slugify
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_BATTERY_LEVEL, STATE_ON, STATE_OFF,
|
ATTR_BATTERY_LEVEL, STATE_ON, STATE_OFF,
|
||||||
TEMP_CELCIUS, TEMP_FAHRENHEIT, ATTR_LOCATION)
|
TEMP_CELCIUS, TEMP_FAHRENHEIT, ATTR_LOCATION)
|
||||||
@ -109,6 +110,21 @@ class ZWaveSensor(Entity):
|
|||||||
|
|
||||||
return "{} {}".format(name, self._value.label)
|
return "{} {}".format(name, self._value.label)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_id(self):
|
||||||
|
""" Returns the entity_id of the device if any.
|
||||||
|
The entity_id contains node_id and value instance id
|
||||||
|
to not collide with other entity_ids"""
|
||||||
|
|
||||||
|
entity_id = "sensor.{}_{}".format(slugify(self.name),
|
||||||
|
self._node.node_id)
|
||||||
|
|
||||||
|
# Add the instance id if there is more than one instance for the value
|
||||||
|
if self._value.instance > 1:
|
||||||
|
return "{}_{}".format(entity_id, self._value.instance)
|
||||||
|
|
||||||
|
return entity_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
""" Returns the state of the sensor. """
|
""" Returns the state of the sensor. """
|
||||||
|
@ -9,6 +9,7 @@ Zwave platform that handles simple binary switches.
|
|||||||
import homeassistant.components.zwave as zwave
|
import homeassistant.components.zwave as zwave
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
|
from homeassistant.util import slugify
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
@ -56,11 +57,32 @@ class ZwaveSwitch(SwitchDevice):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def unique_id(self):
|
||||||
""" Returns the name of the device if any. """
|
""" Returns a unique id. """
|
||||||
name = self._node.name or "{}".format(self._node.product_name)
|
return "ZWAVE-{}-{}".format(self._node.node_id, self._value.object_id)
|
||||||
|
|
||||||
return "{}".format(name or self._value.label)
|
@property
|
||||||
|
def name(self):
|
||||||
|
""" Returns the name of the device. """
|
||||||
|
name = self._node.name or "{} {}".format(
|
||||||
|
self._node.manufacturer_name, self._node.product_name)
|
||||||
|
|
||||||
|
return "{} {}".format(name, self._value.label)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def entity_id(self):
|
||||||
|
""" Returns the entity_id of the device if any.
|
||||||
|
The entity_id contains node_id and value instance id
|
||||||
|
to not collide with other entity_ids"""
|
||||||
|
|
||||||
|
entity_id = "switch.{}_{}".format(slugify(self.name),
|
||||||
|
self._node.node_id)
|
||||||
|
|
||||||
|
# Add the instance id if there is more than one instance for the value
|
||||||
|
if self._value.instance > 1:
|
||||||
|
return "{}_{}".format(entity_id, self._value.instance)
|
||||||
|
|
||||||
|
return entity_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user