Fix refresh when starting with generated on cast (#6072)
This commit is contained in:
parent
6a9a4cf65f
commit
e1df50ad3b
|
@ -82,6 +82,7 @@ export class HcMain extends HassElement {
|
|||
.hass=${this.hass}
|
||||
.lovelaceConfig=${this._lovelaceConfig}
|
||||
.viewPath=${this._lovelacePath}
|
||||
@config-refresh=${this._generateLovelaceConfig}
|
||||
></hc-lovelace>
|
||||
`;
|
||||
}
|
||||
|
@ -193,12 +194,7 @@ export class HcMain extends HassElement {
|
|||
} catch (err) {
|
||||
// Generate a Lovelace config.
|
||||
this._unsubLovelace = () => undefined;
|
||||
const { generateLovelaceConfigFromHass } = await import(
|
||||
"../../../../src/panels/lovelace/common/generate-lovelace-config"
|
||||
);
|
||||
this._handleNewLovelaceConfig(
|
||||
await generateLovelaceConfigFromHass(this.hass!)
|
||||
);
|
||||
await this._generateLovelaceConfig();
|
||||
}
|
||||
}
|
||||
if (!resourcesLoaded) {
|
||||
|
@ -218,6 +214,15 @@ export class HcMain extends HassElement {
|
|||
this._sendStatus();
|
||||
}
|
||||
|
||||
private async _generateLovelaceConfig() {
|
||||
const { generateLovelaceConfigFromHass } = await import(
|
||||
"../../../../src/panels/lovelace/common/generate-lovelace-config"
|
||||
);
|
||||
this._handleNewLovelaceConfig(
|
||||
await generateLovelaceConfigFromHass(this.hass!)
|
||||
);
|
||||
}
|
||||
|
||||
private _handleNewLovelaceConfig(lovelaceConfig: LovelaceConfig) {
|
||||
castContext.setApplicationState(lovelaceConfig.title!);
|
||||
this._lovelaceConfig = lovelaceConfig;
|
||||
|
|
|
@ -15,7 +15,7 @@ import { LovelaceCard } from "../types";
|
|||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||
import "@polymer/paper-spinner/paper-spinner-lite";
|
||||
import { fireEvent } from "../../../common/dom/fire_event";
|
||||
import { STATE_STARTING, STATE_RUNNING } from "home-assistant-js-websocket";
|
||||
import { STATE_NOT_RUNNING } from "home-assistant-js-websocket";
|
||||
|
||||
@customElement("hui-starting-card")
|
||||
export class HuiStartingCard extends LitElement implements LovelaceCard {
|
||||
|
@ -35,13 +35,7 @@ export class HuiStartingCard extends LitElement implements LovelaceCard {
|
|||
return;
|
||||
}
|
||||
|
||||
const oldHass = changedProperties.get("hass") as HomeAssistant | undefined;
|
||||
|
||||
if (
|
||||
(!oldHass?.config || oldHass.config.state !== this.hass!.config.state) &&
|
||||
(this.hass!.config.state === STATE_STARTING ||
|
||||
this.hass!.config.state === STATE_RUNNING)
|
||||
) {
|
||||
if (this.hass!.config.state !== STATE_NOT_RUNNING) {
|
||||
fireEvent(this, "config-refresh");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import { loadLovelaceResources } from "./common/load-resources";
|
|||
import { showSaveDialog } from "./editor/show-save-config-dialog";
|
||||
import "./hui-root";
|
||||
import { Lovelace } from "./types";
|
||||
import { STATE_NOT_RUNNING } from "home-assistant-js-websocket";
|
||||
|
||||
(window as any).loadCardHelpers = () => import("./custom-card-helpers");
|
||||
|
||||
|
@ -170,13 +169,7 @@ class LovelacePanel extends LitElement {
|
|||
}
|
||||
// reload lovelace on reconnect so we are sure we have the latest config
|
||||
window.addEventListener("connection-status", (ev) => {
|
||||
if (
|
||||
ev.detail === "connected" &&
|
||||
!(
|
||||
this.lovelace?.mode === "generated" &&
|
||||
this.hass!.config.state === STATE_NOT_RUNNING
|
||||
)
|
||||
) {
|
||||
if (ev.detail === "connected") {
|
||||
this._fetchConfig(false);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1683,8 +1683,7 @@
|
|||
"description": "Home Assistant ran into trouble while loading your configuration and is now running in safe mode. Take a look at the error log to see what went wrong."
|
||||
},
|
||||
"starting": {
|
||||
"header": "Home Assistant is starting...",
|
||||
"description": "Home Assistant is starting up, please wait."
|
||||
"description": "Home Assistant is starting, please wait..."
|
||||
}
|
||||
},
|
||||
"unused_entities": {
|
||||
|
|
Loading…
Reference in New Issue