Use entity class attributes for airvisual (#52503)

* Use entity class attributes for airvisual

* fix

* rework

* tweaks

* finish

* remove overriden available attribute

* rework
This commit is contained in:
Robert Hillis 2021-07-21 08:07:26 -04:00 committed by GitHub
parent 462db1b4b2
commit 7fef87691a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -266,9 +266,12 @@ class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
self._attr_device_class = device_class
self._attr_icon = icon
self._attr_name = (
f"{coordinator.data['settings']['node_name']} Node/Pro: {name}"
)
self._attr_unique_id = f"{coordinator.data['serial_number']}_{kind}"
self._attr_unit_of_measurement = unit
self._kind = kind
self._name = name
@property
def device_info(self):
@ -284,17 +287,6 @@ class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
),
}
@property
def name(self):
"""Return the name."""
node_name = self.coordinator.data["settings"]["node_name"]
return f"{node_name} Node/Pro: {self._name}"
@property
def unique_id(self):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return f"{self.coordinator.data['serial_number']}_{self._kind}"
@callback
def update_from_latest_data(self):
"""Update the entity from the latest data."""