1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00

Add entity translations to Awair (#95308)

This commit is contained in:
Joost Lekkerkerker 2023-06-27 08:27:33 +02:00 committed by GitHub
parent 6d47feb595
commit 2c3a50fdb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 10 deletions

View File

@ -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,
),

View File

@ -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"
}
}
}
}

View File

@ -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",
{