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`