mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Modernize open_meteo weather (#98504)
This commit is contained in:
parent
3e56d27bf7
commit
79811984f0
@ -3,16 +3,17 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from open_meteo import Forecast as OpenMeteoForecast
|
from open_meteo import Forecast as OpenMeteoForecast
|
||||||
|
|
||||||
from homeassistant.components.weather import Forecast, WeatherEntity
|
from homeassistant.components.weather import (
|
||||||
|
CoordinatorWeatherEntity,
|
||||||
|
Forecast,
|
||||||
|
WeatherEntityFeature,
|
||||||
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import UnitOfPrecipitationDepth, UnitOfSpeed, UnitOfTemperature
|
from homeassistant.const import UnitOfPrecipitationDepth, UnitOfSpeed, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
CoordinatorEntity,
|
|
||||||
DataUpdateCoordinator,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import DOMAIN, WMO_TO_HA_CONDITION_MAP
|
from .const import DOMAIN, WMO_TO_HA_CONDITION_MAP
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
|
|
||||||
class OpenMeteoWeatherEntity(
|
class OpenMeteoWeatherEntity(
|
||||||
CoordinatorEntity[DataUpdateCoordinator[OpenMeteoForecast]], WeatherEntity
|
CoordinatorWeatherEntity[DataUpdateCoordinator[OpenMeteoForecast]]
|
||||||
):
|
):
|
||||||
"""Defines an Open-Meteo weather entity."""
|
"""Defines an Open-Meteo weather entity."""
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ class OpenMeteoWeatherEntity(
|
|||||||
_attr_native_precipitation_unit = UnitOfPrecipitationDepth.MILLIMETERS
|
_attr_native_precipitation_unit = UnitOfPrecipitationDepth.MILLIMETERS
|
||||||
_attr_native_temperature_unit = UnitOfTemperature.CELSIUS
|
_attr_native_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
_attr_native_wind_speed_unit = UnitOfSpeed.KILOMETERS_PER_HOUR
|
_attr_native_wind_speed_unit = UnitOfSpeed.KILOMETERS_PER_HOUR
|
||||||
|
_attr_supported_features = WeatherEntityFeature.FORECAST_DAILY
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -121,3 +123,7 @@ class OpenMeteoWeatherEntity(
|
|||||||
forecasts.append(forecast)
|
forecasts.append(forecast)
|
||||||
|
|
||||||
return forecasts
|
return forecasts
|
||||||
|
|
||||||
|
async def async_forecast_daily(self) -> list[Forecast] | None:
|
||||||
|
"""Return the daily forecast in native units."""
|
||||||
|
return self.forecast
|
||||||
|
Loading…
x
Reference in New Issue
Block a user