Compare commits

...

3 commits

Author SHA1 Message Date
866b1f3fa0
bump version 0.3.0 -> 0.3.1 2025-05-13 19:09:11 +02:00
914dd75d7b
Merge pull request #86 from jdejaegh/fix_regression
Fix regression in 0.3.0: make all elements from Forecast serializable
2025-05-13 19:03:42 +02:00
5c320b57fb
Fix regression: make all elements from Forecast serializable
Fix #85
2025-05-13 18:49:40 +02:00
6 changed files with 50 additions and 6 deletions

View file

@ -134,7 +134,7 @@ IRM_KMI_NAME: Final = {
'en': 'Royal Meteorological Institute of Belgium'
}
USER_AGENT: Final = 'github.com/jdejaegh/irm-kmi-ha 0.3.0'
USER_AGENT: Final = 'github.com/jdejaegh/irm-kmi-ha 0.3.1'
CURRENT_WEATHER_SENSORS: Final = {'temperature', 'wind_speed', 'wind_gust_speed', 'wind_bearing', 'uv_index',
'pressure'}

View file

@ -128,9 +128,18 @@ class IrmKmiCoordinator(TimestampDataUpdateCoordinator):
except ValueError:
animation = None
# Make 'condition_evol' in a str instead of enum variant
daily_forecast = [
{**d, "condition_evol": d["condition_evol"].value}
if "condition_evol" in d and hasattr(d["condition_evol"], "value")
else d
for d in self._api.get_daily_forecast(tz, lang)
]
return ProcessedCoordinatorData(
current_weather=self._api.get_current_weather(tz),
daily_forecast=self._api.get_daily_forecast(tz, lang),
daily_forecast=daily_forecast,
hourly_forecast=self._api.get_hourly_forecast(tz),
radar_forecast=self._api.get_radar_forecast(),
animation=animation,

View file

@ -9,7 +9,7 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/jdejaegh/irm-kmi-ha/issues",
"requirements": [
"irm-kmi-api>=0.1.4,<1.0.0"
"irm-kmi-api==0.1.6"
],
"version": "0.3.0"
"version": "0.3.1"
}

View file

@ -1,5 +1,5 @@
[tool.bumpver]
current_version = "0.3.0"
current_version = "0.3.1"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "bump version {old_version} -> {new_version}"
tag_message = "{new_version}"

View file

@ -1,4 +1,4 @@
aiohttp>=3.11.13
homeassistant==2025.4.4
voluptuous==0.15.2
irm-kmi-api>=0.1.4,<1.0.0
irm-kmi-api==0.1.6

View file

@ -128,3 +128,38 @@ async def test_radar_forecast_service(
result_service: List[Forecast] = weather.get_forecasts_radar_service(True)
assert result_service == expected
def is_serializable(x):
try:
json.dumps(x)
return True
except (TypeError, OverflowError):
return False
def all_serializable(elements: list[Forecast]):
for element in elements:
for v in element.values():
assert is_serializable(v)
async def test_forecast_types_are_serializable(
hass: HomeAssistant,
mock_config_entry: MockConfigEntry
) -> None:
coordinator = IrmKmiCoordinator(hass, mock_config_entry)
forecast = json.loads(load_fixture("forecast.json"))
coordinator._api._api_data = forecast
coordinator.data = await coordinator.process_api_data()
weather = IrmKmiWeather(coordinator, mock_config_entry)
result = await weather.async_forecast_daily()
all_serializable(result)
result = await weather.async_forecast_twice_daily()
all_serializable(result)
result = await weather.async_forecast_hourly()
all_serializable(result)
result = weather.get_forecasts_radar_service(True)
all_serializable(result)