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
2 changed files with 4 additions and 17 deletions
|
@ -399,8 +399,9 @@ class FibaroDevice(Entity):
|
|||
"""Initialize the device."""
|
||||
self.fibaro_device = fibaro_device
|
||||
self.controller = fibaro_device.fibaro_controller
|
||||
self._name = fibaro_device.friendly_name
|
||||
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):
|
||||
"""Call when entity is added to hass."""
|
||||
|
@ -493,16 +494,6 @@ class FibaroDevice(Entity):
|
|||
return True
|
||||
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
|
||||
def should_poll(self):
|
||||
"""Get polling requirement from fibaro device."""
|
||||
|
|
|
@ -140,12 +140,8 @@ class FibaroEnergySensor(FibaroDevice, SensorEntity):
|
|||
"""Initialize the sensor."""
|
||||
super().__init__(fibaro_device)
|
||||
self.entity_id = f"{DOMAIN}.{self.ha_id}_energy"
|
||||
self._name = f"{fibaro_device.friendly_name} Energy"
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return a unique ID."""
|
||||
return f"{self.fibaro_device.unique_id_str}_energy"
|
||||
self._attr_name = f"{fibaro_device.friendly_name} Energy"
|
||||
self._attr_unique_id = f"{fibaro_device.unique_id_str}_energy"
|
||||
|
||||
def update(self):
|
||||
"""Update the state."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue