From b4f025b5580f4c1158ffcfec380bf6a4bf324b69 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 8 Apr 2021 17:19:29 +0200 Subject: [PATCH 1/3] Handle choose being null Fixes #8851 --- src/components/trace/hat-script-graph.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/trace/hat-script-graph.ts b/src/components/trace/hat-script-graph.ts index 9abf4ec9b885..ab10f0360b92 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 From aaccdaae8d457e068294024b63f15e9c32107811 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Thu, 8 Apr 2021 17:45:47 +0200 Subject: [PATCH 2/3] Update ha-automation-trace.ts --- src/panels/config/automation/trace/ha-automation-trace.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/panels/config/automation/trace/ha-automation-trace.ts b/src/panels/config/automation/trace/ha-automation-trace.ts index 53c7131dc379..c1ed1a12373a 100644 --- a/src/panels/config/automation/trace/ha-automation-trace.ts +++ b/src/panels/config/automation/trace/ha-automation-trace.ts @@ -90,7 +90,7 @@ export class HaAutomationTrace extends LitElement { From 398967b3df5ef0b6bbc8ee07a1266817a7dc273b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 8 Apr 2021 18:25:47 +0000 Subject: [PATCH 3/3] Fix types --- src/data/script.ts | 2 +- .../action/types/ha-automation-action-choose.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data/script.ts b/src/data/script.ts index 096835a49d26..bb614696a2d9 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 bb9ac0f8a60d..2c356bca70f7 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`