From 09408234a6e07a0e6d6fb709f750dae9f9f69d65 Mon Sep 17 00:00:00 2001 From: rappenze Date: Sun, 23 Jan 2022 23:25:42 +0100 Subject: [PATCH] Use basic entity attributes in fibaro integration (#64784) * use basic entity attributes in fibaro integration * use fibaro_device without self in constructor --- homeassistant/components/fibaro/__init__.py | 13 ++----------- homeassistant/components/fibaro/sensor.py | 8 ++------ 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index 9d4b26fa118..cfe39201913 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -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.""" diff --git a/homeassistant/components/fibaro/sensor.py b/homeassistant/components/fibaro/sensor.py index 03959ea4e34..901552d0363 100644 --- a/homeassistant/components/fibaro/sensor.py +++ b/homeassistant/components/fibaro/sensor.py @@ -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."""