mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
Retry subscribing to weather forecast if it fails (#24188)
This commit is contained in:
parent
ac88d5993a
commit
99065a689f
@ -37,6 +37,7 @@ import type {
|
|||||||
LovelaceGridOptions,
|
LovelaceGridOptions,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import type { WeatherForecastCardConfig } from "./types";
|
import type { WeatherForecastCardConfig } from "./types";
|
||||||
|
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||||
|
|
||||||
@customElement("hui-weather-forecast-card")
|
@customElement("hui-weather-forecast-card")
|
||||||
class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
||||||
@ -106,7 +107,9 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
!this.isConnected ||
|
!this.isConnected ||
|
||||||
!this.hass ||
|
!this.hass ||
|
||||||
!this._config ||
|
!this._config ||
|
||||||
!this._needForecastSubscription()
|
!this._needForecastSubscription() ||
|
||||||
|
!isComponentLoaded(this.hass, "weather") ||
|
||||||
|
!this.hass.states[this._config!.entity]
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -118,7 +121,14 @@ class HuiWeatherForecastCard extends LitElement implements LovelaceCard {
|
|||||||
(event) => {
|
(event) => {
|
||||||
this._forecastEvent = event;
|
this._forecastEvent = event;
|
||||||
}
|
}
|
||||||
);
|
).catch((e) => {
|
||||||
|
if (e.code === "invalid_entity_id") {
|
||||||
|
setTimeout(() => {
|
||||||
|
this._subscribed = undefined;
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public connectedCallback(): void {
|
public connectedCallback(): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user