From a1bdfa75602afe7da2834b776d32e4d227a7b2c8 Mon Sep 17 00:00:00 2001 From: Donnie Date: Wed, 7 Apr 2021 21:18:55 -0700 Subject: [PATCH 01/13] Fix spinner regression and remove unnecessary twoline config (#8847) --- src/dialogs/quick-bar/ha-quick-bar.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/dialogs/quick-bar/ha-quick-bar.ts b/src/dialogs/quick-bar/ha-quick-bar.ts index dea0a35a17..443b8b8470 100644 --- a/src/dialogs/quick-bar/ha-quick-bar.ts +++ b/src/dialogs/quick-bar/ha-quick-bar.ts @@ -238,7 +238,6 @@ export class QuickBar extends LitElement { @@ -268,10 +267,10 @@ export class QuickBar extends LitElement { private _renderCommandItem(item: CommandItem, index?: number) { return html` Date: Thu, 8 Apr 2021 09:47:25 +0200 Subject: [PATCH 02/13] Mention unique ID requirement in trace button tooltip (#8853) --- src/translations/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/translations/en.json b/src/translations/en.json index 44e8dae6c6..143647766d 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -1237,7 +1237,7 @@ "no_automations": "We couldn’t find any automations", "add_automation": "Add automation", "only_editable": "Only automations defined in automations.yaml are editable.", - "dev_only_editable": "Only automations defined in automations.yaml are debuggable.", + "dev_only_editable": "Only automations that have a unique ID assigned are debuggable.", "edit_automation": "Edit automation", "dev_automation": "Debug automation", "show_info_automation": "Show info about automation", From 716335df2c391d78dea17200f253cbd5ec37269c Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Thu, 8 Apr 2021 10:52:10 +0200 Subject: [PATCH 03/13] Use number format setting for attribute rows (#8844) --- src/panels/lovelace/special-rows/hui-attribute-row.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/panels/lovelace/special-rows/hui-attribute-row.ts b/src/panels/lovelace/special-rows/hui-attribute-row.ts index da15054a57..ce215b0f2e 100644 --- a/src/panels/lovelace/special-rows/hui-attribute-row.ts +++ b/src/panels/lovelace/special-rows/hui-attribute-row.ts @@ -10,6 +10,7 @@ import { TemplateResult, } from "lit-element"; import checkValidDate from "../../../common/datetime/check_valid_date"; +import { formatNumber } from "../../../common/string/format_number"; import { HomeAssistant } from "../../../types"; import { hasConfigOrEntityChanged } from "../common/has-changed"; import "../components/hui-generic-entity-row"; @@ -71,6 +72,8 @@ class HuiAttributeRow extends LitElement implements LovelaceRow { .ts=${date} .format=${this._config.format} >` + : typeof attribute === "number" + ? formatNumber(attribute, this.hass.locale) : attribute ?? "-"} ${this._config.suffix} From e4606219bc73b1ee27b712503fd09ebd57a6c081 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 8 Apr 2021 18:04:08 +0200 Subject: [PATCH 04/13] Check if logbook component loaded when fetching trace (#8861) --- .../config/automation/trace/ha-automation-trace.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/panels/config/automation/trace/ha-automation-trace.ts b/src/panels/config/automation/trace/ha-automation-trace.ts index 53c7131dc3..11030655f2 100644 --- a/src/panels/config/automation/trace/ha-automation-trace.ts +++ b/src/panels/config/automation/trace/ha-automation-trace.ts @@ -40,6 +40,7 @@ import { mdiDownload, } from "@mdi/js"; import "./ha-automation-trace-blueprint-config"; +import { isComponentLoaded } from "../../../../common/config/is_component_loaded"; @customElement("ha-automation-trace") export class HaAutomationTrace extends LitElement { @@ -378,11 +379,13 @@ export class HaAutomationTrace extends LitElement { this.automationId, this._runId! ); - this._logbookEntries = await getLogbookDataForContext( - this.hass, - trace.timestamp.start, - trace.context.id - ); + this._logbookEntries = isComponentLoaded(this.hass, "logbook") + ? await getLogbookDataForContext( + this.hass, + trace.timestamp.start, + trace.context.id + ) + : []; this._trace = trace; } From 51c888845c301d506a24f68a5420aa4858a731cb Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 8 Apr 2021 20:48:49 +0200 Subject: [PATCH 05/13] Handle choose being null (#8859) Co-authored-by: Paulus Schoutsen --- src/components/trace/hat-script-graph.ts | 8 ++++++-- src/data/script.ts | 2 +- .../action/types/ha-automation-action-choose.ts | 10 +++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/trace/hat-script-graph.ts b/src/components/trace/hat-script-graph.ts index 9abf4ec9b8..ab10f0360b 100644 --- a/src/components/trace/hat-script-graph.ts +++ b/src/components/trace/hat-script-graph.ts @@ -143,7 +143,7 @@ class HatScriptGraph extends LitElement { const trace = this.trace.trace[path] as ChooseActionTraceStep[] | undefined; const trace_path = trace?.[0].result ? trace[0].result.choice === "default" - ? [config.choose.length] + ? [config.choose?.length || 0] : [trace[0].result.choice] : []; return html` @@ -167,7 +167,7 @@ class HatScriptGraph extends LitElement { nofocus > - ${config.choose.map((branch, i) => { + ${config.choose?.map((branch, i) => { const branch_path = `${path}/choose/${i}`; const track_this = trace !== undefined && trace[0].result?.choice === i; @@ -466,6 +466,10 @@ class HatScriptGraph extends LitElement { `; } catch (err) { + if (__DEV__) { + // eslint-disable-next-line no-console + console.log("Error creating script graph:", err); + } return html`
Error rendering graph. Please download trace and share with the diff --git a/src/data/script.ts b/src/data/script.ts index 096835a49d..bb614696a2 100644 --- a/src/data/script.ts +++ b/src/data/script.ts @@ -112,7 +112,7 @@ export interface ChooseActionChoice { export interface ChooseAction { alias?: string; - choose: ChooseActionChoice[]; + choose: ChooseActionChoice[] | null; default?: Action | Action[]; } 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 bb9ac0f8a6..2c356bca70 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 @@ -31,7 +31,7 @@ export class HaChooseAction extends LitElement implements ActionElement { const action = this.action; return html` - ${action.choose.map( + ${(action.choose || []).map( (option, idx) => html` Date: Thu, 8 Apr 2021 11:52:37 -0700 Subject: [PATCH 06/13] Add logbook note (#8843) Co-authored-by: Bram Kragten --- src/components/trace/hat-logbook-note.ts | 26 +++++++++ .../trace/ha-automation-trace-logbook.ts | 54 +++++++++++++++++++ .../trace/ha-automation-trace-path-details.ts | 18 ++++--- .../trace/ha-automation-trace-timeline.ts | 14 ++--- .../automation/trace/ha-automation-trace.ts | 7 +-- 5 files changed, 103 insertions(+), 16 deletions(-) create mode 100644 src/components/trace/hat-logbook-note.ts create mode 100644 src/panels/config/automation/trace/ha-automation-trace-logbook.ts diff --git a/src/components/trace/hat-logbook-note.ts b/src/components/trace/hat-logbook-note.ts new file mode 100644 index 0000000000..5d5b1f9df7 --- /dev/null +++ b/src/components/trace/hat-logbook-note.ts @@ -0,0 +1,26 @@ +import { LitElement, css, html, customElement } from "lit-element"; + +@customElement("hat-logbook-note") +class HatLogbookNote extends LitElement { + render() { + return html` + Not all shown logbook entries might be related to this automation. + `; + } + + static styles = css` + :host { + display: block; + text-align: center; + font-style: italic; + padding: 16px; + margin-top: 8px; + } + `; +} + +declare global { + interface HTMLElementTagNameMap { + "hat-logbook-note": HatLogbookNote; + } +} diff --git a/src/panels/config/automation/trace/ha-automation-trace-logbook.ts b/src/panels/config/automation/trace/ha-automation-trace-logbook.ts new file mode 100644 index 0000000000..b18d83d1be --- /dev/null +++ b/src/panels/config/automation/trace/ha-automation-trace-logbook.ts @@ -0,0 +1,54 @@ +import { + css, + CSSResult, + customElement, + html, + LitElement, + property, + TemplateResult, +} from "lit-element"; +import type { HomeAssistant } from "../../../../types"; +import type { LogbookEntry } from "../../../../data/logbook"; +import "../../../../components/trace/hat-logbook-note"; +import "../../../logbook/ha-logbook"; + +@customElement("ha-automation-trace-logbook") +export class HaAutomationTraceLogbook extends LitElement { + @property({ attribute: false }) public hass!: HomeAssistant; + + @property({ type: Boolean, reflect: true }) public narrow!: boolean; + + @property({ attribute: false }) public logbookEntries!: LogbookEntry[]; + + protected render(): TemplateResult { + return this.logbookEntries.length + ? html` + + + ` + : html`
+ No Logbook entries found for this step. +
`; + } + + static get styles(): CSSResult[] { + return [ + css` + .padded-box { + padding: 16px; + } + `, + ]; + } +} + +declare global { + interface HTMLElementTagNameMap { + "ha-automation-trace-logbook": HaAutomationTraceLogbook; + } +} diff --git a/src/panels/config/automation/trace/ha-automation-trace-path-details.ts b/src/panels/config/automation/trace/ha-automation-trace-path-details.ts index b27edf9814..2416ea2ad6 100644 --- a/src/panels/config/automation/trace/ha-automation-trace-path-details.ts +++ b/src/panels/config/automation/trace/ha-automation-trace-path-details.ts @@ -9,6 +9,7 @@ import { property, TemplateResult, } from "lit-element"; +import { classMap } from "lit-html/directives/class-map"; import { ActionTraceStep, AutomationTraceExtended, @@ -18,11 +19,11 @@ import { import "../../../../components/ha-icon-button"; import "../../../../components/ha-code-editor"; import type { NodeInfo } from "../../../../components/trace/hat-graph"; +import "../../../../components/trace/hat-logbook-note"; import { HomeAssistant } from "../../../../types"; import { formatDateTimeWithSeconds } from "../../../../common/datetime/format_date_time"; import { LogbookEntry } from "../../../../data/logbook"; import { traceTabStyles } from "./styles"; -import { classMap } from "lit-html/directives/class-map"; import "../../../logbook/ha-logbook"; @customElement("ha-automation-trace-path-details") @@ -205,12 +206,15 @@ ${safeDump(trace.changed_variables).trimRight()}` + ? html` + + + ` : html`
No Logbook entries found for this step.
`; diff --git a/src/panels/config/automation/trace/ha-automation-trace-timeline.ts b/src/panels/config/automation/trace/ha-automation-trace-timeline.ts index 63599b2db5..b61ce862ee 100644 --- a/src/panels/config/automation/trace/ha-automation-trace-timeline.ts +++ b/src/panels/config/automation/trace/ha-automation-trace-timeline.ts @@ -7,19 +7,20 @@ import { property, TemplateResult, } from "lit-element"; -import { AutomationTraceExtended } from "../../../../data/trace"; -import { HomeAssistant } from "../../../../types"; -import { LogbookEntry } from "../../../../data/logbook"; +import type { AutomationTraceExtended } from "../../../../data/trace"; +import type { HomeAssistant } from "../../../../types"; +import type { LogbookEntry } from "../../../../data/logbook"; import "../../../../components/trace/hat-trace-timeline"; -import { NodeInfo } from "../../../../components/trace/hat-graph"; +import type { NodeInfo } from "../../../../components/trace/hat-graph"; +import "../../../../components/trace/hat-logbook-note"; @customElement("ha-automation-trace-timeline") export class HaAutomationTraceTimeline extends LitElement { @property({ attribute: false }) public hass!: HomeAssistant; - @property() public trace!: AutomationTraceExtended; + @property({ attribute: false }) public trace!: AutomationTraceExtended; - @property() public logbookEntries!: LogbookEntry[]; + @property({ attribute: false }) public logbookEntries!: LogbookEntry[]; @property() public selected!: NodeInfo; @@ -33,6 +34,7 @@ export class HaAutomationTraceTimeline extends LitElement { allowPick > + `; } diff --git a/src/panels/config/automation/trace/ha-automation-trace.ts b/src/panels/config/automation/trace/ha-automation-trace.ts index 11030655f2..41007f4ab7 100644 --- a/src/panels/config/automation/trace/ha-automation-trace.ts +++ b/src/panels/config/automation/trace/ha-automation-trace.ts @@ -30,6 +30,7 @@ import { showAlertDialog } from "../../../../dialogs/generic/show-dialog-box"; import "./ha-automation-trace-path-details"; import "./ha-automation-trace-timeline"; import "./ha-automation-trace-config"; +import "./ha-automation-trace-logbook"; import { classMap } from "lit-html/directives/class-map"; import { traceTabStyles } from "./styles"; import { @@ -239,10 +240,10 @@ export class HaAutomationTrace extends LitElement { ` : this._view === "logbook" ? html` - + .logbookEntries=${this._logbookEntries} + > ` : this._view === "blueprint" ? html` From d0837fada8cf951409a8af616d04f468c52d8f87 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 8 Apr 2021 20:56:03 +0200 Subject: [PATCH 07/13] Bumped version to 20210407.2 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5502d28283..85e8008752 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210407.1", + version="20210407.2", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors", From 9b628546c128c7a7f8a984c5b2066e614dfb823f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 7 Apr 2021 09:41:39 -0700 Subject: [PATCH 08/13] Remove owner guard from analytics (#8842) --- src/panels/config/core/ha-config-analytics.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/panels/config/core/ha-config-analytics.ts b/src/panels/config/core/ha-config-analytics.ts index b582b5ed5e..26a2515e2f 100644 --- a/src/panels/config/core/ha-config-analytics.ts +++ b/src/panels/config/core/ha-config-analytics.ts @@ -33,10 +33,6 @@ class ConfigAnalytics extends LitElement { @internalProperty() private _error?: string; protected render(): TemplateResult { - if (!this.hass.user?.is_owner) { - return html``; - } - const error = this._error ? this._error : !isComponentLoaded(this.hass, "analytics") From 2507a41b6ef9e02d6cd9cac50426d6e54759530c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 8 Apr 2021 13:59:24 -0700 Subject: [PATCH 09/13] Pass narrow (#8864) --- src/panels/config/automation/trace/ha-automation-trace.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/panels/config/automation/trace/ha-automation-trace.ts b/src/panels/config/automation/trace/ha-automation-trace.ts index 41007f4ab7..81522f4876 100644 --- a/src/panels/config/automation/trace/ha-automation-trace.ts +++ b/src/panels/config/automation/trace/ha-automation-trace.ts @@ -242,6 +242,7 @@ export class HaAutomationTrace extends LitElement { ? html` ` From 97508a6f3175304b44207b5321b49f4d7b12a422 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 9 Apr 2021 01:31:46 +0200 Subject: [PATCH 10/13] Update value of date input (#8865) --- src/components/ha-date-input.ts | 2 ++ src/dialogs/more-info/controls/more-info-input_datetime.js | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ha-date-input.ts b/src/components/ha-date-input.ts index e3342396c5..b23f1f5b6b 100644 --- a/src/components/ha-date-input.ts +++ b/src/components/ha-date-input.ts @@ -118,6 +118,8 @@ export class HaDateInput extends LitElement { !this.value || (this._inited && !this._compareStringDates(ev.detail.value, this.value)) ) { + this.value = ev.detail.value; + fireEvent(this, "change"); fireEvent(this, "value-changed", { value: ev.detail.value }); } } diff --git a/src/dialogs/more-info/controls/more-info-input_datetime.js b/src/dialogs/more-info/controls/more-info-input_datetime.js index fad03c408a..cff1b5233b 100644 --- a/src/dialogs/more-info/controls/more-info-input_datetime.js +++ b/src/dialogs/more-info/controls/more-info-input_datetime.js @@ -16,7 +16,6 @@ class DatetimeInput extends PolymerElement {
From 7c823c98ae3dafb667789360cf3e6f734e8a27ab Mon Sep 17 00:00:00 2001 From: Charles Garwood Date: Thu, 8 Apr 2021 19:32:47 -0400 Subject: [PATCH 11/13] Add units to Z-Wave JS Node Config inputs (#8869) Co-authored-by: Paulus Schoutsen --- .../integration-panels/zwave_js/zwave_js-node-config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts index 33e08cb18b..a9ddcf897e 100644 --- a/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts +++ b/src/panels/config/integrations/integration-panels/zwave_js/zwave_js-node-config.ts @@ -230,6 +230,9 @@ class ZWaveJSNodeConfig extends SubscribeMixin(LitElement) { .disabled=${!item.metadata.writeable} @value-changed=${this._numericInputChanged} > + ${item.metadata.unit + ? html`${item.metadata.unit}` + : ""} `; } From d7c0c2ea7272006b6a79708a271855493ee82a83 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 8 Apr 2021 23:01:12 -0700 Subject: [PATCH 12/13] Fix failed conditions reason (#8870) --- gallery/src/demos/demo-automation-trace-timeline.ts | 2 +- src/components/trace/hat-trace-timeline.ts | 2 +- src/data/trace.ts | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gallery/src/demos/demo-automation-trace-timeline.ts b/gallery/src/demos/demo-automation-trace-timeline.ts index 2a8ecce1fa..740c589023 100644 --- a/gallery/src/demos/demo-automation-trace-timeline.ts +++ b/gallery/src/demos/demo-automation-trace-timeline.ts @@ -17,7 +17,7 @@ import { DemoTrace } from "../data/traces/types"; const traces: DemoTrace[] = [ mockDemoTrace({ state: "running" }), mockDemoTrace({ state: "debugged" }), - mockDemoTrace({ state: "stopped", script_execution: "failed_condition" }), + mockDemoTrace({ state: "stopped", script_execution: "failed_conditions" }), mockDemoTrace({ state: "stopped", script_execution: "failed_single" }), mockDemoTrace({ state: "stopped", script_execution: "failed_max_runs" }), mockDemoTrace({ state: "stopped", script_execution: "finished" }), diff --git a/src/components/trace/hat-trace-timeline.ts b/src/components/trace/hat-trace-timeline.ts index 742c6c839c..a17cb3c81e 100644 --- a/src/components/trace/hat-trace-timeline.ts +++ b/src/components/trace/hat-trace-timeline.ts @@ -475,7 +475,7 @@ export class HaAutomationTracer extends LitElement { let extra: TemplateResult | undefined; switch (this.trace.script_execution) { - case "failed_condition": + case "failed_conditions": reason = "a condition failed"; break; case "failed_single": diff --git a/src/data/trace.ts b/src/data/trace.ts index abe9d06830..cf5f18e6c2 100644 --- a/src/data/trace.ts +++ b/src/data/trace.ts @@ -66,7 +66,7 @@ export interface AutomationTrace { }; script_execution: | // The script was not executed because the automation's condition failed - "failed_condition" + "failed_conditions" // The script was not executed because the run mode is single | "failed_single" // The script was not executed because max parallel runs would be exceeded @@ -80,8 +80,7 @@ export interface AutomationTrace { | "error" // The exception is in the trace itself or in the last element of the trace // Script execution stopped by async_stop called on the script run because home assistant is shutting down, script mode is SCRIPT_MODE_RESTART etc: - | "cancelled" - | string; + | "cancelled"; // Automation only, should become it's own type when we support script in frontend trigger: string; } From 17d375515289c6427c0c7114c575f42d4de22a1b Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 9 Apr 2021 20:05:32 +0200 Subject: [PATCH 13/13] Bumped version to 20210407.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 85e8008752..3e60acb104 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="home-assistant-frontend", - version="20210407.2", + version="20210407.3", description="The Home Assistant frontend", url="https://github.com/home-assistant/home-assistant-polymer", author="The Home Assistant Authors",