-
-
Notifications
You must be signed in to change notification settings - Fork 29.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce unit enums for sound pressure #83450
Conversation
homeassistant/const.py
Outdated
"""Sound pressure units.""" | ||
|
||
DECIBEL = "dB" | ||
WEIGHTED_DECIBEL_A = "dB(A)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted based on home-assistant/architecture#837 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing wrong with this, but just adding some extra info.
dBA is also acceptable (also noted in the Wikipedia page). Common usage (from what I've seen) is dBA over dB(A). Definitely not dBa.
For a really comprehensive list of dB variants see https://en.wikipedia.org/wiki/Decibel.
A second thing (which probably displays my lack of knowledge around unit management in HA) is this:
Can units have properties, e.g. so that the unit is dB, but there's an attribute/property to say it uses A-weighted values?
dBA, dBB, and dBC
These symbols are often used to denote the use of different weighting filters, used to approximate the human ear's response to sound, although the measurement is still in dB (SPL). These measurements usually refer to noise and its effects on humans and other animals, and they are widely used in industry while discussing noise control issues, regulations and environmental standards. Other variations that may be seen are dBA or dB(A). According to standards from the International Electro-technical Committee (IEC 61672-2013)[52] and the American National Standards Institute, ANSI S1.4,[53] the preferred usage is to write LA = x dB. Nevertheless, the units dBA and dB(A) are still commonly used as a shorthand for A‑weighted measurements. Compare dBc, used in telecommunications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you said, the current variant dBa
isn't really valid.
I prefer dB(A)
over dBA
because I think it makes it clearer it's added information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @epenet 👍
2e8dbd3
to
6612ad9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @epenet 👍
Breaking change
FOR DEVELOPPERS ONLY: as of Home Assistant Core 2023.1, the following unit constants are deprecated and replaced
by a corresponding enum:
UnitOfSoundPressure
enumerator replacesSOUND_PRESSURE_**
constantsProposed change
Introduce unit enums for sound pressure
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: