Fixing error when Windy was not set correctly. (#95)

* Fixing error when Windy was not set correctly.

Fixed an issue when integration fails to send data to Windy and crashed,
so no data was accepted from station.
Windy resend is disabled on misconfiguration detect.

* Fixed WSLink bool in resend function.
fix/push_data_not_accepted
Lukas Svoboda 2026-02-23 18:31:25 +01:00 committed by GitHub
parent 55652415f4
commit 5ca0d65cd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 35 additions and 12 deletions

View File

@ -86,7 +86,7 @@ class WeatherDataUpdateCoordinator(DataUpdateCoordinator):
raise HTTPUnauthorized raise HTTPUnauthorized
if self.config_entry.options.get(WINDY_ENABLED): if self.config_entry.options.get(WINDY_ENABLED):
response = await self.windy.push_data_to_windy(data, _wslink) _ = await self.windy.push_data_to_windy(data, _wslink)
if self.config.options.get(POCASI_CZ_ENABLED): if self.config.options.get(POCASI_CZ_ENABLED):
await self.pocasi.push_data_to_server(data, "WSLINK" if _wslink else "WU") await self.pocasi.push_data_to_server(data, "WSLINK" if _wslink else "WU")

View File

@ -197,13 +197,19 @@ class ConfigOptionsFlowHandler(OptionsFlow):
errors=errors, errors=errors,
) )
if (user_input[WINDY_ENABLED] is True) and ((user_input[WINDY_STATION_ID] == "") or (user_input[WINDY_STATION_PW] == "")): station_id = (user_input.get(WINDY_STATION_ID) or "").strip()
errors[WINDY_STATION_ID] = "windy_key_required" station_pw = (user_input.get(WINDY_STATION_PW) or "").strip()
return self.async_show_form( if user_input.get(WINDY_ENABLED):
step_id="windy", if not station_id:
data_schema=vol.Schema(self.windy_data_schema), errors[WINDY_STATION_ID] = "windy_id_required"
errors=errors, if not station_pw:
) errors[WINDY_STATION_PW] = "windy_pw_required"
if errors:
return self.async_show_form(
step_id="windy",
data_schema=vol.Schema(self.windy_data_schema),
errors=errors,
)
# retain user_data # retain user_data
user_input.update(self.user_data) user_input.update(self.user_data)

View File

@ -29,7 +29,8 @@
"valid_credentials_api": "Vyplňte platné API ID", "valid_credentials_api": "Vyplňte platné API ID",
"valid_credentials_key": "Vyplňte platný API KEY", "valid_credentials_key": "Vyplňte platný API KEY",
"valid_credentials_match": "API ID a API KEY nesmějí být stejné!", "valid_credentials_match": "API ID a API KEY nesmějí být stejné!",
"windy_key_required": "Je vyžadován Windy API key, pokud chcete aktivovat přeposílání dat na Windy", "windy_id_required": "Je vyžadováno Windy ID, pokud chcete aktivovat přeposílání dat na Windy",
"windy_pw_required": "Je vyžadován Windy KEY, pokud chcete aktivovat přeposílání dat na Windy",
"pocasi_id_required": "Je vyžadován Počasí ID, pokud chcete aktivovat přeposílání dat na Počasí Meteo CZ", "pocasi_id_required": "Je vyžadován Počasí ID, pokud chcete aktivovat přeposílání dat na Počasí Meteo CZ",
"pocasi_key_required": "Klíč k účtu Počasí Meteo je povinný.", "pocasi_key_required": "Klíč k účtu Počasí Meteo je povinný.",
"pocasi_send_minimum": "Minimální interval pro přeposílání je 12 sekund." "pocasi_send_minimum": "Minimální interval pro přeposílání je 12 sekund."

View File

@ -29,7 +29,8 @@
"valid_credentials_api": "Provide valid API ID.", "valid_credentials_api": "Provide valid API ID.",
"valid_credentials_key": "Provide valid API KEY.", "valid_credentials_key": "Provide valid API KEY.",
"valid_credentials_match": "API ID and API KEY should not be the same.", "valid_credentials_match": "API ID and API KEY should not be the same.",
"windy_key_required": "Windy API key is required if you want to enable this function." "windy_id_required": "Windy API key is required if you want to enable this function.",
"windy_pw_required": "Windy API password is required if you want to enable this function."
}, },
"step": { "step": {
"init": { "init": {

View File

@ -5,6 +5,7 @@ import logging
from aiohttp.client_exceptions import ClientError from aiohttp.client_exceptions import ClientError
from homeassistant.components import persistent_notification
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -138,8 +139,22 @@ class WindyPush:
if "t1solrad" in purged_data: if "t1solrad" in purged_data:
purged_data["solarradiation"] = purged_data.pop("t1solrad") purged_data["solarradiation"] = purged_data.pop("t1solrad")
windy_station_id = self.config.options.get(WINDY_STATION_ID) windy_station_id = self.config.options.get(WINDY_STATION_ID, "")
windy_station_pw = self.config.options.get(WINDY_STATION_PW) windy_station_pw = self.config.options.get(WINDY_STATION_PW, "")
if windy_station_id == "" or windy_station_pw == "":
_LOGGER.error(
"Windy ID or PASSWORD is not set correctly. Please reconfigure your WINDY resend credentials. Disabling WINDY resend for now!"
)
persistent_notification.async_create(
self.hass,
"Your Windy credentials are not set correctly. Disabling Windy resending for now. Update Windy options and enable reseding.",
"Windy resending disabled.",
)
await update_options(self.hass, self.config, WINDY_ENABLED, False)
return False
request_url = f"{WINDY_URL}" request_url = f"{WINDY_URL}"