From 8e93045857cc0c0fb5f1a4a4031b770bc389f378 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker <joostlek@outlook.com> Date: Thu, 22 Jun 2023 16:02:45 +0200 Subject: [PATCH] Add entity translations to Airthings (#95052) --- homeassistant/components/airthings/sensor.py | 20 ++++++------------- .../components/airthings/strings.json | 16 +++++++++++++++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/airthings/sensor.py b/homeassistant/components/airthings/sensor.py index 5212ff51fe8..9c9859306ca 100644 --- a/homeassistant/components/airthings/sensor.py +++ b/homeassistant/components/airthings/sensor.py @@ -35,62 +35,56 @@ SENSORS: dict[str, SensorEntityDescription] = { "radonShortTermAvg": SensorEntityDescription( key="radonShortTermAvg", native_unit_of_measurement="Bq/m³", - name="Radon", + translation_key="radon", ), "temp": SensorEntityDescription( key="temp", device_class=SensorDeviceClass.TEMPERATURE, native_unit_of_measurement=UnitOfTemperature.CELSIUS, - name="Temperature", ), "humidity": SensorEntityDescription( key="humidity", device_class=SensorDeviceClass.HUMIDITY, native_unit_of_measurement=PERCENTAGE, - name="Humidity", ), "pressure": SensorEntityDescription( key="pressure", device_class=SensorDeviceClass.PRESSURE, native_unit_of_measurement=UnitOfPressure.MBAR, - name="Pressure", ), "battery": SensorEntityDescription( key="battery", device_class=SensorDeviceClass.BATTERY, native_unit_of_measurement=PERCENTAGE, entity_category=EntityCategory.DIAGNOSTIC, - name="Battery", ), "co2": SensorEntityDescription( key="co2", device_class=SensorDeviceClass.CO2, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, - name="CO2", ), "voc": SensorEntityDescription( key="voc", + device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS, native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION, - name="VOC", ), "light": SensorEntityDescription( key="light", native_unit_of_measurement=PERCENTAGE, - name="Light", + translation_key="light", ), "virusRisk": SensorEntityDescription( key="virusRisk", - name="Virus Risk", + translation_key="virus_risk", ), "mold": SensorEntityDescription( key="mold", - name="Mold", + translation_key="mold", ), "rssi": SensorEntityDescription( key="rssi", native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS, device_class=SensorDeviceClass.SIGNAL_STRENGTH, - name="RSSI", entity_registry_enabled_default=False, entity_category=EntityCategory.DIAGNOSTIC, ), @@ -98,13 +92,11 @@ SENSORS: dict[str, SensorEntityDescription] = { key="pm1", native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, device_class=SensorDeviceClass.PM1, - name="PM1", ), "pm25": SensorEntityDescription( key="pm25", native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, device_class=SensorDeviceClass.PM25, - name="PM25", ), } @@ -134,6 +126,7 @@ class AirthingsHeaterEnergySensor(CoordinatorEntity, SensorEntity): """Representation of a Airthings Sensor device.""" _attr_state_class = SensorStateClass.MEASUREMENT + _attr_has_entity_name = True def __init__( self, @@ -146,7 +139,6 @@ class AirthingsHeaterEnergySensor(CoordinatorEntity, SensorEntity): self.entity_description = entity_description - self._attr_name = f"{airthings_device.name} {entity_description.name}" self._attr_unique_id = f"{airthings_device.device_id}_{entity_description.key}" self._id = airthings_device.device_id self._attr_device_info = DeviceInfo( diff --git a/homeassistant/components/airthings/strings.json b/homeassistant/components/airthings/strings.json index af1200baa58..610891fff10 100644 --- a/homeassistant/components/airthings/strings.json +++ b/homeassistant/components/airthings/strings.json @@ -17,5 +17,21 @@ "abort": { "already_configured": "[%key:common::config_flow::abort::already_configured_account%]" } + }, + "entity": { + "sensor": { + "radon": { + "name": "Radon" + }, + "light": { + "name": "Light" + }, + "virus_risk": { + "name": "Virus Risk" + }, + "mold": { + "name": "Mold" + } + } } }