From ec0af2f25dd6dd0c67e5d1e563acf4158fd369d3 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 8 Dec 2022 20:56:02 +0100 Subject: [PATCH] Use SoundPressure unit and device class in awair (#83582) --- homeassistant/components/awair/const.py | 10 +++++----- tests/components/awair/test_sensor.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/awair/const.py b/homeassistant/components/awair/const.py index c117129dd2a..d483df64298 100644 --- a/homeassistant/components/awair/const.py +++ b/homeassistant/components/awair/const.py @@ -19,8 +19,8 @@ from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, LIGHT_LUX, PERCENTAGE, - SOUND_PRESSURE_WEIGHTED_DBA, - TEMP_CELSIUS, + UnitOfSoundPressure, + UnitOfTemperature, ) API_CO2 = "carbon_dioxide" @@ -87,8 +87,8 @@ SENSOR_TYPES: tuple[AwairSensorEntityDescription, ...] = ( ), AwairSensorEntityDescription( key=API_SPL_A, - icon="mdi:ear-hearing", - native_unit_of_measurement=SOUND_PRESSURE_WEIGHTED_DBA, + device_class=SensorDeviceClass.SOUND_PRESSURE, + native_unit_of_measurement=UnitOfSoundPressure.WEIGHTED_DECIBEL_A, name="Sound level", unique_id_tag="sound_level", state_class=SensorStateClass.MEASUREMENT, @@ -104,7 +104,7 @@ SENSOR_TYPES: tuple[AwairSensorEntityDescription, ...] = ( AwairSensorEntityDescription( key=API_TEMP, device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, name="Temperature", unique_id_tag="TEMP", # matches legacy format state_class=SensorStateClass.MEASUREMENT, diff --git a/tests/components/awair/test_sensor.py b/tests/components/awair/test_sensor.py index 162b68d913b..32a4578bebc 100644 --- a/tests/components/awair/test_sensor.py +++ b/tests/components/awair/test_sensor.py @@ -287,7 +287,7 @@ async def test_awair_omni_sensors(hass: HomeAssistant, user, cloud_devices, omni "sensor.living_room_sound_level", f"{AWAIR_UUID}_{SENSOR_TYPES_MAP[API_SPL_A].unique_id_tag}", "47.0", - {ATTR_UNIT_OF_MEASUREMENT: "dBa"}, + {ATTR_UNIT_OF_MEASUREMENT: "dBA"}, ) assert_expected_properties(