From a28b0e1b6ffb91f476cbf249832e2fa3fd5151f9 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 26 Oct 2022 17:57:41 +0200 Subject: [PATCH] Migrate volume units to an enum (#81028) * Migrate volume units to an enum * Adjust docstring * Deprecate -> Deprecated * Plural --- homeassistant/const.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index 7601dd05dd4..112b1637c46 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -637,17 +637,38 @@ PRESSURE_PSI: Final = "psi" SOUND_PRESSURE_DB: Final = "dB" SOUND_PRESSURE_WEIGHTED_DBA: Final = "dBa" + # Volume units +class UnitOfVolume(StrEnum): + """Volume units.""" + + CUBIC_FEET = "ft³" + CUBIC_METERS = "m³" + LITERS = "L" + MILLILITERS = "mL" + GALLONS = "gal" + """Assumed to be US gallons in conversion utilities. + + British/Imperial gallons are not yet supported""" + FLUID_OUNCES = "fl. oz." + """Assumed to be US fluid ounces in conversion utilities. + + British/Imperial fluid ounces are not yet supported""" + + VOLUME_LITERS: Final = "L" +"""Deprecated: please use UnitOfVolume.LITERS""" VOLUME_MILLILITERS: Final = "mL" +"""Deprecated: please use UnitOfVolume.MILLILITERS""" VOLUME_CUBIC_METERS: Final = "m³" +"""Deprecated: please use UnitOfVolume.CUBIC_METERS""" VOLUME_CUBIC_FEET: Final = "ft³" +"""Deprecated: please use UnitOfVolume.CUBIC_FEET""" VOLUME_GALLONS: Final = "gal" -"""US gallon (British gallon is not yet supported)""" - +"""Deprecated: please use UnitOfVolume.GALLONS""" VOLUME_FLUID_OUNCE: Final = "fl. oz." -"""US fluid ounce (British fluid ounce is not yet supported)""" +"""Deprecated: please use UnitOfVolume.FLUID_OUNCES""" # Volume Flow Rate units VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR: Final = "m³/h"