mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
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}
|
.hass=${this.hass}
|
||||||
.lovelaceConfig=${this._lovelaceConfig}
|
.lovelaceConfig=${this._lovelaceConfig}
|
||||||
.viewPath=${this._lovelacePath}
|
.viewPath=${this._lovelacePath}
|
||||||
|
@config-refresh=${this._generateLovelaceConfig}
|
||||||
></hc-lovelace>
|
></hc-lovelace>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@ -193,12 +194,7 @@ export class HcMain extends HassElement {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Generate a Lovelace config.
|
// Generate a Lovelace config.
|
||||||
this._unsubLovelace = () => undefined;
|
this._unsubLovelace = () => undefined;
|
||||||
const { generateLovelaceConfigFromHass } = await import(
|
await this._generateLovelaceConfig();
|
||||||
"../../../../src/panels/lovelace/common/generate-lovelace-config"
|
|
||||||
);
|
|
||||||
this._handleNewLovelaceConfig(
|
|
||||||
await generateLovelaceConfigFromHass(this.hass!)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!resourcesLoaded) {
|
if (!resourcesLoaded) {
|
||||||
@ -218,6 +214,15 @@ export class HcMain extends HassElement {
|
|||||||
this._sendStatus();
|
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) {
|
private _handleNewLovelaceConfig(lovelaceConfig: LovelaceConfig) {
|
||||||
castContext.setApplicationState(lovelaceConfig.title!);
|
castContext.setApplicationState(lovelaceConfig.title!);
|
||||||
this._lovelaceConfig = lovelaceConfig;
|
this._lovelaceConfig = lovelaceConfig;
|
||||||
|
@ -15,7 +15,7 @@ import { LovelaceCard } from "../types";
|
|||||||
import { LovelaceCardConfig } from "../../../data/lovelace";
|
import { LovelaceCardConfig } from "../../../data/lovelace";
|
||||||
import "@polymer/paper-spinner/paper-spinner-lite";
|
import "@polymer/paper-spinner/paper-spinner-lite";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
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")
|
@customElement("hui-starting-card")
|
||||||
export class HuiStartingCard extends LitElement implements LovelaceCard {
|
export class HuiStartingCard extends LitElement implements LovelaceCard {
|
||||||
@ -35,13 +35,7 @@ export class HuiStartingCard extends LitElement implements LovelaceCard {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldHass = changedProperties.get("hass") as HomeAssistant | undefined;
|
if (this.hass!.config.state !== STATE_NOT_RUNNING) {
|
||||||
|
|
||||||
if (
|
|
||||||
(!oldHass?.config || oldHass.config.state !== this.hass!.config.state) &&
|
|
||||||
(this.hass!.config.state === STATE_STARTING ||
|
|
||||||
this.hass!.config.state === STATE_RUNNING)
|
|
||||||
) {
|
|
||||||
fireEvent(this, "config-refresh");
|
fireEvent(this, "config-refresh");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import { loadLovelaceResources } from "./common/load-resources";
|
|||||||
import { showSaveDialog } from "./editor/show-save-config-dialog";
|
import { showSaveDialog } from "./editor/show-save-config-dialog";
|
||||||
import "./hui-root";
|
import "./hui-root";
|
||||||
import { Lovelace } from "./types";
|
import { Lovelace } from "./types";
|
||||||
import { STATE_NOT_RUNNING } from "home-assistant-js-websocket";
|
|
||||||
|
|
||||||
(window as any).loadCardHelpers = () => import("./custom-card-helpers");
|
(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
|
// reload lovelace on reconnect so we are sure we have the latest config
|
||||||
window.addEventListener("connection-status", (ev) => {
|
window.addEventListener("connection-status", (ev) => {
|
||||||
if (
|
if (ev.detail === "connected") {
|
||||||
ev.detail === "connected" &&
|
|
||||||
!(
|
|
||||||
this.lovelace?.mode === "generated" &&
|
|
||||||
this.hass!.config.state === STATE_NOT_RUNNING
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
this._fetchConfig(false);
|
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."
|
"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": {
|
"starting": {
|
||||||
"header": "Home Assistant is starting...",
|
"description": "Home Assistant is starting, please wait..."
|
||||||
"description": "Home Assistant is starting up, please wait."
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"unused_entities": {
|
"unused_entities": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user