1 """Support for WeatherFlow Forecast weather service."""
3 from __future__
import annotations
5 from weatherflow4py.models.rest.unified
import WeatherFlowDataREST
9 SingleCoordinatorWeatherEntity,
14 UnitOfPrecipitationDepth,
22 from .const
import DOMAIN, STATE_MAP
23 from .coordinator
import WeatherFlowCloudDataUpdateCoordinator
24 from .entity
import WeatherFlowCloudEntity
29 config_entry: ConfigEntry,
30 async_add_entities: AddEntitiesCallback,
32 """Add a weather entity from a config_entry."""
33 coordinator: WeatherFlowCloudDataUpdateCoordinator = hass.data[DOMAIN][
40 for station_id, data
in coordinator.data.items()
46 WeatherFlowCloudEntity,
47 SingleCoordinatorWeatherEntity[WeatherFlowCloudDataUpdateCoordinator],
49 """Implementation of a WeatherFlow weather condition."""
51 _attr_native_temperature_unit = UnitOfTemperature.CELSIUS
52 _attr_native_precipitation_unit = UnitOfPrecipitationDepth.MILLIMETERS
53 _attr_native_pressure_unit = UnitOfPressure.MBAR
54 _attr_native_wind_speed_unit = UnitOfSpeed.METERS_PER_SECOND
55 _attr_supported_features = (
56 WeatherEntityFeature.FORECAST_DAILY | WeatherEntityFeature.FORECAST_HOURLY
62 coordinator: WeatherFlowCloudDataUpdateCoordinator,
65 """Initialise the platform with a data instance and station."""
66 super().
__init__(coordinator, station_id)
71 """Return the local weather data object for this station."""
72 return self.coordinator.data[self.
station_idstation_id]
76 """Return current condition - required property."""
77 return STATE_MAP[self.
local_datalocal_data.weather.current_conditions.icon.value]
81 """Return the temperature."""
82 return self.
local_datalocal_data.weather.current_conditions.air_temperature
86 """Return the Air Pressure @ Station."""
87 return self.
local_datalocal_data.weather.current_conditions.station_pressure
91 """Return the humidity."""
92 return self.
local_datalocal_data.weather.current_conditions.relative_humidity
96 """Return the wind speed."""
97 return self.
local_datalocal_data.weather.current_conditions.wind_avg
101 """Return the wind direction."""
102 return self.
local_datalocal_data.weather.current_conditions.wind_direction
106 """Return the wind gust speed in native units."""
107 return self.
local_datalocal_data.weather.current_conditions.wind_gust
111 """Return dew point."""
112 return self.
local_datalocal_data.weather.current_conditions.dew_point
116 """Return UV Index."""
117 return self.
local_datalocal_data.weather.current_conditions.uv
121 """Return the daily forecast in native units."""
122 return [x.ha_forecast
for x
in self.
local_datalocal_data.weather.forecast.daily]
126 """Return the hourly forecast in native units."""
127 return [x.ha_forecast
for x
in self.
local_datalocal_data.weather.forecast.hourly]
WeatherFlowDataREST local_data(self)
list[Forecast]|None _async_forecast_hourly(self)
float|str|None wind_bearing(self)
float|None native_pressure(self)
float|None native_dew_point(self)
float|None native_wind_gust_speed(self)
float|None native_wind_speed(self)
None __init__(self, WeatherFlowCloudDataUpdateCoordinator coordinator, int station_id)
float|None native_temperature(self)
float|None humidity(self)
float|None uv_index(self)
list[Forecast]|None _async_forecast_daily(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)