mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix refresh strategy config on HA start-up (#24984)
This commit is contained in:
parent
4fd87a1d7c
commit
c8e46bd239
@ -183,32 +183,46 @@ export class LovelacePanel extends LitElement {
|
|||||||
if (!changedProperties.has("hass")) {
|
if (!changedProperties.has("hass")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldHass = changedProperties.get("hass") as HomeAssistant | undefined;
|
const oldHass = changedProperties.get("hass") as HomeAssistant | undefined;
|
||||||
if (
|
if (
|
||||||
oldHass &&
|
oldHass &&
|
||||||
this.hass &&
|
this.hass &&
|
||||||
(oldHass.entities !== this.hass.entities ||
|
this.lovelace &&
|
||||||
|
isStrategyDashboard(this.lovelace.rawConfig)
|
||||||
|
) {
|
||||||
|
// If the entity registry changed, ask the user if they want to refresh the config
|
||||||
|
if (
|
||||||
|
oldHass.entities !== this.hass.entities ||
|
||||||
oldHass.devices !== this.hass.devices ||
|
oldHass.devices !== this.hass.devices ||
|
||||||
oldHass.areas !== this.hass.areas ||
|
oldHass.areas !== this.hass.areas ||
|
||||||
oldHass.floors !== this.hass.floors)
|
oldHass.floors !== this.hass.floors
|
||||||
) {
|
) {
|
||||||
this._registriesChanged();
|
if (this.hass.config.state === "RUNNING") {
|
||||||
|
this._askRefreshConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If ha started, refresh the config
|
||||||
|
if (
|
||||||
|
this.hass.config.state === "RUNNING" &&
|
||||||
|
oldHass.config.state !== "RUNNING"
|
||||||
|
) {
|
||||||
|
this._refreshConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _registriesChanged = () => {
|
private _askRefreshConfig = () => {
|
||||||
if (this.lovelace && isStrategyDashboard(this.lovelace.rawConfig)) {
|
showToast(this, {
|
||||||
showToast(this, {
|
message: this.hass!.localize("ui.panel.lovelace.changed_toast.message"),
|
||||||
message: this.hass!.localize("ui.panel.lovelace.changed_toast.message"),
|
action: {
|
||||||
action: {
|
action: () => this._refreshConfig(),
|
||||||
action: () => this._refreshConfig(),
|
text: this.hass!.localize("ui.common.refresh"),
|
||||||
text: this.hass!.localize("ui.common.refresh"),
|
},
|
||||||
},
|
duration: -1,
|
||||||
duration: -1,
|
id: "entity-registry-changed",
|
||||||
id: "entity-registry-changed",
|
dismissable: false,
|
||||||
dismissable: false,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private async _refreshConfig() {
|
private async _refreshConfig() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user