Migrate AirVisual to new entity naming style (#74753)

This commit is contained in:
Aaron Bach 2022-07-10 13:38:00 -06:00 committed by GitHub
parent ae4f2a0e34
commit f95c9d0f02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,20 +62,20 @@ SENSOR_KIND_VOC = "voc"
GEOGRAPHY_SENSOR_DESCRIPTIONS = (
SensorEntityDescription(
key=SENSOR_KIND_LEVEL,
name="Air Pollution Level",
name="Air pollution level",
device_class=DEVICE_CLASS_POLLUTANT_LEVEL,
icon="mdi:gauge",
),
SensorEntityDescription(
key=SENSOR_KIND_AQI,
name="Air Quality Index",
name="Air quality index",
device_class=SensorDeviceClass.AQI,
native_unit_of_measurement="AQI",
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key=SENSOR_KIND_POLLUTANT,
name="Main Pollutant",
name="Main pollutant",
device_class=DEVICE_CLASS_POLLUTANT_LABEL,
icon="mdi:chemical-weapon",
),
@ -85,7 +85,7 @@ GEOGRAPHY_SENSOR_LOCALES = {"cn": "Chinese", "us": "U.S."}
NODE_PRO_SENSOR_DESCRIPTIONS = (
SensorEntityDescription(
key=SENSOR_KIND_AQI,
name="Air Quality Index",
name="Air quality index",
device_class=SensorDeviceClass.AQI,
native_unit_of_measurement="AQI",
state_class=SensorStateClass.MEASUREMENT,
@ -292,6 +292,8 @@ class AirVisualGeographySensor(AirVisualEntity, SensorEntity):
class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
"""Define an AirVisual sensor related to a Node/Pro unit."""
_attr_has_entity_name = True
def __init__(
self,
coordinator: DataUpdateCoordinator,
@ -301,9 +303,6 @@ class AirVisualNodeProSensor(AirVisualEntity, SensorEntity):
"""Initialize."""
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}"
@property