From 5e431a07ad7e7cf176ffaea6441fdd20dd3c3a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Thu, 8 Sep 2022 02:59:08 +0200 Subject: [PATCH 01/23] Guard more of the hardware panel (#13650) --- .../config/hardware/ha-config-hardware.ts | 98 ++++++++++--------- 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/src/panels/config/hardware/ha-config-hardware.ts b/src/panels/config/hardware/ha-config-hardware.ts index 3e19697d1e..2d225bca1c 100644 --- a/src/panels/config/hardware/ha-config-hardware.ts +++ b/src/panels/config/hardware/ha-config-hardware.ts @@ -80,29 +80,31 @@ class HaConfigHardware extends SubscribeMixin(LitElement) { private _cpuEntries: { x: number; y: number | null }[] = []; public hassSubscribe() { - return [ - this.hass.connection.subscribeMessage( - (message) => { - // Only store the last 60 entries - this._memoryEntries.shift(); - this._cpuEntries.shift(); + return isComponentLoaded(this.hass, "hardware") + ? [ + this.hass.connection.subscribeMessage( + (message) => { + // Only store the last 60 entries + this._memoryEntries.shift(); + this._cpuEntries.shift(); - this._memoryEntries.push({ - x: new Date(message.timestamp).getTime(), - y: message.memory_used_percent, - }); - this._cpuEntries.push({ - x: new Date(message.timestamp).getTime(), - y: message.cpu_percent, - }); + this._memoryEntries.push({ + x: new Date(message.timestamp).getTime(), + y: message.memory_used_percent, + }); + this._cpuEntries.push({ + x: new Date(message.timestamp).getTime(), + y: message.cpu_percent, + }); - this._systemStatusData = message; - }, - { - type: "hardware/subscribe_system_status", - } - ), - ]; + this._systemStatusData = message; + }, + { + type: "hardware/subscribe_system_status", + } + ), + ] + : []; } protected willUpdate(): void { @@ -198,32 +200,34 @@ class HaConfigHardware extends SubscribeMixin(LitElement) { .narrow=${this.narrow} .header=${this.hass.localize("ui.panel.config.hardware.caption")} > - - - ${this.hass.localize( - "ui.panel.config.hardware.available_hardware.title" - )} - ${this._hostData - ? html` - ${this.hass.localize( - "ui.panel.config.hardware.reboot_host" - )} - ${this.hass.localize( - "ui.panel.config.hardware.shutdown_host" - )} - ` - : ""} - + ${isComponentLoaded(this.hass, "hassio") + ? html` + + ${this.hass.localize( + "ui.panel.config.hardware.available_hardware.title" + )} + ${this._hostData + ? html` + ${this.hass.localize( + "ui.panel.config.hardware.reboot_host" + )} + ${this.hass.localize( + "ui.panel.config.hardware.shutdown_host" + )} + ` + : ""} + ` + : ""} ${this._error ? html` Date: Thu, 8 Sep 2022 12:00:52 +0200 Subject: [PATCH 02/23] Move automation trace actions to overflow menu (#13656) --- .../config/automation/ha-automation-trace.ts | 88 +++++++++++++++---- src/panels/config/script/ha-script-trace.ts | 87 ++++++++++++++---- 2 files changed, 140 insertions(+), 35 deletions(-) diff --git a/src/panels/config/automation/ha-automation-trace.ts b/src/panels/config/automation/ha-automation-trace.ts index b2884f064f..31f795f801 100644 --- a/src/panels/config/automation/ha-automation-trace.ts +++ b/src/panels/config/automation/ha-automation-trace.ts @@ -1,5 +1,8 @@ import { + mdiDotsVertical, mdiDownload, + mdiInformationOutline, + mdiPencil, mdiRayEndArrow, mdiRayStartArrow, mdiRefresh, @@ -10,6 +13,8 @@ import { classMap } from "lit/directives/class-map"; import { repeat } from "lit/directives/repeat"; import { isComponentLoaded } from "../../../common/config/is_component_loaded"; import { formatDateTimeWithSeconds } from "../../../common/datetime/format_date_time"; +import { fireEvent } from "../../../common/dom/fire_event"; +import "../../../components/ha-button-menu"; import "../../../components/ha-icon-button"; import "../../../components/trace/ha-trace-blueprint-config"; import "../../../components/trace/ha-trace-config"; @@ -31,9 +36,9 @@ import { loadTraces, } from "../../../data/trace"; import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box"; +import "../../../layouts/hass-subpage"; import { haStyle } from "../../../resources/styles"; import { HomeAssistant, Route } from "../../../types"; -import "../../../layouts/hass-subpage"; @customElement("ha-automation-trace") export class HaAutomationTrace extends LitElement { @@ -107,23 +112,63 @@ export class HaAutomationTrace extends LitElement { ` : ""} - - + + + + + ${this.hass.localize("ui.panel.config.automation.editor.show_info")} + + + + ${stateObj?.attributes.id && this.narrow + ? html` + + + ${this.hass.localize( + "ui.panel.config.automation.trace.edit_automation" + )} + + + + ` + : ""} + +
  • + + + ${this.hass.localize("ui.panel.config.automation.trace.refresh")} + + + + + ${this.hass.localize( + "ui.panel.config.automation.trace.download_trace" + )} + + +
    +
    ${this._traces && this._traces.length > 0 ? html` @@ -443,6 +488,13 @@ export class HaAutomationTrace extends LitElement { } } + private _showInfo() { + if (!this.hass || !this._entityId) { + return; + } + fireEvent(this, "hass-more-info", { entityId: this._entityId }); + } + static get styles(): CSSResultGroup { return [ haStyle, diff --git a/src/panels/config/script/ha-script-trace.ts b/src/panels/config/script/ha-script-trace.ts index e0ba6c6d33..ab35977cb1 100644 --- a/src/panels/config/script/ha-script-trace.ts +++ b/src/panels/config/script/ha-script-trace.ts @@ -1,5 +1,8 @@ import { + mdiDotsVertical, mdiDownload, + mdiInformationOutline, + mdiPencil, mdiRayEndArrow, mdiRayStartArrow, mdiRefresh, @@ -34,6 +37,8 @@ import { showAlertDialog } from "../../../dialogs/generic/show-dialog-box"; import { haStyle } from "../../../resources/styles"; import { HomeAssistant, Route } from "../../../types"; import "../../../layouts/hass-subpage"; +import "../../../components/ha-button-menu"; +import { fireEvent } from "../../../common/dom/fire_event"; @customElement("ha-script-trace") export class HaScriptTrace extends LitElement { @@ -105,23 +110,64 @@ export class HaScriptTrace extends LitElement { ` : ""} - - + + + + + + ${this.hass.localize("ui.panel.config.script.editor.show_info")} + + + + ${this.narrow && this.scriptEntityId + ? html` + + + ${this.hass.localize( + "ui.panel.config.script.trace.edit_script" + )} + + + + ` + : ""} + +
  • + + + ${this.hass.localize("ui.panel.config.automation.trace.refresh")} + + + + + ${this.hass.localize( + "ui.panel.config.automation.trace.download_trace" + )} + + +
    +
    ${this._traces && this._traces.length > 0 ? html` @@ -429,6 +475,13 @@ export class HaScriptTrace extends LitElement { } } + private async _showInfo() { + if (!this.scriptEntityId) { + return; + } + fireEvent(this, "hass-more-info", { entityId: this.scriptEntityId }); + } + static get styles(): CSSResultGroup { return [ haStyle, From 330f3e5ce48f179f86f0107aa596c4d97f2da032 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 8 Sep 2022 17:43:36 +0200 Subject: [PATCH 03/23] use input instead of change (#13660) --- .../automation-rename-dialog/dialog-automation-rename.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panels/config/automation/automation-rename-dialog/dialog-automation-rename.ts b/src/panels/config/automation/automation-rename-dialog/dialog-automation-rename.ts index e97976e3f7..8dcf1e4219 100644 --- a/src/panels/config/automation/automation-rename-dialog/dialog-automation-rename.ts +++ b/src/panels/config/automation/automation-rename-dialog/dialog-automation-rename.ts @@ -79,7 +79,7 @@ class DialogAutomationRename extends LitElement implements HassDialog { )} required type="string" - @change=${this._valueChanged} + @input=${this._valueChanged} > From e95d5b1afb03bbdcc60d06363331bf318b1e6737 Mon Sep 17 00:00:00 2001 From: krazos Date: Mon, 12 Sep 2022 05:57:53 -0400 Subject: [PATCH 04/23] Eliminate redundant "for" in trigger description (#13669) --- src/data/automation_i18n.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index 1c7e8a1537..93a6970cc9 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -143,11 +143,11 @@ export const describeTrigger = ( if ("for" in trigger) { let duration: string; if (typeof trigger.for === "number") { - duration = `for ${secondsToDuration(trigger.for)!}`; + duration = `${secondsToDuration(trigger.for)!}`; } else if (typeof trigger.for === "string") { - duration = `for ${trigger.for}`; + duration = `${trigger.for}`; } else { - duration = `for ${JSON.stringify(trigger.for)}`; + duration = `${JSON.stringify(trigger.for)}`; } base += ` for ${duration}`; From 432483b3d288c604a645bac6f930f7806fdc0fb7 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Mon, 12 Sep 2022 07:22:49 -0300 Subject: [PATCH 05/23] Use newspaper icon for change log button (#13668) --- src/panels/config/info/ha-config-info.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panels/config/info/ha-config-info.ts b/src/panels/config/info/ha-config-info.ts index 3c87a70dd7..bb4634a000 100644 --- a/src/panels/config/info/ha-config-info.ts +++ b/src/panels/config/info/ha-config-info.ts @@ -5,7 +5,7 @@ import { mdiHandsPray, mdiHelp, mdiHomeAssistant, - mdiPower, + mdiNewspaperVariant, mdiTshirtCrew, } from "@mdi/js"; import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; @@ -36,7 +36,7 @@ const PAGES: Array<{ { name: "change_log", path: "/latest-release-notes/", - iconPath: mdiPower, + iconPath: mdiNewspaperVariant, iconColor: "#4A5963", }, { From 032f497687280636bb75b637f01f294c5048ff39 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 12 Sep 2022 15:53:18 +0200 Subject: [PATCH 06/23] Fix empty value for state picker (#13699) --- .../entity/ha-entity-state-picker.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/entity/ha-entity-state-picker.ts b/src/components/entity/ha-entity-state-picker.ts index 21f83ae948..98b5640b67 100644 --- a/src/components/entity/ha-entity-state-picker.ts +++ b/src/components/entity/ha-entity-state-picker.ts @@ -8,6 +8,7 @@ import { HomeAssistant } from "../../types"; import "../ha-combo-box"; import type { HaComboBox } from "../ha-combo-box"; import { formatAttributeValue } from "../../data/entity_attributes"; +import { fireEvent } from "../../common/dom/fire_event"; export type HaEntityPickerEntityFilterFunc = (entityId: HassEntity) => boolean; @@ -70,7 +71,7 @@ class HaEntityStatePicker extends LitElement { return html` ) { this._opened = ev.detail.value; } private _valueChanged(ev: PolymerChangedEvent) { - this.value = ev.detail.value; + ev.stopPropagation(); + const newValue = ev.detail.value; + if (newValue !== this._value) { + this._setValue(newValue); + } + } + + private _setValue(value: string) { + this.value = value; + setTimeout(() => { + fireEvent(this, "value-changed", { value }); + fireEvent(this, "change"); + }, 0); } } From cfabaa8716a9ea966cf2018b9ed09293fac8640d Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Mon, 12 Sep 2022 15:55:03 +0200 Subject: [PATCH 07/23] Display entity friendly name for disabled entities (#13696) --- src/data/entity_registry.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/data/entity_registry.ts b/src/data/entity_registry.ts index 81a430dce4..78da19f6f2 100644 --- a/src/data/entity_registry.ts +++ b/src/data/entity_registry.ts @@ -93,7 +93,10 @@ export const computeEntityRegistryName = ( return entry.name; } const state = hass.states[entry.entity_id]; - return state ? computeStateName(state) : entry.entity_id; + if (state) { + return computeStateName(state); + } + return entry.original_name ? entry.original_name : entry.entity_id; }; export const getExtendedEntityRegistryEntry = ( From f7253a73a5d387569cc50869659e5a805a37e38a Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 12 Sep 2022 18:04:07 +0200 Subject: [PATCH 08/23] Fix script config editor (#13703) --- src/panels/config/script/ha-script-editor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index 2eea1afc6f..004547ea28 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -609,13 +609,13 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { switch (key) { case "id": this._idChanged(value); - return; + break; case "alias": this._aliasChanged(value); break; case "mode": this._modeChanged(value); - return; + break; } if (values[key] === undefined) { From 3cf14bb2e1608b48b280b22cff2bac3b164032ac Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Tue, 13 Sep 2022 10:40:18 +0200 Subject: [PATCH 09/23] Revert "Either show range or fix target temperature... #13638 (#13706) --- src/dialogs/more-info/controls/more-info-climate.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/dialogs/more-info/controls/more-info-climate.ts b/src/dialogs/more-info/controls/more-info-climate.ts index 1715a94703..2a66080055 100644 --- a/src/dialogs/more-info/controls/more-info-climate.ts +++ b/src/dialogs/more-info/controls/more-info-climate.ts @@ -98,9 +98,7 @@ class MoreInfoClimate extends LitElement {
    ` : ""} - ${supportTargetTemperature && - !supportTargetTemperatureRange && - stateObj.attributes.temperature !== undefined && + ${stateObj.attributes.temperature !== undefined && stateObj.attributes.temperature !== null ? html` ` : ""} - ${supportTargetTemperatureRange && - ((stateObj.attributes.target_temp_low !== undefined && + ${(stateObj.attributes.target_temp_low !== undefined && stateObj.attributes.target_temp_low !== null) || - (stateObj.attributes.target_temp_high !== undefined && - stateObj.attributes.target_temp_high !== null)) + (stateObj.attributes.target_temp_high !== undefined && + stateObj.attributes.target_temp_high !== null) ? html` Date: Tue, 13 Sep 2022 10:40:48 +0200 Subject: [PATCH 10/23] Fix customizing sensor unit (#13710) --- src/panels/config/entities/entity-registry-settings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/config/entities/entity-registry-settings.ts b/src/panels/config/entities/entity-registry-settings.ts index da15534590..8ae1e84046 100644 --- a/src/panels/config/entities/entity-registry-settings.ts +++ b/src/panels/config/entities/entity-registry-settings.ts @@ -900,7 +900,7 @@ export class EntityRegistrySettings extends SubscribeMixin(LitElement) { params.hidden_by = this._hiddenBy; } if ( - (domain === "number" || domain === "number") && + (domain === "number" || domain === "sensor") && stateObj?.attributes?.unit_of_measurement !== this._unit_of_measurement ) { params.options_domain = domain; From 749d869e033a0cafeaa37b2d8e0657c9c6bfce39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Tue, 13 Sep 2022 10:41:19 +0200 Subject: [PATCH 11/23] Guard repairs subscription (#13708) --- src/components/ha-sidebar.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/ha-sidebar.ts b/src/components/ha-sidebar.ts index 3425cb35d4..30c4959335 100644 --- a/src/components/ha-sidebar.ts +++ b/src/components/ha-sidebar.ts @@ -221,13 +221,15 @@ class HaSidebar extends SubscribeMixin(LitElement) { private _sortable?: SortableInstance; public hassSubscribe(): UnsubscribeFunc[] { - return [ - subscribeRepairsIssueRegistry(this.hass.connection!, (repairs) => { - this._issuesCount = repairs.issues.filter( - (issue) => !issue.ignored - ).length; - }), - ]; + return this.hass.user?.is_admin + ? [ + subscribeRepairsIssueRegistry(this.hass.connection!, (repairs) => { + this._issuesCount = repairs.issues.filter( + (issue) => !issue.ignored + ).length; + }), + ] + : []; } protected render() { From d78191efa6e7b869bb82115549a88ed6effb87b3 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 13 Sep 2022 10:42:15 +0200 Subject: [PATCH 12/23] Fix rtl support for hass subpage layout (#13702) --- src/layouts/hass-subpage.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/layouts/hass-subpage.ts b/src/layouts/hass-subpage.ts index 10859151c8..2dd0979543 100644 --- a/src/layouts/hass-subpage.ts +++ b/src/layouts/hass-subpage.ts @@ -1,6 +1,15 @@ -import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; +import { + css, + CSSResultGroup, + html, + LitElement, + PropertyValues, + TemplateResult, +} from "lit"; import { customElement, eventOptions, property } from "lit/decorators"; import { restoreScroll } from "../common/decorators/restore-scroll"; +import { toggleAttribute } from "../common/dom/toggle_attribute"; +import { computeRTL } from "../common/util/compute_rtl"; import "../components/ha-icon-button-arrow-prev"; import "../components/ha-menu-button"; import { HomeAssistant } from "../types"; @@ -24,6 +33,14 @@ class HassSubpage extends LitElement { // @ts-ignore @restoreScroll(".content") private _savedScrollPos?: number; + protected willUpdate(changedProps: PropertyValues): void { + const oldHass = changedProps.get("hass") as HomeAssistant | undefined; + if (!oldHass || oldHass.locale !== this.hass.locale) { + toggleAttribute(this, "rtl", computeRTL(this.hass)); + } + super.willUpdate(changedProps); + } + protected render(): TemplateResult { return html`
    From 8f6a09f44c51ca753ba9eec14433e57232401ced Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 13 Sep 2022 10:43:38 +0200 Subject: [PATCH 13/23] Don't use selector inside choose action (#13705) --- .../action/types/ha-automation-action-choose.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/panels/config/automation/action/types/ha-automation-action-choose.ts b/src/panels/config/automation/action/types/ha-automation-action-choose.ts index 67a70e4304..4ab8dd1538 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-choose.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-choose.ts @@ -9,7 +9,6 @@ import { Action, ChooseAction } from "../../../../../data/script"; import { haStyle } from "../../../../../resources/styles"; import { HomeAssistant } from "../../../../../types"; import { ActionElement } from "../ha-automation-action-row"; -import "../../../../../components/ha-form/ha-form"; @customElement("ha-automation-action-choose") export class HaChooseAction extends LitElement implements ActionElement { @@ -64,13 +63,13 @@ export class HaChooseAction extends LitElement implements ActionElement { "ui.panel.config.automation.editor.actions.type.choose.sequence" )}: - + >
    ` )} @@ -126,7 +125,7 @@ export class HaChooseAction extends LitElement implements ActionElement { private _actionChanged(ev: CustomEvent) { ev.stopPropagation(); - const value = ev.detail.value.sequence as Action[]; + const value = ev.detail.value as Action[]; const index = (ev.target as any).idx; const choose = this.action.choose ? [...ensureArray(this.action.choose)] @@ -185,9 +184,6 @@ export class HaChooseAction extends LitElement implements ActionElement { right: 0; padding: 4px; } - ha-form::part(root) { - overflow: visible; - } ha-svg-icon { height: 20px; } From 3a17f2d73ed65bde80dfa3c68e1574e33d3b2e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Tue, 13 Sep 2022 19:58:32 +0200 Subject: [PATCH 14/23] Fix open config flow when coming from a my link (#13720) --- .../integrations/ha-config-integrations.ts | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/panels/config/integrations/ha-config-integrations.ts b/src/panels/config/integrations/ha-config-integrations.ts index 82ce8bf60f..765627cec0 100644 --- a/src/panels/config/integrations/ha-config-integrations.ts +++ b/src/panels/config/integrations/ha-config-integrations.ts @@ -689,22 +689,22 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) { if (handlers.includes(domain)) { const localize = await localizePromise; if ( - !(await showConfirmationDialog(this, { + await showConfirmationDialog(this, { title: localize("ui.panel.config.integrations.confirm_new", { integration: domainToName(localize, domain), }), - })) + }) ) { - return; + showConfigFlowDialog(this, { + dialogClosedCallback: () => { + this._handleFlowUpdated(); + }, + startFlowHandler: domain, + manifest: this._manifests[domain], + showAdvanced: this.hass.userData?.showAdvanced, + }); } - showConfigFlowDialog(this, { - dialogClosedCallback: () => { - this._handleFlowUpdated(); - }, - startFlowHandler: domain, - manifest: this._manifests[domain], - showAdvanced: this.hass.userData?.showAdvanced, - }); + return; } const supportedBrands = await getSupportedBrands(this.hass); From de90a62de7bd977a08c4f4cd7bbc8b8fe4f44038 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Tue, 13 Sep 2022 19:59:35 +0200 Subject: [PATCH 15/23] Show confirm dialog when clicking traces (#13716) --- .../config/automation/ha-automation-editor.ts | 72 ++++++++---------- src/panels/config/script/ha-script-editor.ts | 73 ++++++++----------- 2 files changed, 63 insertions(+), 82 deletions(-) diff --git a/src/panels/config/automation/ha-automation-editor.ts b/src/panels/config/automation/ha-automation-editor.ts index f61b1f6438..14f34c7f6b 100644 --- a/src/panels/config/automation/ha-automation-editor.ts +++ b/src/panels/config/automation/ha-automation-editor.ts @@ -31,7 +31,6 @@ import { classMap } from "lit/directives/class-map"; import { fireEvent } from "../../../common/dom/fire_event"; import { navigate } from "../../../common/navigate"; import { copyToClipboard } from "../../../common/util/copy-clipboard"; -import { afterNextRender } from "../../../common/util/render-status"; import "../../../components/ha-button-menu"; import "../../../components/ha-card"; import "../../../components/ha-fab"; @@ -135,17 +134,11 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { > ${this._config?.id && !this.narrow ? html` - - - ${this.hass.localize( - "ui.panel.config.automation.editor.show_trace" - )} - - + + ${this.hass.localize( + "ui.panel.config.automation.editor.show_trace" + )} + ` : ""} @@ -486,6 +479,15 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { fireEvent(this, "hass-more-info", { entityId: this._entityId }); } + private async _showTrace() { + if (this._config?.id) { + const result = await this.confirmUnsavedChanged(); + if (result) { + navigate(`/config/automation/trace/${this._config.id}`); + } + } + } + private _runActions() { if (!this.hass || !this._entityId) { return; @@ -535,44 +537,35 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { this._dirty = true; } - private _backTapped = (): void => { + private async confirmUnsavedChanged(): Promise { if (this._dirty) { - showConfirmationDialog(this, { + return showConfirmationDialog(this, { text: this.hass!.localize( "ui.panel.config.automation.editor.unsaved_confirm" ), confirmText: this.hass!.localize("ui.common.leave"), dismissText: this.hass!.localize("ui.common.stay"), - confirm: () => { - afterNextRender(() => history.back()); - }, }); - } else { - afterNextRender(() => history.back()); + } + return true; + } + + private _backTapped = async () => { + const result = await this.confirmUnsavedChanged(); + if (result) { + history.back(); } }; private async _duplicate() { - if (this._dirty) { - if ( - !(await showConfirmationDialog(this, { - text: this.hass!.localize( - "ui.panel.config.automation.editor.unsaved_confirm" - ), - confirmText: this.hass!.localize("ui.common.leave"), - dismissText: this.hass!.localize("ui.common.stay"), - })) - ) { - return; - } - // Wait for dialog to complete closing - await new Promise((resolve) => setTimeout(resolve, 0)); + const result = await this.confirmUnsavedChanged(); + if (result) { + showAutomationEditor({ + ...this._config, + id: undefined, + alias: undefined, + }); } - showAutomationEditor({ - ...this._config, - id: undefined, - alias: undefined, - }); } private async _deleteConfirm() { @@ -689,9 +682,6 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) { flex-direction: column; padding-bottom: 0; } - .trace-link { - text-decoration: none; - } manual-automation-editor, blueprint-automation-editor { margin: 0 auto; diff --git a/src/panels/config/script/ha-script-editor.ts b/src/panels/config/script/ha-script-editor.ts index 004547ea28..d39e81a473 100644 --- a/src/panels/config/script/ha-script-editor.ts +++ b/src/panels/config/script/ha-script-editor.ts @@ -184,17 +184,11 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { > ${this.scriptEntityId && !this.narrow ? html` - - - ${this.hass.localize( - "ui.panel.config.script.editor.show_trace" - )} - - + + ${this.hass.localize( + "ui.panel.config.script.editor.show_trace" + )} + ` : ""} @@ -530,6 +524,15 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { fireEvent(this, "hass-more-info", { entityId: this.scriptEntityId }); } + private async _showTrace() { + if (this.scriptEntityId) { + const result = await this.confirmUnsavedChanged(); + if (result) { + navigate(`/config/script/trace/${this.scriptEntityId}`); + } + } + } + private async _runScript(ev: CustomEvent) { ev.stopPropagation(); await triggerScript(this.hass, this.scriptEntityId as string); @@ -660,45 +663,36 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { this._dirty = true; } - private _backTapped = (): void => { + private async confirmUnsavedChanged(): Promise { if (this._dirty) { - showConfirmationDialog(this, { + return showConfirmationDialog(this, { text: this.hass!.localize( - "ui.panel.config.common.editor.confirm_unsaved" + "ui.panel.config.automation.editor.unsaved_confirm" ), confirmText: this.hass!.localize("ui.common.leave"), dismissText: this.hass!.localize("ui.common.stay"), - confirm: () => { - setTimeout(() => history.back()); - }, }); - } else { + } + return true; + } + + private _backTapped = async () => { + const result = await this.confirmUnsavedChanged(); + if (result) { history.back(); } }; private async _duplicate() { - if (this._dirty) { - if ( - !(await showConfirmationDialog(this, { - text: this.hass!.localize( - "ui.panel.config.common.editor.confirm_unsaved" - ), - confirmText: this.hass!.localize("ui.common.yes"), - dismissText: this.hass!.localize("ui.common.no"), - })) - ) { - return; - } - // Wait for dialog to complete closing - await new Promise((resolve) => setTimeout(resolve, 0)); + const result = await this.confirmUnsavedChanged(); + if (result) { + showScriptEditor({ + ...this._config, + alias: `${this._config?.alias} (${this.hass.localize( + "ui.panel.config.script.picker.duplicate" + )})`, + }); } - showScriptEditor({ - ...this._config, - alias: `${this._config?.alias} (${this.hass.localize( - "ui.panel.config.script.picker.duplicate" - )})`, - }); } private async _deleteConfirm() { @@ -840,9 +834,6 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) { .header a { color: var(--secondary-text-color); } - .trace-link { - text-decoration: none; - } ha-button-menu a { text-decoration: none; color: var(--primary-color); From 55d84973c66b5000a9f2d209e50477338b859302 Mon Sep 17 00:00:00 2001 From: Pierre <397503+bemble@users.noreply.github.com> Date: Tue, 13 Sep 2022 20:00:20 +0200 Subject: [PATCH 16/23] fix: add previous repeat action configuration on change (#13717) --- .../automation/action/types/ha-automation-action-repeat.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/panels/config/automation/action/types/ha-automation-action-repeat.ts b/src/panels/config/automation/action/types/ha-automation-action-repeat.ts index c7dc7c8eab..f0994f6925 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-repeat.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-repeat.ts @@ -115,6 +115,7 @@ export class HaRepeatAction extends LitElement implements ActionElement { fireEvent(this, "value-changed", { value: { + ...this.action, repeat: { [type]: value, sequence: this.action.repeat.sequence }, }, }); @@ -125,6 +126,7 @@ export class HaRepeatAction extends LitElement implements ActionElement { const value = ev.detail.value as Condition[]; fireEvent(this, "value-changed", { value: { + ...this.action, repeat: { ...this.action.repeat, [getType(this.action.repeat)!]: value, @@ -138,6 +140,7 @@ export class HaRepeatAction extends LitElement implements ActionElement { const value = ev.detail.value as Action[]; fireEvent(this, "value-changed", { value: { + ...this.action, repeat: { ...this.action.repeat, sequence: value, @@ -153,6 +156,7 @@ export class HaRepeatAction extends LitElement implements ActionElement { } fireEvent(this, "value-changed", { value: { + ...this.action, repeat: { ...this.action.repeat, count: newVal, From f164ad0b8956f4b522ec9b502988e8d4323bcec8 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 13 Sep 2022 20:53:19 +0200 Subject: [PATCH 17/23] use the correct inputmode (#13722) --- src/components/ha-selector/ha-selector-number.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ha-selector/ha-selector-number.ts b/src/components/ha-selector/ha-selector-number.ts index 0ccfedafd2..343490af31 100644 --- a/src/components/ha-selector/ha-selector-number.ts +++ b/src/components/ha-selector/ha-selector-number.ts @@ -51,8 +51,9 @@ export class HaNumberSelector extends LitElement { ` : ""} Date: Tue, 13 Sep 2022 20:49:39 +0200 Subject: [PATCH 18/23] improve duration rendering for state trigger (#13723) --- src/data/automation_i18n.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/data/automation_i18n.ts b/src/data/automation_i18n.ts index 93a6970cc9..e81e6c992a 100644 --- a/src/data/automation_i18n.ts +++ b/src/data/automation_i18n.ts @@ -1,3 +1,4 @@ +import { formatDuration } from "../common/datetime/format_duration"; import secondsToDuration from "../common/datetime/seconds_to_duration"; import { ensureArray } from "../common/ensure-array"; import { computeStateName } from "../common/entity/compute_state_name"; @@ -140,17 +141,19 @@ export const describeTrigger = ( base += ` to ${to}`; } - if ("for" in trigger) { - let duration: string; + if (trigger.for) { + let duration: string | null; if (typeof trigger.for === "number") { - duration = `${secondsToDuration(trigger.for)!}`; + duration = secondsToDuration(trigger.for); } else if (typeof trigger.for === "string") { - duration = `${trigger.for}`; + duration = trigger.for; } else { - duration = `${JSON.stringify(trigger.for)}`; + duration = formatDuration(trigger.for); } - base += ` for ${duration}`; + if (duration) { + base += ` for ${duration}`; + } } return base; From e9281ad9f134d13c1e43c6a953138dd9630ccb0d Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 13 Sep 2022 20:58:07 +0200 Subject: [PATCH 19/23] Bumped version to 20220907.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 17f53754f1..432afad75a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20220907.0" +version = "20220907.1" license = {text = "Apache-2.0"} description = "The Home Assistant frontend" readme = "README.md" From 28bae5071cd72de7198357e110db0a59b7be5537 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 13 Sep 2022 20:53:55 +0200 Subject: [PATCH 20/23] Revert "Add initial field to the helper input_number in UI" (#13713) --- .../config/helpers/forms/ha-input_number-form.ts | 13 ------------- src/translations/en.json | 1 - 2 files changed, 14 deletions(-) diff --git a/src/panels/config/helpers/forms/ha-input_number-form.ts b/src/panels/config/helpers/forms/ha-input_number-form.ts index e6de46796f..a1196cbf22 100644 --- a/src/panels/config/helpers/forms/ha-input_number-form.ts +++ b/src/panels/config/helpers/forms/ha-input_number-form.ts @@ -26,8 +26,6 @@ class HaInputNumberForm extends LitElement { @state() private _min?: number; - @state() private _initial?: number; - @state() private _mode?: string; @state() private _step?: number; @@ -44,7 +42,6 @@ class HaInputNumberForm extends LitElement { this._min = item.min ?? 0; this._mode = item.mode || "slider"; this._step = item.step ?? 1; - this._initial = item.initial ?? 0; this._unit_of_measurement = item.unit_of_measurement; } else { this._item = { @@ -57,7 +54,6 @@ class HaInputNumberForm extends LitElement { this._min = 0; this._mode = "slider"; this._step = 1; - this._initial = 0; } } @@ -117,15 +113,6 @@ class HaInputNumberForm extends LitElement { "ui.dialogs.helper_settings.input_number.max" )} > - ${this.hass.userData?.showAdvanced ? html`
    diff --git a/src/translations/en.json b/src/translations/en.json index 4ca9e25056..c3fa44cf73 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -924,7 +924,6 @@ "pattern": "Regex pattern for client-side validation" }, "input_number": { - "initial": "Initial value", "min": "Minimum value", "max": "Maximum value", "mode": "Display mode", From e9f4307d15f4fc1a096373ec46fc952f5f5596d1 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 14 Sep 2022 09:02:51 +0200 Subject: [PATCH 21/23] Fix hass subpage (#13730) --- src/layouts/hass-subpage.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layouts/hass-subpage.ts b/src/layouts/hass-subpage.ts index 2dd0979543..76322b6691 100644 --- a/src/layouts/hass-subpage.ts +++ b/src/layouts/hass-subpage.ts @@ -34,11 +34,14 @@ class HassSubpage extends LitElement { @restoreScroll(".content") private _savedScrollPos?: number; protected willUpdate(changedProps: PropertyValues): void { + super.willUpdate(changedProps); + if (!changedProps.has("hass")) { + return; + } const oldHass = changedProps.get("hass") as HomeAssistant | undefined; if (!oldHass || oldHass.locale !== this.hass.locale) { toggleAttribute(this, "rtl", computeRTL(this.hass)); } - super.willUpdate(changedProps); } protected render(): TemplateResult { From 7ec28c43147597a780962bcaadb0a95c33cb6341 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 14 Sep 2022 09:03:46 +0200 Subject: [PATCH 22/23] Bumped version to 20220907.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 432afad75a..ba3b991ccb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "home-assistant-frontend" -version = "20220907.1" +version = "20220907.2" license = {text = "Apache-2.0"} description = "The Home Assistant frontend" readme = "README.md" From fe46f759c937a101e5720aa3ccfcd3903ebc0051 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Wed, 14 Sep 2022 09:08:37 +0200 Subject: [PATCH 23/23] Fix system blank page (#13731) --- src/panels/config/core/ha-config-system-navigation.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/panels/config/core/ha-config-system-navigation.ts b/src/panels/config/core/ha-config-system-navigation.ts index e69948c657..42c71b95c5 100644 --- a/src/panels/config/core/ha-config-system-navigation.ts +++ b/src/panels/config/core/ha-config-system-navigation.ts @@ -116,6 +116,7 @@ class HaConfigSystemNavigation extends LitElement { return html`