mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 08:46:35 +00:00
Use logbook for trace logbook items (#8773)
This commit is contained in:
parent
5cfd28881b
commit
5b55bcd879
@ -35,14 +35,17 @@ export const getLogbookDataForContext = async (
|
|||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
startDate: string,
|
startDate: string,
|
||||||
contextId?: string
|
contextId?: string
|
||||||
) =>
|
): Promise<LogbookEntry[]> =>
|
||||||
getLogbookDataFromServer(
|
addLogbookMessage(
|
||||||
hass,
|
hass,
|
||||||
startDate,
|
await getLogbookDataFromServer(
|
||||||
undefined,
|
hass,
|
||||||
undefined,
|
startDate,
|
||||||
undefined,
|
undefined,
|
||||||
contextId
|
undefined,
|
||||||
|
undefined,
|
||||||
|
contextId
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
export const getLogbookData = async (
|
export const getLogbookData = async (
|
||||||
@ -51,15 +54,22 @@ export const getLogbookData = async (
|
|||||||
endDate: string,
|
endDate: string,
|
||||||
entityId?: string,
|
entityId?: string,
|
||||||
entity_matches_only?: boolean
|
entity_matches_only?: boolean
|
||||||
) => {
|
): Promise<LogbookEntry[]> =>
|
||||||
const logbookData = await getLogbookDataCache(
|
addLogbookMessage(
|
||||||
hass,
|
hass,
|
||||||
startDate,
|
await getLogbookDataCache(
|
||||||
endDate,
|
hass,
|
||||||
entityId,
|
startDate,
|
||||||
entity_matches_only
|
endDate,
|
||||||
|
entityId,
|
||||||
|
entity_matches_only
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const addLogbookMessage = (
|
||||||
|
hass: HomeAssistant,
|
||||||
|
logbookData: LogbookEntry[]
|
||||||
|
): LogbookEntry[] => {
|
||||||
for (const entry of logbookData) {
|
for (const entry of logbookData) {
|
||||||
const stateObj = hass!.states[entry.entity_id!];
|
const stateObj = hass!.states[entry.entity_id!];
|
||||||
if (entry.state && stateObj) {
|
if (entry.state && stateObj) {
|
||||||
@ -71,7 +81,6 @@ export const getLogbookData = async (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return logbookData;
|
return logbookData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import { formatDateTimeWithSeconds } from "../../../../common/datetime/format_da
|
|||||||
import { LogbookEntry } from "../../../../data/logbook";
|
import { LogbookEntry } from "../../../../data/logbook";
|
||||||
import { traceTabStyles } from "./styles";
|
import { traceTabStyles } from "./styles";
|
||||||
import { classMap } from "lit-html/directives/class-map";
|
import { classMap } from "lit-html/directives/class-map";
|
||||||
|
import "../../../logbook/ha-logbook";
|
||||||
|
|
||||||
@customElement("ha-automation-trace-path-details")
|
@customElement("ha-automation-trace-path-details")
|
||||||
export class HaAutomationTracePathDetails extends LitElement {
|
export class HaAutomationTracePathDetails extends LitElement {
|
||||||
@ -200,13 +201,16 @@ ${safeDump(trace.changed_variables).trimRight()}</pre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`<div class="padded-box">
|
return entries.length
|
||||||
${entries.map(
|
? html`<ha-logbook
|
||||||
(entry) =>
|
relative-time
|
||||||
html`${entry.name} (${entry.entity_id})
|
.hass=${this.hass}
|
||||||
${entry.message || `turned ${entry.state}`}<br />`
|
.entries=${entries}
|
||||||
)}
|
.narrow=${this.narrow}
|
||||||
</div>`;
|
></ha-logbook>`
|
||||||
|
: html`<div class="padded-box">
|
||||||
|
No Logbook entries found for this step.
|
||||||
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _showTab(ev) {
|
private _showTab(ev) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user