From 2c3a50fdb1838d607a99e62bb8fb23414f251b41 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 27 Jun 2023 08:27:33 +0200 Subject: [PATCH] Add entity translations to Awair (#95308) --- homeassistant/components/awair/sensor.py | 12 +++--------- homeassistant/components/awair/strings.json | 10 ++++++++++ tests/components/awair/test_sensor.py | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/awair/sensor.py b/homeassistant/components/awair/sensor.py index e771c29d45b..ee0febf1455 100644 --- a/homeassistant/components/awair/sensor.py +++ b/homeassistant/components/awair/sensor.py @@ -66,7 +66,7 @@ SENSOR_TYPE_SCORE = AwairSensorEntityDescription( key=API_SCORE, icon="mdi:blur", native_unit_of_measurement=PERCENTAGE, - name="Score", + translation_key="score", unique_id_tag="score", # matches legacy format state_class=SensorStateClass.MEASUREMENT, ) @@ -76,7 +76,6 @@ SENSOR_TYPES: tuple[AwairSensorEntityDescription, ...] = ( key=API_HUMID, device_class=SensorDeviceClass.HUMIDITY, native_unit_of_measurement=PERCENTAGE, - name="Humidity", unique_id_tag="HUMID", # matches legacy format state_class=SensorStateClass.MEASUREMENT, ), @@ -84,7 +83,6 @@ SENSOR_TYPES: tuple[AwairSensorEntityDescription, ...] = ( key=API_LUX, device_class=SensorDeviceClass.ILLUMINANCE, native_unit_of_measurement=LIGHT_LUX, - name="Illuminance", unique_id_tag="illuminance", state_class=SensorStateClass.MEASUREMENT, ), @@ -92,15 +90,15 @@ SENSOR_TYPES: tuple[AwairSensorEntityDescription, ...] = ( key=API_SPL_A, device_class=SensorDeviceClass.SOUND_PRESSURE, native_unit_of_measurement=UnitOfSoundPressure.WEIGHTED_DECIBEL_A, - name="Sound level", + translation_key="sound_level", unique_id_tag="sound_level", state_class=SensorStateClass.MEASUREMENT, ), AwairSensorEntityDescription( key=API_VOC, icon="mdi:molecule", + device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS_PARTS, native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION, - name="Volatile organic compounds", unique_id_tag="VOC", # matches legacy format state_class=SensorStateClass.MEASUREMENT, ), @@ -108,7 +106,6 @@ SENSOR_TYPES: tuple[AwairSensorEntityDescription, ...] = ( key=API_TEMP, device_class=SensorDeviceClass.TEMPERATURE, native_unit_of_measurement=UnitOfTemperature.CELSIUS, - name="Temperature", unique_id_tag="TEMP", # matches legacy format state_class=SensorStateClass.MEASUREMENT, ), @@ -116,7 +113,6 @@ SENSOR_TYPES: tuple[AwairSensorEntityDescription, ...] = ( key=API_CO2, device_class=SensorDeviceClass.CO2, native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, - name="Carbon dioxide", unique_id_tag="CO2", # matches legacy format state_class=SensorStateClass.MEASUREMENT, ), @@ -127,7 +123,6 @@ SENSOR_TYPES_DUST: tuple[AwairSensorEntityDescription, ...] = ( key=API_PM25, device_class=SensorDeviceClass.PM25, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, - name="PM2.5", unique_id_tag="PM25", # matches legacy format state_class=SensorStateClass.MEASUREMENT, ), @@ -135,7 +130,6 @@ SENSOR_TYPES_DUST: tuple[AwairSensorEntityDescription, ...] = ( key=API_PM10, device_class=SensorDeviceClass.PM10, native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, - name="PM10", unique_id_tag="PM10", # matches legacy format state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/awair/strings.json b/homeassistant/components/awair/strings.json index 6040bc1d7b0..731cd5db8dd 100644 --- a/homeassistant/components/awair/strings.json +++ b/homeassistant/components/awair/strings.json @@ -48,5 +48,15 @@ "unreachable": "[%key:common::config_flow::error::cannot_connect%]" }, "flow_title": "{model} ({device_id})" + }, + "entity": { + "sensor": { + "score": { + "name": "Score" + }, + "sound_level": { + "name": "Sound level" + } + } } } diff --git a/tests/components/awair/test_sensor.py b/tests/components/awair/test_sensor.py index 2c8aa78f791..24bbb40d9cf 100644 --- a/tests/components/awair/test_sensor.py +++ b/tests/components/awair/test_sensor.py @@ -115,7 +115,7 @@ async def test_awair_gen1_sensors( assert_expected_properties( hass, registry, - "sensor.living_room_volatile_organic_compounds", + "sensor.living_room_vocs", f"{AWAIR_UUID}_{SENSOR_TYPES_MAP[API_VOC].unique_id_tag}", "366", {