mirror of
https://github.com/jdejaegh/irm-kmi-ha.git
synced 2025-06-27 11:39:26 +02:00
Add forecast text as an attribute
This commit is contained in:
parent
1c50c78f7a
commit
d488d15875
2 changed files with 10 additions and 1 deletions
|
@ -1 +1,7 @@
|
||||||
"""Integration for IRM KMI weather"""
|
"""Integration for IRM KMI weather"""
|
||||||
|
|
||||||
|
from homeassistant.components.weather import Forecast
|
||||||
|
class IrmKmiForecast(Forecast):
|
||||||
|
"""Forecast class with additional attributes for IRM KMI"""
|
||||||
|
text_fr: str | None
|
||||||
|
text_nl: str | None
|
||||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant.helpers.update_coordinator import (
|
||||||
UpdateFailed,
|
UpdateFailed,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from . import IrmKmiForecast
|
||||||
from .const import IRM_KMI_TO_HA_CONDITION_MAP as CDT_MAP
|
from .const import IRM_KMI_TO_HA_CONDITION_MAP as CDT_MAP
|
||||||
from .api import IrmKmiApiClient, IrmKmiApiError
|
from .api import IrmKmiApiClient, IrmKmiApiError
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ def daily_dict_to_forecast(data: List[dict] | None) -> List[Forecast] | None:
|
||||||
|
|
||||||
is_daytime = f.get('dayNight', None) == 'd'
|
is_daytime = f.get('dayNight', None) == 'd'
|
||||||
|
|
||||||
forecast = Forecast(
|
forecast = IrmKmiForecast(
|
||||||
datetime=(datetime.now() + timedelta(days=n_days)).strftime('%Y-%m-%d')
|
datetime=(datetime.now() + timedelta(days=n_days)).strftime('%Y-%m-%d')
|
||||||
if is_daytime else datetime.now().strftime('%Y-%m-%d'),
|
if is_daytime else datetime.now().strftime('%Y-%m-%d'),
|
||||||
condition=CDT_MAP.get((f.get('ww1'), f.get('dayNight')), None),
|
condition=CDT_MAP.get((f.get('ww1'), f.get('dayNight')), None),
|
||||||
|
@ -45,6 +46,8 @@ def daily_dict_to_forecast(data: List[dict] | None) -> List[Forecast] | None:
|
||||||
precipitation_probability=f.get('precipChance', None),
|
precipitation_probability=f.get('precipChance', None),
|
||||||
wind_bearing=f.get('wind', {}).get('dirText', {}).get('en'),
|
wind_bearing=f.get('wind', {}).get('dirText', {}).get('en'),
|
||||||
is_daytime=is_daytime,
|
is_daytime=is_daytime,
|
||||||
|
text_fr=f.get('text', {}).get('fr'),
|
||||||
|
text_nl=f.get('text', {}).get('nl')
|
||||||
)
|
)
|
||||||
forecasts.append(forecast)
|
forecasts.append(forecast)
|
||||||
if is_daytime:
|
if is_daytime:
|
||||||
|
|
Loading…
Add table
Reference in a new issue