Skip to content

Commit 79bcd50

Browse files
committed
Sync changes from hacore2/dwd_global_rad_api_server
1 parent 04fb15e commit 79bcd50

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

custom_components/dwd_global_rad/api_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ async def get_status(self):
8787
return True
8888
else:
8989
return False
90+
91+
async def get_forecast_for_future_hour(self, location_name: str, number_of_hours: int):
92+
self._log_debug_info(f"Fetching forecast for location: {location_name}, hours: {number_of_hours}")
93+
url = f"{self.base_url}/locations/{location_name}/forecast/{number_of_hours}h"
94+
async with self.session.get(url) as response:
95+
return await response.json()
9096

9197
async def close(self):
9298
self._log_debug_info("Closing session")

custom_components/dwd_global_rad/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"iot_class": "cloud_polling",
1010
"requirements": [],
1111
"ssdp": [],
12-
"version": "0.3.2-beta",
12+
"version": "0.3.3-beta",
1313
"zeroconf": []
1414
}

custom_components/dwd_global_rad/restapi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ async def get(self, request, location_name, hours):
3030

3131
try:
3232
# location_name is automatically URL-decoded by HomeAssistantView
33-
location = api_client.get_location_by_name(location_name)
34-
forecast = location.get_forecast_for_future_hour(dt_now(), hours)
33+
34+
forecast = await api_client.get_forecast_for_future_hour(
35+
location_name, hours
36+
)
3537
except KeyError:
3638
return self.json({"error": "Location not found"}, status_code=404)
3739
except ValueError as e:

0 commit comments

Comments
 (0)