1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Add preferred wind speed unit to unit systems (#90504)

* Add preferred wind speed unit to unit systems

* Tweak

* Update tests
This commit is contained in:
Erik Montnemery
2023-03-30 12:54:12 +02:00
committed by GitHub
parent b316ffff9b
commit ead88cc3f8
2 changed files with 50 additions and 0 deletions

View File

@@ -277,6 +277,12 @@ METRIC_SYSTEM = UnitSystem(
("water", UnitOfVolume.CENTUM_CUBIC_FEET): UnitOfVolume.CUBIC_METERS,
("water", UnitOfVolume.CUBIC_FEET): UnitOfVolume.CUBIC_METERS,
("water", UnitOfVolume.GALLONS): UnitOfVolume.LITERS,
# Convert wind speeds except knots to km/h
**{
("wind_speed", unit): UnitOfSpeed.KILOMETERS_PER_HOUR
for unit in UnitOfSpeed
if unit not in (UnitOfSpeed.KILOMETERS_PER_HOUR, UnitOfSpeed.KNOTS)
},
},
length=UnitOfLength.KILOMETERS,
mass=UnitOfMass.GRAMS,
@@ -341,6 +347,12 @@ US_CUSTOMARY_SYSTEM = UnitSystem(
# Convert non-USCS volumes of water meters
("water", UnitOfVolume.CUBIC_METERS): UnitOfVolume.CUBIC_FEET,
("water", UnitOfVolume.LITERS): UnitOfVolume.GALLONS,
# Convert wind speeds except knots to mph
**{
("wind_speed", unit): UnitOfSpeed.MILES_PER_HOUR
for unit in UnitOfSpeed
if unit not in (UnitOfSpeed.KNOTS, UnitOfSpeed.MILES_PER_HOUR)
},
},
length=UnitOfLength.MILES,
mass=UnitOfMass.POUNDS,