Entity registry (#11979)
* Entity#unique_id defaults to None * Initial commit entity registry * Clean up unique_id property * Lint * Add tests to entity component * Lint * Restore some unique ids * Spelling * Remove use of IP address for unique ID * Add tests * Add tests * Fix tests * Add some docs * Add one more test * Fix new test…
This commit is contained in:
parent
8e441ba03b
commit
e51427b284
47 changed files with 471 additions and 230 deletions
|
@ -61,11 +61,6 @@ class BlinkSensor(Entity):
|
|||
"""Return the camera's current state."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique camera sensor identifier."""
|
||||
return "sensor_{}_{}".format(self._name, self.index)
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement."""
|
||||
|
|
|
@ -64,7 +64,6 @@ class BloomSkySensor(Entity):
|
|||
self._device_id = device['DeviceID']
|
||||
self._sensor_name = sensor_name
|
||||
self._name = '{} {}'.format(device['DeviceName'], sensor_name)
|
||||
self._unique_id = 'bloomsky_sensor {}'.format(self._name)
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
|
@ -72,11 +71,6 @@ class BloomSkySensor(Entity):
|
|||
"""Return the name of the BloomSky device and this sensor."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID for this sensor."""
|
||||
return self._unique_id
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the current state, eg. value, of this sensor."""
|
||||
|
|
|
@ -70,8 +70,7 @@ class CanarySensor(Entity):
|
|||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID of this sensor."""
|
||||
return "sensor_canary_{}_{}".format(self._device_id,
|
||||
self._sensor_type[0])
|
||||
return "{}_{}".format(self._device_id, self._sensor_type[0])
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
|
|
@ -95,11 +95,6 @@ class DaikinClimateSensor(Entity):
|
|||
|
||||
return value
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the ID of this AC."""
|
||||
return "{}.{}".format(self.__class__, self._api.ip_address)
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend, if any."""
|
||||
|
|
|
@ -50,18 +50,13 @@ class EcobeeSensor(Entity):
|
|||
@property
|
||||
def name(self):
|
||||
"""Return the name of the Ecobee sensor."""
|
||||
return self._name.rstrip()
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the sensor."""
|
||||
return self._state
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique ID of this sensor."""
|
||||
return "sensor_ecobee_{}_{}".format(self._name, self.index)
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit of measurement this sensor expresses itself in."""
|
||||
|
|
|
@ -58,7 +58,7 @@ class IOSSensor(Entity):
|
|||
def unique_id(self):
|
||||
"""Return the unique ID of this sensor."""
|
||||
device_id = self._device[ios.ATTR_DEVICE_ID]
|
||||
return "sensor_ios_battery_{}_{}".format(self.type, device_id)
|
||||
return "{}_{}".format(self.type, device_id)
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
|
|
@ -317,11 +317,6 @@ class ISYWeatherDevice(ISYDevice):
|
|||
"""Initialize the ISY994 weather device."""
|
||||
super().__init__(node)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return the unique identifier for the node."""
|
||||
return self._node.name
|
||||
|
||||
@property
|
||||
def raw_units(self) -> str:
|
||||
"""Return the raw unit of measurement."""
|
||||
|
|
|
@ -113,8 +113,7 @@ class NetAtmoSensor(Entity):
|
|||
module_id = self.netatmo_data.\
|
||||
station_data.moduleByName(module=module_name)['_id']
|
||||
self.module_id = module_id[1]
|
||||
self._unique_id = "Netatmo Sensor {0} - {1} ({2})".format(
|
||||
self._name, module_id, self.type)
|
||||
self._unique_id = '{}-{}'.format(self.module_id, self.type)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue