Fix describing device conditions in trace viewer (#24645)

This commit is contained in:
karwosts 2025-03-16 01:14:40 -07:00 committed by GitHub
parent d4717f1293
commit 05aa55bfb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,5 @@
import { dump } from "js-yaml"; import { dump } from "js-yaml";
import { consume } from "@lit-labs/context";
import type { CSSResultGroup, TemplateResult } from "lit"; import type { CSSResultGroup, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit"; import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
@ -19,6 +20,8 @@ import { traceTabStyles } from "./trace-tab-styles";
import type { HomeAssistant } from "../../types"; import type { HomeAssistant } from "../../types";
import type { NodeInfo } from "./hat-script-graph"; import type { NodeInfo } from "./hat-script-graph";
import { describeCondition } from "../../data/automation_i18n"; import { describeCondition } from "../../data/automation_i18n";
import type { EntityRegistryEntry } from "../../data/entity_registry";
import { fullEntitiesContext } from "../../data/context";
const TRACE_PATH_TABS = [ const TRACE_PATH_TABS = [
"step_config", "step_config",
@ -45,6 +48,10 @@ export class HaTracePathDetails extends LitElement {
@state() private _view: (typeof TRACE_PATH_TABS)[number] = "step_config"; @state() private _view: (typeof TRACE_PATH_TABS)[number] = "step_config";
@state()
@consume({ context: fullEntitiesContext, subscribe: true })
_entityReg!: EntityRegistryEntry[];
protected render(): TemplateResult { protected render(): TemplateResult {
return html` return html`
<div class="padded-box trace-info"> <div class="padded-box trace-info">
@ -166,7 +173,7 @@ export class HaTracePathDetails extends LitElement {
? html`[${describeCondition( ? html`[${describeCondition(
currentDetail, currentDetail,
this.hass, this.hass,
currentDetail.alias this._entityReg
)}]<br />` )}]<br />`
: nothing} : nothing}
${this.hass!.localize( ${this.hass!.localize(