Use the unit converter directly in google_weather (#195447)

This commit is contained in:
epenet
2026-11-30 10:25:07 +01:00
committed by GitHub
parent b67afd4238
commit 5b7856dadd
@@ -41,8 +41,6 @@ from homeassistant.components.weather import (
ATTR_FORECAST_TIME,
ATTR_FORECAST_UV_INDEX,
ATTR_FORECAST_WIND_BEARING,
ATTR_WEATHER_PRECIPITATION_UNIT,
UNIT_CONVERSIONS,
CoordinatorWeatherEntity,
Forecast,
WeatherEntityFeature,
@@ -61,6 +59,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
from homeassistant.util import dt as dt_util
from homeassistant.util.unit_conversion import DistanceConverter
from .const import DOMAIN
from .coordinator import (
@@ -385,7 +384,7 @@ class GoogleWeatherEntity(
"""
if amount is None or amount.quantity is None:
return None
return UNIT_CONVERSIONS[ATTR_WEATHER_PRECIPITATION_UNIT](
return DistanceConverter.convert(
amount.quantity,
UnitOfPrecipitationDepth.MILLIMETERS,
self._precipitation_unit,