Skip to content

Commit

Permalink
Migrate mass units to an enum (home-assistant#81021)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Oct 26, 2022
1 parent dde7634 commit e18adb3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion homeassistant/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,31 @@ class UnitOfPressure(StrEnum):
# Area units
AREA_SQUARE_METERS: Final = "m²"


# Mass units
class UnitOfMass(StrEnum):
"""Mass units."""

GRAMS = "g"
KILOGRAMS = "kg"
MILLIGRAMS = "mg"
MICROGRAMS = "µg"
OUNCES = "oz"
POUNDS = "lb"


MASS_GRAMS: Final = "g"
"""Deprecated: please use UnitOfMass.GRAMS"""
MASS_KILOGRAMS: Final = "kg"
"""Deprecated: please use UnitOfMass.KILOGRAMS"""
MASS_MILLIGRAMS: Final = "mg"
"""Deprecated: please use UnitOfMass.MILLIGRAMS"""
MASS_MICROGRAMS: Final = "µg"

"""Deprecated: please use UnitOfMass.MICROGRAMS"""
MASS_OUNCES: Final = "oz"
"""Deprecated: please use UnitOfMass.OUNCES"""
MASS_POUNDS: Final = "lb"
"""Deprecated: please use UnitOfMass.POUNDS"""

# Conductivity units
CONDUCTIVITY: Final = "µS/cm"
Expand Down

0 comments on commit e18adb3

Please sign in to comment.