mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 05:47:20 +00:00
Add basic action descriptions in traces (#8639)
This commit is contained in:
parent
5d2afdd825
commit
a841e287e5
@ -24,6 +24,7 @@ import {
|
||||
mdiStopCircleOutline,
|
||||
} from "@mdi/js";
|
||||
import { LogbookEntry } from "../../data/logbook";
|
||||
import { Action, describeAction } from "../../data/script";
|
||||
|
||||
const pathToName = (path: string) => path.split("/").join(" ");
|
||||
|
||||
@ -194,9 +195,10 @@ export class HaAutomationTracer extends LitElement {
|
||||
}
|
||||
|
||||
private _renderActionTrace(path: string, _value: ActionTrace[]) {
|
||||
const action = getConfigFromPath(this.trace!.config, path) as Action;
|
||||
return html`
|
||||
<ha-timeline .icon=${mdiRecordCircleOutline}>
|
||||
${getConfigFromPath(this.trace!.config, path).alias || pathToName(path)}
|
||||
${action.alias || describeAction(action, this.hass.localize)}
|
||||
</ha-timeline>
|
||||
`;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import {
|
||||
} from "home-assistant-js-websocket";
|
||||
import { computeObjectId } from "../common/entity/compute_object_id";
|
||||
import { navigate } from "../common/navigate";
|
||||
import { LocalizeFunc } from "../common/translations/localize";
|
||||
import { HomeAssistant } from "../types";
|
||||
import { Condition, Trigger } from "./automation";
|
||||
|
||||
@ -158,3 +159,41 @@ export const getScriptEditorInitData = () => {
|
||||
inititialScriptEditorData = undefined;
|
||||
return data;
|
||||
};
|
||||
|
||||
export const describeAction = (action: Action, _localize: LocalizeFunc) => {
|
||||
// Check based on config_validation.py#determine_script_action
|
||||
if ("delay" in action) {
|
||||
return "Delay";
|
||||
}
|
||||
if ("wait_template" in action) {
|
||||
return "Wait";
|
||||
}
|
||||
if ("condition" in action) {
|
||||
return "Check condition";
|
||||
}
|
||||
if ("event" in action) {
|
||||
return "Fire event";
|
||||
}
|
||||
if ("device_id" in action) {
|
||||
return "Run Device Action";
|
||||
}
|
||||
if ("scene" in action) {
|
||||
return "Activate a scene";
|
||||
}
|
||||
if ("repeat" in action) {
|
||||
return "Repeat an action multiple times";
|
||||
}
|
||||
if ("choose" in action) {
|
||||
return "Choose an action";
|
||||
}
|
||||
if ("wait_for_trigger" in action) {
|
||||
return "Wait for a trigger";
|
||||
}
|
||||
if ("variables" in action) {
|
||||
return "Define variables";
|
||||
}
|
||||
if ("service" in action) {
|
||||
return "Call service";
|
||||
}
|
||||
return "Unknown action";
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user