From 0536db18796b9001815937fea7429fb6b517bdd7 Mon Sep 17 00:00:00 2001 From: Marco Gosselink Date: Wed, 20 Sep 2023 06:56:41 +0200 Subject: [PATCH] Added chance of rain --- .gitignore | 2 +- custom_components/gfs_weather_forecast/const.py | 2 +- .../gfs_weather_forecast/manifest.json | 2 +- .../gfs_weather_forecast/weather.py | 16 +++++++++------- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 3214958..57fdaa4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -/.DS_Store +.DS_Store /.venv \ No newline at end of file diff --git a/custom_components/gfs_weather_forecast/const.py b/custom_components/gfs_weather_forecast/const.py index c2d1dbe..7895b39 100644 --- a/custom_components/gfs_weather_forecast/const.py +++ b/custom_components/gfs_weather_forecast/const.py @@ -9,7 +9,7 @@ # Platforms WEATHER = "weather" -DEFAULT_SYNC_INTERVAL = 30 # seconds +DEFAULT_SYNC_INTERVAL = 15 # seconds CONF_API_PORT = 8000 diff --git a/custom_components/gfs_weather_forecast/manifest.json b/custom_components/gfs_weather_forecast/manifest.json index 6f65dc6..b3c06df 100644 --- a/custom_components/gfs_weather_forecast/manifest.json +++ b/custom_components/gfs_weather_forecast/manifest.json @@ -1,7 +1,7 @@ { "domain": "gfs_weather_forecast", "name": "GFS Weather Forecast", - "version": "0.0.1", + "version": "1.0.2", "config_flow": true, "documentation": "https://github.com/MarcoGos/gfs_weather_forecast", "requirements": [], diff --git a/custom_components/gfs_weather_forecast/weather.py b/custom_components/gfs_weather_forecast/weather.py index 5035144..eec0456 100644 --- a/custom_components/gfs_weather_forecast/weather.py +++ b/custom_components/gfs_weather_forecast/weather.py @@ -22,6 +22,7 @@ ATTR_CONDITION_SUNNY, ATTR_FORECAST_CONDITION, ATTR_FORECAST_NATIVE_PRECIPITATION, + ATTR_FORECAST_PRECIPITATION_PROBABILITY, ATTR_FORECAST_NATIVE_TEMP, ATTR_FORECAST_NATIVE_TEMP_LOW, ATTR_FORECAST_NATIVE_WIND_SPEED, @@ -97,13 +98,13 @@ def _get_forecast(self) -> list[Forecast] | None: forecast_date = datetime.fromisoformat(key).date() if forecast_date > datetime.today().date(): chance_of_sun = forecast_data[key].get('chance_of_sun') - rain = forecast_data[key].get('rain') - min_temperature_daytime = forecast_data[key].get('min_temperature_daytime') - temperature_min = round(forecast_data[key].get('temperature_min')) - temperature_max = round(forecast_data[key].get('temperature_max')) - rain = forecast_data[key].get('rain') - windangle = forecast_data[key].get('windangle') - windspeed = forecast_data[key].get('windspeed') + min_temperature_daytime = forecast_data[key].get('min_temperature_daytime', -999) + temperature_min = round(forecast_data[key].get('temperature_min', -999)) + temperature_max = round(forecast_data[key].get('temperature_max', -999)) + rain = forecast_data[key].get('rain', 0) + chance_of_rain = forecast_data[key].get('chance_of_rain', 0) + windangle = forecast_data[key].get('windangle', 0) + windspeed = forecast_data[key].get('windspeed', 0) if temperature_max > -999 and temperature_min > -999: next_day = { ATTR_FORECAST_TIME: key, @@ -112,6 +113,7 @@ def _get_forecast(self) -> list[Forecast] | None: ATTR_FORECAST_NATIVE_TEMP_LOW: temperature_min, ATTR_FORECAST_NATIVE_TEMP: temperature_max, ATTR_FORECAST_NATIVE_PRECIPITATION: rain, + ATTR_FORECAST_PRECIPITATION_PROBABILITY: chance_of_rain, ATTR_FORECAST_WIND_BEARING: windangle, ATTR_FORECAST_NATIVE_WIND_SPEED: windspeed }