Small entity attribute cleanup in AirVisual (#51601)
* Small entity attribute cleanup in AirVisual * Fix icon in sensor update
This commit is contained in:
parent
a4587b5f3b
commit
4007430d72
3 changed files with 7 additions and 24 deletions
|
@ -337,24 +337,12 @@ class AirVisualEntity(CoordinatorEntity):
|
|||
"""Initialize."""
|
||||
super().__init__(coordinator)
|
||||
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
||||
self._icon = None
|
||||
self._unit = None
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self):
|
||||
"""Return the device state attributes."""
|
||||
return self._attrs
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon."""
|
||||
return self._icon
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit the value is expressed in."""
|
||||
return self._unit
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
"""Support for AirVisual Node/Pro units."""
|
||||
from homeassistant.components.air_quality import AirQualityEntity
|
||||
from homeassistant.const import CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||
from homeassistant.core import callback
|
||||
|
||||
from . import AirVisualEntity
|
||||
|
@ -34,8 +33,7 @@ class AirVisualNodeProSensor(AirVisualEntity, AirQualityEntity):
|
|||
"""Initialize."""
|
||||
super().__init__(airvisual)
|
||||
|
||||
self._icon = "mdi:chemical-weapon"
|
||||
self._unit = CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
||||
self._attr_icon = "mdi:chemical-weapon"
|
||||
|
||||
@property
|
||||
def air_quality_index(self):
|
||||
|
|
|
@ -154,12 +154,13 @@ class AirVisualGeographySensor(AirVisualEntity, SensorEntity):
|
|||
}
|
||||
)
|
||||
self._config_entry = config_entry
|
||||
self._icon = icon
|
||||
self._kind = kind
|
||||
self._locale = locale
|
||||
self._name = name
|
||||
self._state = None
|
||||
self._unit = unit
|
||||
|
||||
self._attr_icon = icon
|
||||
self._attr_unit_of_measurement = unit
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
|
@ -196,7 +197,7 @@ class AirVisualGeographySensor(AirVisualEntity, SensorEntity):
|
|||
|
||||
if self._kind == SENSOR_KIND_LEVEL:
|
||||
aqi = data[f"aqi{self._locale}"]
|
||||
self._state, self._icon = async_get_pollutant_level_info(aqi)
|
||||
self._state, self._attr_icon = async_get_pollutant_level_info(aqi)
|
||||
elif self._kind == SENSOR_KIND_AQI:
|
||||
self._state = data[f"aqi{self._locale}"]
|
||||
elif self._kind == SENSOR_KIND_POLLUTANT:
|
||||
|
@ -244,16 +245,12 @@ class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
|
|||
"""Initialize."""
|
||||
super().__init__(coordinator)
|
||||
|
||||
self._device_class = device_class
|
||||
self._kind = kind
|
||||
self._name = name
|
||||
self._state = None
|
||||
self._unit = unit
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class."""
|
||||
return self._device_class
|
||||
self._attr_device_class = device_class
|
||||
self._attr_unit_of_measurement = unit
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue