From 542f169b360f700239628599cc390a5a95088269 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 29 Apr 2021 18:05:58 +0200 Subject: [PATCH] Fix saving Lovelace config (#9041) --- src/panels/lovelace/ha-panel-lovelace.ts | 15 +++++++++++++-- src/panels/lovelace/hui-editor.ts | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/panels/lovelace/ha-panel-lovelace.ts b/src/panels/lovelace/ha-panel-lovelace.ts index a499aa54e0..43aa5c8d45 100644 --- a/src/panels/lovelace/ha-panel-lovelace.ts +++ b/src/panels/lovelace/ha-panel-lovelace.ts @@ -363,11 +363,22 @@ class LovelacePanel extends LitElement { mode: previousMode, } = this.lovelace!; newConfig = this._checkLovelaceConfig(newConfig); + let conf: LovelaceConfig; + // If strategy defined, apply it here. + if (newConfig.strategy) { + conf = await generateLovelaceDashboardStrategy({ + config: newConfig, + hass: this.hass!, + narrow: this.narrow, + }); + } else { + conf = newConfig; + } try { // Optimistic update this._updateLovelace({ - config: newConfig, - rawConfig: undefined, + config: conf, + rawConfig: newConfig, mode: "storage", }); this._ignoreNextUpdateEvent = true; diff --git a/src/panels/lovelace/hui-editor.ts b/src/panels/lovelace/hui-editor.ts index eb0a8805e7..6e86102452 100644 --- a/src/panels/lovelace/hui-editor.ts +++ b/src/panels/lovelace/hui-editor.ts @@ -115,8 +115,8 @@ class LovelaceFullConfigEditor extends LitElement { !this._saving && oldLovelace && this.lovelace && - oldLovelace.config !== this.lovelace.config && - !deepEqual(oldLovelace.config, this.lovelace.config) + oldLovelace.rawConfig !== this.lovelace.rawConfig && + !deepEqual(oldLovelace.rawConfig, this.lovelace.rawConfig) ) { showToast(this, { message: this.hass!.localize( @@ -124,7 +124,7 @@ class LovelaceFullConfigEditor extends LitElement { ), action: { action: () => { - this.yamlEditor.value = safeDump(this.lovelace!.config); + this.yamlEditor.value = safeDump(this.lovelace!.rawConfig); }, text: this.hass!.localize( "ui.panel.lovelace.editor.raw_editor.reload"