mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Migrate AirVisual to new entity naming style (#74753)
This commit is contained in:
parent
ae4f2a0e34
commit
f95c9d0f02
@ -62,20 +62,20 @@ SENSOR_KIND_VOC = "voc"
|
|||||||
GEOGRAPHY_SENSOR_DESCRIPTIONS = (
|
GEOGRAPHY_SENSOR_DESCRIPTIONS = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=SENSOR_KIND_LEVEL,
|
key=SENSOR_KIND_LEVEL,
|
||||||
name="Air Pollution Level",
|
name="Air pollution level",
|
||||||
device_class=DEVICE_CLASS_POLLUTANT_LEVEL,
|
device_class=DEVICE_CLASS_POLLUTANT_LEVEL,
|
||||||
icon="mdi:gauge",
|
icon="mdi:gauge",
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=SENSOR_KIND_AQI,
|
key=SENSOR_KIND_AQI,
|
||||||
name="Air Quality Index",
|
name="Air quality index",
|
||||||
device_class=SensorDeviceClass.AQI,
|
device_class=SensorDeviceClass.AQI,
|
||||||
native_unit_of_measurement="AQI",
|
native_unit_of_measurement="AQI",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=SENSOR_KIND_POLLUTANT,
|
key=SENSOR_KIND_POLLUTANT,
|
||||||
name="Main Pollutant",
|
name="Main pollutant",
|
||||||
device_class=DEVICE_CLASS_POLLUTANT_LABEL,
|
device_class=DEVICE_CLASS_POLLUTANT_LABEL,
|
||||||
icon="mdi:chemical-weapon",
|
icon="mdi:chemical-weapon",
|
||||||
),
|
),
|
||||||
@ -85,7 +85,7 @@ GEOGRAPHY_SENSOR_LOCALES = {"cn": "Chinese", "us": "U.S."}
|
|||||||
NODE_PRO_SENSOR_DESCRIPTIONS = (
|
NODE_PRO_SENSOR_DESCRIPTIONS = (
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key=SENSOR_KIND_AQI,
|
key=SENSOR_KIND_AQI,
|
||||||
name="Air Quality Index",
|
name="Air quality index",
|
||||||
device_class=SensorDeviceClass.AQI,
|
device_class=SensorDeviceClass.AQI,
|
||||||
native_unit_of_measurement="AQI",
|
native_unit_of_measurement="AQI",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -292,6 +292,8 @@ class AirVisualGeographySensor(AirVisualEntity, SensorEntity):
|
|||||||
class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
|
class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
|
||||||
"""Define an AirVisual sensor related to a Node/Pro unit."""
|
"""Define an AirVisual sensor related to a Node/Pro unit."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: DataUpdateCoordinator,
|
coordinator: DataUpdateCoordinator,
|
||||||
@ -301,9 +303,6 @@ class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
|
|||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(coordinator, entry, description)
|
super().__init__(coordinator, entry, description)
|
||||||
|
|
||||||
self._attr_name = (
|
|
||||||
f"{coordinator.data['settings']['node_name']} Node/Pro: {description.name}"
|
|
||||||
)
|
|
||||||
self._attr_unique_id = f"{coordinator.data['serial_number']}_{description.key}"
|
self._attr_unique_id = f"{coordinator.data['serial_number']}_{description.key}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user