mirror of
https://github.com/jdejaegh/irm-kmi-ha.git
synced 2025-06-26 19:35:40 +02:00
Compare commits
3 commits
68bcb8aeb4
...
866b1f3fa0
Author | SHA1 | Date | |
---|---|---|---|
866b1f3fa0 | |||
914dd75d7b | |||
5c320b57fb |
6 changed files with 50 additions and 6 deletions
|
@ -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'}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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}"
|
||||
|
|
|
@ -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
|
|
@ -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)
|
Loading…
Add table
Reference in a new issue