Retry subscribing to weather forecast if it fails (#24188)

This commit is contained in:
karwosts 2025-02-11 22:39:46 -08:00 committed by GitHub
parent ac88d5993a
commit 99065a689f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,6 +37,7 @@ import type {
LovelaceGridOptions,
} from "../types";
import type { WeatherForecastCardConfig } from "./types";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
@customElement("hui-weather-forecast-card")
class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
@ -106,7 +107,9 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
!this.isConnected ||
!this.hass ||
!this._config ||
!this._needForecastSubscription()
!this._needForecastSubscription() ||
!isComponentLoaded(this.hass, "weather") ||
!this.hass.states[this._config!.entity]
) {
return;
}
@ -118,7 +121,14 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
(event) => {
this._forecastEvent = event;
}
);
).catch((e) => {
if (e.code === "invalid_entity_id") {
setTimeout(() => {
this._subscribed = undefined;
}, 2000);
}
throw e;
});
}
public connectedCallback(): void {