From d570d063c7ca2dba65dd5ee1d07ddf3c12cbf7c4 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 6 Feb 2023 22:37:05 +0100 Subject: [PATCH] Optionally update sensor units when unit system changes (#15287) Co-authored-by: Bram Kragten --- .../config/core/ha-config-section-general.ts | 67 +++++++++++++++++-- src/translations/en.json | 9 ++- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/src/panels/config/core/ha-config-section-general.ts b/src/panels/config/core/ha-config-section-general.ts index 900b5ccdac..31abfd8346 100644 --- a/src/panels/config/core/ha-config-section-general.ts +++ b/src/panels/config/core/ha-config-section-general.ts @@ -26,6 +26,9 @@ import "../../../layouts/hass-subpage"; import { haStyle } from "../../../resources/styles"; import type { HomeAssistant } from "../../../types"; import "../../../components/ha-alert"; +import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box"; +import type { HaCheckbox } from "../../../components/ha-checkbox"; +import "../../../components/ha-checkbox"; @customElement("ha-config-section-general") class HaConfigSectionGeneral extends LitElement { @@ -55,6 +58,8 @@ class HaConfigSectionGeneral extends LitElement { @state() private _error?: string; + @state() private _updateUnits?: boolean; + protected render(): TemplateResult { const canEdit = ["storage", "default"].includes( this.hass.config.config_source @@ -174,6 +179,32 @@ class HaConfigSectionGeneral extends LitElement { .disabled=${this._submitting} > + ${this._unitSystem !== this._configuredUnitSystem() + ? html` + + + +
+ ${this.hass.localize( + "ui.panel.config.core.section.core.core_config.update_units_text_1" + )} + ${this.hass.localize( + "ui.panel.config.core.section.core.core_config.update_units_text_2" + )}

+ ${this.hass.localize( + "ui.panel.config.core.section.core.core_config.update_units_text_3" + )} +
+ ` + : ""}