mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 10:47:10 +00:00
Use entity class attributes for aurora (#52690)
* Use entity class attributes for aurora * fix
This commit is contained in:
parent
293690e3d8
commit
922ef3f2f3
@ -123,6 +123,8 @@ class AuroraDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
class AuroraEntity(CoordinatorEntity):
|
class AuroraEntity(CoordinatorEntity):
|
||||||
"""Implementation of the base Aurora Entity."""
|
"""Implementation of the base Aurora Entity."""
|
||||||
|
|
||||||
|
_attr_extra_state_attributes = {"attribution": ATTRIBUTION}
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: AuroraDataUpdateCoordinator,
|
coordinator: AuroraDataUpdateCoordinator,
|
||||||
@ -133,35 +135,15 @@ class AuroraEntity(CoordinatorEntity):
|
|||||||
|
|
||||||
super().__init__(coordinator=coordinator)
|
super().__init__(coordinator=coordinator)
|
||||||
|
|
||||||
self._name = name
|
self._attr_name = name
|
||||||
self._unique_id = f"{self.coordinator.latitude}_{self.coordinator.longitude}"
|
self._attr_unique_id = f"{coordinator.latitude}_{coordinator.longitude}"
|
||||||
self._icon = icon
|
self._attr_icon = icon
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
"""Define the unique id based on the latitude and longitude."""
|
|
||||||
return self._unique_id
|
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of the sensor."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
|
||||||
def extra_state_attributes(self):
|
|
||||||
"""Return the state attributes."""
|
|
||||||
return {"attribution": ATTRIBUTION}
|
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self):
|
|
||||||
"""Return the icon for the sensor."""
|
|
||||||
return self._icon
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
"""Define the device based on name."""
|
"""Define the device based on name."""
|
||||||
return {
|
return {
|
||||||
ATTR_IDENTIFIERS: {(DOMAIN, self._unique_id)},
|
ATTR_IDENTIFIERS: {(DOMAIN, self.unique_id)},
|
||||||
ATTR_NAME: self.coordinator.name,
|
ATTR_NAME: self.coordinator.name,
|
||||||
ATTR_MANUFACTURER: "NOAA",
|
ATTR_MANUFACTURER: "NOAA",
|
||||||
ATTR_MODEL: "Aurora Visibility Sensor",
|
ATTR_MODEL: "Aurora Visibility Sensor",
|
||||||
|
@ -22,12 +22,9 @@ async def async_setup_entry(hass, entry, async_add_entries):
|
|||||||
class AuroraSensor(AuroraEntity, SensorEntity):
|
class AuroraSensor(AuroraEntity, SensorEntity):
|
||||||
"""Implementation of an aurora sensor."""
|
"""Implementation of an aurora sensor."""
|
||||||
|
|
||||||
|
_attr_unit_of_measurement = PERCENTAGE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return % chance the aurora is visible."""
|
"""Return % chance the aurora is visible."""
|
||||||
return self.coordinator.data
|
return self.coordinator.data
|
||||||
|
|
||||||
@property
|
|
||||||
def unit_of_measurement(self):
|
|
||||||
"""Return the unit of measure."""
|
|
||||||
return PERCENTAGE
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user