diff --git a/homeassistant/const.py b/homeassistant/const.py index 81e71fa4f9a..a0277231551 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -896,7 +896,7 @@ class UnitOfLength(StrEnum): FEET = "ft" YARDS = "yd" MILES = "mi" - NAUTICALMILES = "nmi" + NAUTICAL_MILES = "nmi" _DEPRECATED_LENGTH_MILLIMETERS: Final = DeprecatedConstantEnum( diff --git a/homeassistant/util/unit_conversion.py b/homeassistant/util/unit_conversion.py index 02591010b77..fccc77edcb0 100644 --- a/homeassistant/util/unit_conversion.py +++ b/homeassistant/util/unit_conversion.py @@ -158,12 +158,12 @@ class DistanceConverter(BaseUnitConverter): UnitOfLength.FEET: 1 / _FOOT_TO_M, UnitOfLength.YARDS: 1 / _YARD_TO_M, UnitOfLength.MILES: 1 / _MILE_TO_M, - UnitOfLength.NAUTICALMILES: 1 / _NAUTICAL_MILE_TO_M, + UnitOfLength.NAUTICAL_MILES: 1 / _NAUTICAL_MILE_TO_M, } VALID_UNITS = { UnitOfLength.KILOMETERS, UnitOfLength.MILES, - UnitOfLength.NAUTICALMILES, + UnitOfLength.NAUTICAL_MILES, UnitOfLength.FEET, UnitOfLength.METERS, UnitOfLength.CENTIMETERS, diff --git a/homeassistant/util/unit_system.py b/homeassistant/util/unit_system.py index e2e41614d3e..7f7c7f2b5fd 100644 --- a/homeassistant/util/unit_system.py +++ b/homeassistant/util/unit_system.py @@ -238,7 +238,7 @@ METRIC_SYSTEM = UnitSystem( ("distance", UnitOfLength.FEET): UnitOfLength.METERS, ("distance", UnitOfLength.INCHES): UnitOfLength.MILLIMETERS, ("distance", UnitOfLength.MILES): UnitOfLength.KILOMETERS, - ("distance", UnitOfLength.NAUTICALMILES): UnitOfLength.KILOMETERS, + ("distance", UnitOfLength.NAUTICAL_MILES): UnitOfLength.KILOMETERS, ("distance", UnitOfLength.YARDS): UnitOfLength.METERS, # Convert non-metric volumes of gas meters ("gas", UnitOfVolume.CENTUM_CUBIC_FEET): UnitOfVolume.CUBIC_METERS, diff --git a/tests/util/test_unit_conversion.py b/tests/util/test_unit_conversion.py index 7bf8f9db04a..630c3d556f1 100644 --- a/tests/util/test_unit_conversion.py +++ b/tests/util/test_unit_conversion.py @@ -173,13 +173,13 @@ _CONVERTED_VALUE: dict[ (5, UnitOfLength.MILES, 8800.0, UnitOfLength.YARDS), (5, UnitOfLength.MILES, 26400.0008448, UnitOfLength.FEET), (5, UnitOfLength.MILES, 316800.171072, UnitOfLength.INCHES), - (5, UnitOfLength.NAUTICALMILES, 9.26, UnitOfLength.KILOMETERS), - (5, UnitOfLength.NAUTICALMILES, 9260.0, UnitOfLength.METERS), - (5, UnitOfLength.NAUTICALMILES, 926000.0, UnitOfLength.CENTIMETERS), - (5, UnitOfLength.NAUTICALMILES, 9260000.0, UnitOfLength.MILLIMETERS), - (5, UnitOfLength.NAUTICALMILES, 10126.859142607176, UnitOfLength.YARDS), - (5, UnitOfLength.NAUTICALMILES, 30380.57742782153, UnitOfLength.FEET), - (5, UnitOfLength.NAUTICALMILES, 364566.9291338583, UnitOfLength.INCHES), + (5, UnitOfLength.NAUTICAL_MILES, 9.26, UnitOfLength.KILOMETERS), + (5, UnitOfLength.NAUTICAL_MILES, 9260.0, UnitOfLength.METERS), + (5, UnitOfLength.NAUTICAL_MILES, 926000.0, UnitOfLength.CENTIMETERS), + (5, UnitOfLength.NAUTICAL_MILES, 9260000.0, UnitOfLength.MILLIMETERS), + (5, UnitOfLength.NAUTICAL_MILES, 10126.859142607176, UnitOfLength.YARDS), + (5, UnitOfLength.NAUTICAL_MILES, 30380.57742782153, UnitOfLength.FEET), + (5, UnitOfLength.NAUTICAL_MILES, 364566.9291338583, UnitOfLength.INCHES), (5, UnitOfLength.YARDS, 0.004572, UnitOfLength.KILOMETERS), (5, UnitOfLength.YARDS, 4.572, UnitOfLength.METERS), (5, UnitOfLength.YARDS, 457.2, UnitOfLength.CENTIMETERS), diff --git a/tests/util/test_unit_system.py b/tests/util/test_unit_system.py index 6c15ae9aa23..c08555840bb 100644 --- a/tests/util/test_unit_system.py +++ b/tests/util/test_unit_system.py @@ -725,7 +725,7 @@ UNCONVERTED_UNITS_US_SYSTEM = { SensorDeviceClass.DISTANCE: ( UnitOfLength.FEET, UnitOfLength.INCHES, - UnitOfLength.NAUTICALMILES, + UnitOfLength.NAUTICAL_MILES, UnitOfLength.MILES, UnitOfLength.YARDS, ),