Introduce unit enums for sound pressure (#83450)

* Introduce unit enums for sound pressure

* Adjust based on architecture comment

* Adjust
This commit is contained in:
epenet 2022-12-08 20:06:02 +01:00 committed by GitHub
parent 38f62ae622
commit 96c442349f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -27,6 +27,7 @@ from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT,
REVOLUTIONS_PER_MINUTE,
UnitOfIrradiance,
UnitOfSoundPressure,
UnitOfVolume,
)
from homeassistant.core import HomeAssistant, State, callback, split_entity_id
@ -55,6 +56,7 @@ DEFAULT_STATISTICS = {
EQUIVALENT_UNITS = {
"BTU/(h×ft²)": UnitOfIrradiance.BTUS_PER_HOUR_SQUARE_FOOT,
"dBa": UnitOfSoundPressure.WEIGHTED_DECIBEL_A,
"RPM": REVOLUTIONS_PER_MINUTE,
"ft3": UnitOfVolume.CUBIC_FEET,
"m3": UnitOfVolume.CUBIC_METERS,

View File

@ -702,9 +702,19 @@ PRESSURE_INHG: Final = "inHg"
PRESSURE_PSI: Final = "psi"
"""Deprecated: please use UnitOfPressure.PSI"""
# Sound pressure units
class UnitOfSoundPressure(StrEnum):
"""Sound pressure units."""
DECIBEL = "dB"
WEIGHTED_DECIBEL_A = "dBA"
SOUND_PRESSURE_DB: Final = "dB"
"""Deprecated: please use UnitOfSoundPressure.DECIBEL"""
SOUND_PRESSURE_WEIGHTED_DBA: Final = "dBa"
"""Deprecated: please use UnitOfSoundPressure.WEIGHTED_DECIBEL_A"""
# Volume units