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."""
|
"""Initialize."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
|
||||||
self._icon = None
|
|
||||||
self._unit = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the device state attributes."""
|
"""Return the device state attributes."""
|
||||||
return self._attrs
|
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):
|
async def async_added_to_hass(self):
|
||||||
"""Register callbacks."""
|
"""Register callbacks."""
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
"""Support for AirVisual Node/Pro units."""
|
"""Support for AirVisual Node/Pro units."""
|
||||||
from homeassistant.components.air_quality import AirQualityEntity
|
from homeassistant.components.air_quality import AirQualityEntity
|
||||||
from homeassistant.const import CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
|
||||||
from . import AirVisualEntity
|
from . import AirVisualEntity
|
||||||
|
@ -34,8 +33,7 @@ class AirVisualNodeProSensor(AirVisualEntity, AirQualityEntity):
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(airvisual)
|
super().__init__(airvisual)
|
||||||
|
|
||||||
self._icon = "mdi:chemical-weapon"
|
self._attr_icon = "mdi:chemical-weapon"
|
||||||
self._unit = CONCENTRATION_MICROGRAMS_PER_CUBIC_METER
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def air_quality_index(self):
|
def air_quality_index(self):
|
||||||
|
|
|
@ -154,12 +154,13 @@ class AirVisualGeographySensor(AirVisualEntity, SensorEntity):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self._config_entry = config_entry
|
self._config_entry = config_entry
|
||||||
self._icon = icon
|
|
||||||
self._kind = kind
|
self._kind = kind
|
||||||
self._locale = locale
|
self._locale = locale
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = None
|
self._state = None
|
||||||
self._unit = unit
|
|
||||||
|
self._attr_icon = icon
|
||||||
|
self._attr_unit_of_measurement = unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self):
|
def available(self):
|
||||||
|
@ -196,7 +197,7 @@ class AirVisualGeographySensor(AirVisualEntity, SensorEntity):
|
||||||
|
|
||||||
if self._kind == SENSOR_KIND_LEVEL:
|
if self._kind == SENSOR_KIND_LEVEL:
|
||||||
aqi = data[f"aqi{self._locale}"]
|
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:
|
elif self._kind == SENSOR_KIND_AQI:
|
||||||
self._state = data[f"aqi{self._locale}"]
|
self._state = data[f"aqi{self._locale}"]
|
||||||
elif self._kind == SENSOR_KIND_POLLUTANT:
|
elif self._kind == SENSOR_KIND_POLLUTANT:
|
||||||
|
@ -244,16 +245,12 @@ class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
|
|
||||||
self._device_class = device_class
|
|
||||||
self._kind = kind
|
self._kind = kind
|
||||||
self._name = name
|
self._name = name
|
||||||
self._state = None
|
self._state = None
|
||||||
self._unit = unit
|
|
||||||
|
|
||||||
@property
|
self._attr_device_class = device_class
|
||||||
def device_class(self):
|
self._attr_unit_of_measurement = unit
|
||||||
"""Return the device class."""
|
|
||||||
return self._device_class
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue