hass-core/homeassistant/util/pressure.py
epenet dc82ae4f69
Make VALID_UNITS a set (#79104)
* Make VALID_UNITS a set

* Also adjust weather
2022-09-27 07:16:03 +01:00

27 lines
766 B
Python

"""Pressure util functions."""
from __future__ import annotations
from homeassistant.const import ( # pylint: disable=unused-import # noqa: F401
PRESSURE,
PRESSURE_BAR,
PRESSURE_CBAR,
PRESSURE_HPA,
PRESSURE_INHG,
PRESSURE_KPA,
PRESSURE_MBAR,
PRESSURE_MMHG,
PRESSURE_PA,
PRESSURE_PSI,
UNIT_NOT_RECOGNIZED_TEMPLATE,
)
from .unit_conversion import PressureConverter
UNIT_CONVERSION: dict[str, float] = PressureConverter.UNIT_CONVERSION
VALID_UNITS = PressureConverter.VALID_UNITS
def convert(value: float, from_unit: str, to_unit: str) -> float:
"""Convert one unit of measurement to another."""
# Need to add warning when core migration finished
return PressureConverter.convert(value, from_unit, to_unit)