mirror of
https://github.com/jdejaegh/irm-kmi-api.git
synced 2025-06-26 20:05:40 +02:00
Add second weather condition and evolution
This commit is contained in:
parent
c3896bd3ce
commit
c1caa01034
5 changed files with 24 additions and 5 deletions
|
@ -14,7 +14,7 @@ from zoneinfo import ZoneInfo
|
|||
import aiohttp
|
||||
import async_timeout
|
||||
|
||||
from .const import MAP_WARNING_ID_TO_SLUG as SLUG_MAP
|
||||
from .const import MAP_WARNING_ID_TO_SLUG as SLUG_MAP, WWEVOL_TO_ENUM_MAP
|
||||
from .const import STYLE_TO_PARAM_MAP, WEEKDAYS
|
||||
from .data import (AnimationFrameData, CurrentWeatherData, Forecast,
|
||||
IrmKmiForecast, IrmKmiRadarForecast, RadarAnimationData,
|
||||
|
@ -314,6 +314,8 @@ class IrmKmiApiClientHa(IrmKmiApiClient):
|
|||
forecast = IrmKmiForecast(
|
||||
datetime=(forecast_day.strftime('%Y-%m-%d')),
|
||||
condition=self._cdt_map.get((f.get('ww1', None), f.get('dayNight', None)), None),
|
||||
condition_2=self._cdt_map.get((f.get('ww2', None), f.get('dayNight', None)), None),
|
||||
condition_evol=WWEVOL_TO_ENUM_MAP.get(f.get('wwevol'), None),
|
||||
native_precipitation=precipitation,
|
||||
native_temperature=f.get('tempMax', None),
|
||||
native_templow=f.get('tempMin', None),
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from typing import Final
|
||||
|
||||
from irm_kmi_api.data import IrmKmiConditionEvol
|
||||
|
||||
POLLEN_NAMES: Final = {'Alder', 'Ash', 'Birch', 'Grasses', 'Hazel', 'Mugwort', 'Oak'}
|
||||
POLLEN_LEVEL_TO_COLOR = {'null': 'green', 'low': 'yellow', 'moderate': 'orange', 'high': 'red', 'very high': 'purple',
|
||||
'active': 'active'}
|
||||
|
@ -26,3 +28,9 @@ MAP_WARNING_ID_TO_SLUG: Final = {
|
|||
14: 'thunderstorm_large_rainfall',
|
||||
15: 'storm_surge',
|
||||
17: 'coldspell'}
|
||||
|
||||
WWEVOL_TO_ENUM_MAP: Final = {
|
||||
None: IrmKmiConditionEvol.STABLE,
|
||||
0: IrmKmiConditionEvol.ONE_WAY,
|
||||
1: IrmKmiConditionEvol.TWO_WAYS
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
"""Data classes for IRM KMI integration"""
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import List, Required, TypedDict
|
||||
|
||||
|
||||
|
@ -35,10 +36,16 @@ class Forecast(TypedDict, total=False):
|
|||
is_daytime: bool | None # Mandatory to use with forecast_twice_daily
|
||||
|
||||
|
||||
class IrmKmiForecast(Forecast):
|
||||
class IrmKmiConditionEvol(Enum):
|
||||
ONE_WAY = 'one_way'
|
||||
TWO_WAYS = 'two_ways'
|
||||
STABLE = 'stable'
|
||||
|
||||
class IrmKmiForecast(Forecast, total=False):
|
||||
"""Forecast class with additional attributes for IRM KMI"""
|
||||
|
||||
# TODO: add condition_2 as well and evolution to match data from the API?
|
||||
condition_2: str | None
|
||||
condition_evol: IrmKmiConditionEvol | None
|
||||
text: str | None
|
||||
sunrise: str | None
|
||||
sunset: str | None
|
||||
|
|
2
tests/fixtures/forecast.json
vendored
2
tests/fixtures/forecast.json
vendored
|
@ -75,7 +75,7 @@
|
|||
"tempMax": 9,
|
||||
"ww1": 3,
|
||||
"ww2": null,
|
||||
"wwevol": null,
|
||||
"wwevol": 1,
|
||||
"ff1": 4,
|
||||
"ff2": null,
|
||||
"ffevol": null,
|
||||
|
|
|
@ -3,7 +3,7 @@ from zoneinfo import ZoneInfo
|
|||
|
||||
from freezegun import freeze_time
|
||||
|
||||
from irm_kmi_api.data import IrmKmiForecast
|
||||
from irm_kmi_api.data import IrmKmiForecast, IrmKmiConditionEvol
|
||||
from tests.conftest import get_api_with_data
|
||||
from tests.const import ATTR_CONDITION_PARTLYCLOUDY
|
||||
|
||||
|
@ -22,6 +22,8 @@ async def test_daily_forecast() -> None:
|
|||
expected = IrmKmiForecast(
|
||||
datetime='2023-12-27',
|
||||
condition=ATTR_CONDITION_PARTLYCLOUDY,
|
||||
condition_2=None,
|
||||
condition_evol=IrmKmiConditionEvol.TWO_WAYS,
|
||||
native_precipitation=0,
|
||||
native_temperature=9,
|
||||
native_templow=4,
|
||||
|
|
Loading…
Add table
Reference in a new issue