Add atmospheres (atm) as a pressure unit (#178708)

Co-authored-by: Markus Tuominen <3738613+Markus98@users.noreply.github.com>
This commit is contained in:
Brett Adams
2026-08-31 16:17:38 +03:00
committed by GitHub
co-authored by Markus Tuominen
parent c4cfba0b22
commit 9889cfcf66
8 changed files with 20 additions and 4 deletions
+1
View File
@@ -647,6 +647,7 @@ class UnitOfPressure(StrEnum):
INHG = "inHg"
INH2O = "inH₂O"
PSI = "psi"
ATM = "atm"
# Sound pressure units
+4
View File
@@ -22,6 +22,7 @@
"yd\u00b2"
],
"atmospheric_pressure": [
"atm",
"bar",
"cbar",
"hPa",
@@ -199,6 +200,7 @@
"mm/h"
],
"pressure": [
"atm",
"bar",
"cbar",
"hPa",
@@ -356,6 +358,7 @@
"yd\u00b2"
],
"atmospheric_pressure": [
"atm",
"bar",
"cbar",
"hPa",
@@ -570,6 +573,7 @@
"mm/h"
],
"pressure": [
"atm",
"bar",
"cbar",
"hPa",
+2
View File
@@ -600,6 +600,7 @@ class PressureConverter(BaseUnitConverter):
UnitOfPressure.PSI: 1 / 6894.757,
UnitOfPressure.MMHG: 1
/ (_MM_TO_M * 1000 * _STANDARD_GRAVITY * _MERCURY_DENSITY),
UnitOfPressure.ATM: 1 / 101325,
}
VALID_UNITS = {
UnitOfPressure.MILLIPASCAL,
@@ -613,6 +614,7 @@ class PressureConverter(BaseUnitConverter):
UnitOfPressure.INH2O,
UnitOfPressure.PSI,
UnitOfPressure.MMHG,
UnitOfPressure.ATM,
}
+1
View File
@@ -386,6 +386,7 @@ US_CUSTOMARY_SYSTEM = UnitSystem(
("pressure", UnitOfPressure.KPA): UnitOfPressure.PSI,
("pressure", UnitOfPressure.MMHG): UnitOfPressure.INHG,
("pressure", UnitOfPressure.INH2O): UnitOfPressure.PSI,
("pressure", UnitOfPressure.ATM): UnitOfPressure.PSI,
# Convert non-USCS radon concentration
(
"radon",
@@ -1839,6 +1839,7 @@
'ZB',
'ZiB',
'ac',
'atm',
'bar',
'bit',
'bit/s',
@@ -2216,6 +2217,7 @@
'ZB',
'ZiB',
'ac',
'atm',
'bar',
'bit',
'bit/s',
+4 -4
View File
@@ -5322,7 +5322,7 @@ async def async_record_states(
"pressure",
"psi",
"bar",
"Pa, bar, cbar, hPa, inHg, inH₂O, kPa, mPa, mbar, mmHg, psi",
"Pa, atm, bar, cbar, hPa, inHg, inH₂O, kPa, mPa, mbar, mmHg, psi",
),
(
METRIC_SYSTEM,
@@ -5330,7 +5330,7 @@ async def async_record_states(
"pressure",
"Pa",
"bar",
"Pa, bar, cbar, hPa, inHg, inH₂O, kPa, mPa, mbar, mmHg, psi",
"Pa, atm, bar, cbar, hPa, inHg, inH₂O, kPa, mPa, mbar, mmHg, psi",
),
],
)
@@ -5561,7 +5561,7 @@ async def test_validate_statistics_unit_ignore_device_class(
"pressure",
"psi",
"bar",
"Pa, bar, cbar, hPa, inHg, inH₂O, kPa, mPa, mbar, mmHg, psi",
"Pa, atm, bar, cbar, hPa, inHg, inH₂O, kPa, mPa, mbar, mmHg, psi",
),
(
METRIC_SYSTEM,
@@ -5569,7 +5569,7 @@ async def test_validate_statistics_unit_ignore_device_class(
"pressure",
"Pa",
"bar",
"Pa, bar, cbar, hPa, inHg, inH₂O, kPa, mPa, mbar, mmHg, psi",
"Pa, atm, bar, cbar, hPa, inHg, inH₂O, kPa, mPa, mbar, mmHg, psi",
),
(
METRIC_SYSTEM,
+5
View File
@@ -880,6 +880,11 @@ _CONVERTED_VALUE: dict[
(30, UnitOfPressure.MMHG, 1.181102, UnitOfPressure.INHG),
(30, UnitOfPressure.MMHG, 16.0572051431838, UnitOfPressure.INH2O),
(5, UnitOfPressure.BAR, 72.51887, UnitOfPressure.PSI),
(1, UnitOfPressure.ATM, 101325, UnitOfPressure.PA),
(1, UnitOfPressure.ATM, 1013.25, UnitOfPressure.HPA),
(1, UnitOfPressure.ATM, 1013.25, UnitOfPressure.MBAR),
(1, UnitOfPressure.ATM, 1.01325, UnitOfPressure.BAR),
(101325, UnitOfPressure.PA, 1, UnitOfPressure.ATM),
],
RadiationConcentrationConverter: [
(
+1
View File
@@ -601,6 +601,7 @@ UNCONVERTED_UNITS_METRIC_SYSTEM = {
UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR,
),
SensorDeviceClass.PRESSURE: (
UnitOfPressure.ATM,
UnitOfPressure.BAR,
UnitOfPressure.CBAR,
UnitOfPressure.HPA,