mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 05:47:20 +00:00
Handle errors in trace (#8775)
This commit is contained in:
parent
9b947ef734
commit
9a68bdeec1
@ -93,7 +93,7 @@ class HatScriptGraph extends LitElement {
|
||||
const path = `condition/${i}`;
|
||||
const trace = this.trace.trace[path] as ConditionTraceStep[] | undefined;
|
||||
const track_path =
|
||||
trace === undefined ? 0 : trace![0].result.result ? 1 : 2;
|
||||
trace?.[0].result === undefined ? 0 : trace[0].result.result ? 1 : 2;
|
||||
if (trace) {
|
||||
this.trackedNodes[path] = { config, path };
|
||||
}
|
||||
@ -139,7 +139,7 @@ class HatScriptGraph extends LitElement {
|
||||
|
||||
private render_choose_node(config: ChooseAction, path: string) {
|
||||
const trace = this.trace.trace[path] as ChooseActionTraceStep[] | undefined;
|
||||
const trace_path = trace
|
||||
const trace_path = trace?.[0].result
|
||||
? trace[0].result.choice === "default"
|
||||
? [config.choose.length]
|
||||
: [trace[0].result.choice]
|
||||
@ -173,7 +173,7 @@ class HatScriptGraph extends LitElement {
|
||||
.iconPath=${mdiCheckBoxOutline}
|
||||
nofocus
|
||||
class=${classMap({
|
||||
track: trace !== undefined && trace[0].result.choice === i,
|
||||
track: trace !== undefined && trace[0].result?.choice === i,
|
||||
})}
|
||||
></hat-graph-node>
|
||||
${branch.sequence.map((action, j) =>
|
||||
@ -188,7 +188,7 @@ class HatScriptGraph extends LitElement {
|
||||
nofocus
|
||||
class=${classMap({
|
||||
track:
|
||||
trace !== undefined && trace[0].result.choice === "default",
|
||||
trace !== undefined && trace[0].result?.choice === "default",
|
||||
})}
|
||||
></hat-graph-node>
|
||||
${config.default?.map((action, i) =>
|
||||
@ -200,8 +200,9 @@ class HatScriptGraph extends LitElement {
|
||||
}
|
||||
|
||||
private render_condition_node(node: Condition, path: string) {
|
||||
const trace: any = this.trace.trace[path];
|
||||
const track_path = trace === undefined ? 0 : trace[0].result.result ? 1 : 2;
|
||||
const trace = (this.trace.trace[path] as ConditionTraceStep[]) || undefined;
|
||||
const track_path =
|
||||
trace?.[0].result === undefined ? 0 : trace[0].result.result ? 1 : 2;
|
||||
return html`
|
||||
<hat-graph
|
||||
branching
|
||||
@ -218,7 +219,7 @@ class HatScriptGraph extends LitElement {
|
||||
<hat-graph-node
|
||||
slot="head"
|
||||
class=${classMap({
|
||||
track: trace,
|
||||
track: Boolean(trace),
|
||||
})}
|
||||
.iconPath=${mdiAbTesting}
|
||||
nofocus
|
||||
|
@ -302,7 +302,7 @@ class ActionRenderer {
|
||||
const startLevel = choosePath.split("/").length - 1;
|
||||
|
||||
const chooseTrace = this._getItem(index)[0] as ChooseActionTraceStep;
|
||||
const defaultExecuted = chooseTrace.result.choice === "default";
|
||||
const defaultExecuted = chooseTrace.result?.choice === "default";
|
||||
const chooseConfig = this._getDataFromPath(
|
||||
this.keys[index]
|
||||
) as ChooseAction;
|
||||
@ -312,11 +312,14 @@ class ActionRenderer {
|
||||
this._renderEntry(choosePath, `${name}: Default action executed`);
|
||||
} else {
|
||||
const choiceConfig = this._getDataFromPath(
|
||||
`${this.keys[index]}/choose/${chooseTrace.result.choice}`
|
||||
) as ChooseActionChoice;
|
||||
const choiceName =
|
||||
choiceConfig.alias || `Choice ${chooseTrace.result.choice}`;
|
||||
this._renderEntry(choosePath, `${name}: ${choiceName} executed`);
|
||||
`${this.keys[index]}/choose/${chooseTrace.result?.choice}`
|
||||
) as ChooseActionChoice | undefined;
|
||||
const choiceName = choiceConfig
|
||||
? `${
|
||||
choiceConfig.alias || `Choice ${chooseTrace.result?.choice}`
|
||||
} executed`
|
||||
: `Error: ${chooseTrace.error}`;
|
||||
this._renderEntry(choosePath, `${name}: ${choiceName}`);
|
||||
}
|
||||
|
||||
let i;
|
||||
|
@ -5,6 +5,7 @@ import { AutomationConfig } from "./automation";
|
||||
interface BaseTraceStep {
|
||||
path: string;
|
||||
timestamp: string;
|
||||
error?: string;
|
||||
changed_variables?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
@ -19,11 +20,11 @@ export interface TriggerTraceStep extends BaseTraceStep {
|
||||
}
|
||||
|
||||
export interface ConditionTraceStep extends BaseTraceStep {
|
||||
result: { result: boolean };
|
||||
result?: { result: boolean };
|
||||
}
|
||||
|
||||
export interface CallServiceActionTraceStep extends BaseTraceStep {
|
||||
result: {
|
||||
result?: {
|
||||
limit: number;
|
||||
running_script: boolean;
|
||||
params: Record<string, unknown>;
|
||||
@ -36,11 +37,11 @@ export interface CallServiceActionTraceStep extends BaseTraceStep {
|
||||
}
|
||||
|
||||
export interface ChooseActionTraceStep extends BaseTraceStep {
|
||||
result: { choice: number | "default" };
|
||||
result?: { choice: number | "default" };
|
||||
}
|
||||
|
||||
export interface ChooseChoiceActionTraceStep extends BaseTraceStep {
|
||||
result: { result: boolean };
|
||||
result?: { result: boolean };
|
||||
}
|
||||
|
||||
export type ActionTraceStep =
|
||||
|
@ -259,7 +259,7 @@ class HaLogbook extends LitElement {
|
||||
haStyle,
|
||||
haStyleScrollbar,
|
||||
css`
|
||||
:host {
|
||||
:host([virtualize]) {
|
||||
display: block;
|
||||
height: 100%;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user