From a267045a31a2bfe0ceff83cd5c46ee87ec9b361c Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Sat, 25 Jun 2022 01:05:31 +0200 Subject: [PATCH] Migrate open_meteo to native_* (#73910) --- .../components/open_meteo/weather.py | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/open_meteo/weather.py b/homeassistant/components/open_meteo/weather.py index 40b52248a52..d1f0adf2e87 100644 --- a/homeassistant/components/open_meteo/weather.py +++ b/homeassistant/components/open_meteo/weather.py @@ -5,7 +5,11 @@ from open_meteo import Forecast as OpenMeteoForecast from homeassistant.components.weather import Forecast, WeatherEntity from homeassistant.config_entries import ConfigEntry -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import ( + LENGTH_MILLIMETERS, + SPEED_KILOMETERS_PER_HOUR, + TEMP_CELSIUS, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.device_registry import DeviceEntryType from homeassistant.helpers.entity import DeviceInfo @@ -33,7 +37,9 @@ class OpenMeteoWeatherEntity( ): """Defines an Open-Meteo weather entity.""" - _attr_temperature_unit = TEMP_CELSIUS + _attr_native_precipitation_unit = LENGTH_MILLIMETERS + _attr_native_temperature_unit = TEMP_CELSIUS + _attr_native_wind_speed_unit = SPEED_KILOMETERS_PER_HOUR def __init__( self, @@ -63,14 +69,14 @@ class OpenMeteoWeatherEntity( ) @property - def temperature(self) -> float | None: + def native_temperature(self) -> float | None: """Return the platform temperature.""" if not self.coordinator.data.current_weather: return None return self.coordinator.data.current_weather.temperature @property - def wind_speed(self) -> float | None: + def native_wind_speed(self) -> float | None: """Return the wind speed.""" if not self.coordinator.data.current_weather: return None @@ -103,19 +109,19 @@ class OpenMeteoWeatherEntity( ) if daily.precipitation_sum is not None: - forecast["precipitation"] = daily.precipitation_sum[index] + forecast["native_precipitation"] = daily.precipitation_sum[index] if daily.temperature_2m_max is not None: - forecast["temperature"] = daily.temperature_2m_max[index] + forecast["native_temperature"] = daily.temperature_2m_max[index] if daily.temperature_2m_min is not None: - forecast["templow"] = daily.temperature_2m_min[index] + forecast["native_templow"] = daily.temperature_2m_min[index] if daily.wind_direction_10m_dominant is not None: forecast["wind_bearing"] = daily.wind_direction_10m_dominant[index] if daily.wind_speed_10m_max is not None: - forecast["wind_speed"] = daily.wind_speed_10m_max[index] + forecast["native_wind_speed"] = daily.wind_speed_10m_max[index] forecasts.append(forecast)