mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Add unique id to ADS platforms (#20511)
* Add friendly_name option * Correct hound findings * correct hound findings 2 * add unique id * add unique id to all ads platforms
This commit is contained in:
parent
d89c56829c
commit
d1c8d39107
@ -44,6 +44,7 @@ class AdsBinarySensor(BinarySensorDevice):
|
|||||||
def __init__(self, ads_hub, name, ads_var, device_class):
|
def __init__(self, ads_hub, name, ads_var, device_class):
|
||||||
"""Initialize ADS binary sensor."""
|
"""Initialize ADS binary sensor."""
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._unique_id = ads_var
|
||||||
self._state = False
|
self._state = False
|
||||||
self._device_class = device_class or 'moving'
|
self._device_class = device_class or 'moving'
|
||||||
self._ads_hub = ads_hub
|
self._ads_hub = ads_hub
|
||||||
@ -66,6 +67,11 @@ class AdsBinarySensor(BinarySensorDevice):
|
|||||||
"""Return the default name of the binary sensor."""
|
"""Return the default name of the binary sensor."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return an unique identifier for this entity."""
|
||||||
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the device class."""
|
"""Return the device class."""
|
||||||
|
@ -46,6 +46,7 @@ class AdsLight(Light):
|
|||||||
self._on_state = False
|
self._on_state = False
|
||||||
self._brightness = None
|
self._brightness = None
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._unique_id = ads_var_enable
|
||||||
self.ads_var_enable = ads_var_enable
|
self.ads_var_enable = ads_var_enable
|
||||||
self.ads_var_brightness = ads_var_brightness
|
self.ads_var_brightness = ads_var_brightness
|
||||||
|
|
||||||
@ -79,6 +80,11 @@ class AdsLight(Light):
|
|||||||
"""Return the name of the device if any."""
|
"""Return the name of the device if any."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return an unique identifier for this entity."""
|
||||||
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
"""Return the brightness of the light (0..255)."""
|
"""Return the brightness of the light (0..255)."""
|
||||||
|
@ -55,6 +55,7 @@ class AdsSensor(Entity):
|
|||||||
"""Initialize AdsSensor entity."""
|
"""Initialize AdsSensor entity."""
|
||||||
self._ads_hub = ads_hub
|
self._ads_hub = ads_hub
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._unique_id = ads_var
|
||||||
self._value = None
|
self._value = None
|
||||||
self._unit_of_measurement = unit_of_measurement
|
self._unit_of_measurement = unit_of_measurement
|
||||||
self.ads_var = ads_var
|
self.ads_var = ads_var
|
||||||
@ -84,6 +85,11 @@ class AdsSensor(Entity):
|
|||||||
"""Return the name of the entity."""
|
"""Return the name of the entity."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return an unique identifier for this entity."""
|
||||||
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
|
@ -44,6 +44,7 @@ class AdsSwitch(ToggleEntity):
|
|||||||
self._ads_hub = ads_hub
|
self._ads_hub = ads_hub
|
||||||
self._on_state = False
|
self._on_state = False
|
||||||
self._name = name
|
self._name = name
|
||||||
|
self._unique_id = ads_var
|
||||||
self.ads_var = ads_var
|
self.ads_var = ads_var
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
@ -68,6 +69,11 @@ class AdsSwitch(ToggleEntity):
|
|||||||
"""Return the name of the entity."""
|
"""Return the name of the entity."""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def unique_id(self):
|
||||||
|
"""Return an unique identifier for this entity."""
|
||||||
|
return self._unique_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
"""Return False because entity pushes its state to HA."""
|
"""Return False because entity pushes its state to HA."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user