diff --git a/dwd_global_rad_api_server/app.py b/dwd_global_rad_api_server/app.py index ad9948d..6afd143 100644 --- a/dwd_global_rad_api_server/app.py +++ b/dwd_global_rad_api_server/app.py @@ -6,6 +6,7 @@ import main import logging import dwd_global_radiation as dgr +from datetime import datetime, timezone app = Flask(__name__) @@ -29,6 +30,24 @@ def format(self, record): app.logger.propagate = False +@app.route('/locations//forecast/h', methods=['GET']) +def get_forecast_for_future_hour(name, number_of_hours): + try: + # Get the current datetime + datetime_input = datetime.now(timezone.utc) + + # Get the location + location = objGlobalRadiation.get_location_by_name(name) + if not location: + return jsonify({'error': 'Location not found'}), 404 + + # Get the forecast for the specified future hour + forecast = location.get_forecast_for_future_hour(datetime_input, number_of_hours) + return jsonify(forecast) + except Exception as e: + app.logger.error(f"Error fetching forecast for future hour: {e}") + return jsonify({'error': str(e)}), 500 + @app.route('/process', methods=['POST']) def process(): try: diff --git a/dwd_global_rad_api_server/config.yaml b/dwd_global_rad_api_server/config.yaml index 4966934..e19e5da 100644 --- a/dwd_global_rad_api_server/config.yaml +++ b/dwd_global_rad_api_server/config.yaml @@ -1,6 +1,6 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config name: DWD Global Rad Api Server -version: "1.4.7" +version: "1.4.8" slug: dwd_global_rad_api_server description: DWD Global Rad Api Server arch: