diff --git a/src/panels/config/core/ha-config-section-general.ts b/src/panels/config/core/ha-config-section-general.ts index f3857b1bb7..635c455d79 100644 --- a/src/panels/config/core/ha-config-section-general.ts +++ b/src/panels/config/core/ha-config-section-general.ts @@ -25,6 +25,7 @@ import { SYMBOL_TO_ISO } from "../../../data/currency"; import "../../../layouts/hass-subpage"; import { haStyle } from "../../../resources/styles"; import type { HomeAssistant } from "../../../types"; +import "../../../components/ha-alert"; @customElement("ha-config-section-general") class HaConfigSectionGeneral extends LitElement { @@ -52,6 +53,8 @@ class HaConfigSectionGeneral extends LitElement { @state() private _languages?: { value: string; label: string }[]; + @state() private _error?: string; + protected render(): TemplateResult { const canEdit = ["storage", "default"].includes( this.hass.config.config_source @@ -65,6 +68,9 @@ class HaConfigSectionGeneral extends LitElement { .header=${this.hass.localize("ui.panel.config.core.caption")} >
+ ${this._error + ? html`${this._error}` + : ""}
${!canEdit @@ -289,7 +295,7 @@ class HaConfigSectionGeneral extends LitElement { this._country = this.hass.config.country; this._language = this.hass.config.language; this._elevation = this.hass.config.elevation; - this._timeZone = this.hass.config.time_zone; + this._timeZone = this.hass.config.time_zone || "Etc/GMT"; this._name = this.hass.config.location_name; this._computeLanguages(); } @@ -347,6 +353,8 @@ class HaConfigSectionGeneral extends LitElement { }; } + this._error = undefined; + try { await saveCoreConfig(this.hass, { currency: this._currency, @@ -361,7 +369,7 @@ class HaConfigSectionGeneral extends LitElement { button.actionSuccess(); } catch (err: any) { button.actionError(); - alert(`Error saving config: ${err.message}`); + this._error = err.message; } finally { button.progress = false; }