mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use basic entity attributes in fibaro integration (#64784)
* use basic entity attributes in fibaro integration * use fibaro_device without self in constructor
This commit is contained in:
parent
2f0059fa8b
commit
09408234a6
@ -399,8 +399,9 @@ class FibaroDevice(Entity):
|
|||||||
"""Initialize the device."""
|
"""Initialize the device."""
|
||||||
self.fibaro_device = fibaro_device
|
self.fibaro_device = fibaro_device
|
||||||
self.controller = fibaro_device.fibaro_controller
|
self.controller = fibaro_device.fibaro_controller
|
||||||
self._name = fibaro_device.friendly_name
|
|
||||||
self.ha_id = fibaro_device.ha_id
|
self.ha_id = fibaro_device.ha_id
|
||||||
|
self._attr_name = fibaro_device.friendly_name
|
||||||
|
self._attr_unique_id = fibaro_device.unique_id_str
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Call when entity is added to hass."""
|
"""Call when entity is added to hass."""
|
||||||
@ -493,16 +494,6 @@ class FibaroDevice(Entity):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return a unique ID."""
|
|
||||||
return self.fibaro_device.unique_id_str
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str | None:
|
|
||||||
"""Return the name of the device."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
"""Get polling requirement from fibaro device."""
|
"""Get polling requirement from fibaro device."""
|
||||||
|
@ -140,12 +140,8 @@ class FibaroEnergySensor(FibaroDevice, SensorEntity):
|
|||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
super().__init__(fibaro_device)
|
super().__init__(fibaro_device)
|
||||||
self.entity_id = f"{DOMAIN}.{self.ha_id}_energy"
|
self.entity_id = f"{DOMAIN}.{self.ha_id}_energy"
|
||||||
self._name = f"{fibaro_device.friendly_name} Energy"
|
self._attr_name = f"{fibaro_device.friendly_name} Energy"
|
||||||
|
self._attr_unique_id = f"{fibaro_device.unique_id_str}_energy"
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return a unique ID."""
|
|
||||||
return f"{self.fibaro_device.unique_id_str}_energy"
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the state."""
|
"""Update the state."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user