Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/panels/config/automation/trace/ha-automation-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,24 @@ export class HaAutomationTrace extends LitElement {

const title = stateObj?.attributes.friendly_name || this._entityId;

let devButtons: TemplateResult | string = "";
if (__DEV__) {
devButtons = html`<div style="position: absolute; right: 0;">
<button @click=${this._importTrace}>
Import trace
</button>
<button @click=${this._loadLocalStorageTrace}>
Load stored trace
</button>
</div>`;
}

const actionButtons = html`
<mwc-icon-button label="Refresh" @click=${() => this._loadTraces()}>
<ha-svg-icon .path=${mdiRefresh}></ha-svg-icon>
</mwc-icon-button>
<mwc-icon-button
.disabled=${!this._runId}
.disabled=${!this._trace}
label="Download Trace"
@click=${this._downloadTrace}
>
Expand All @@ -99,6 +111,7 @@ export class HaAutomationTrace extends LitElement {
`;

return html`
${devButtons}
<hass-tabs-subpage
.hass=${this.hass}
.narrow=${this.narrow}
Expand Down Expand Up @@ -405,6 +418,27 @@ export class HaAutomationTrace extends LitElement {
aEl.click();
}

private _importTrace() {
const traceText = prompt("Enter downloaded trace");
if (!traceText) {
return;
}
localStorage.devTrace = traceText;
this._loadLocalTrace(traceText);
}

private _loadLocalStorageTrace() {
if (localStorage.devTrace) {
this._loadLocalTrace(localStorage.devTrace);
}
}

private _loadLocalTrace(traceText: string) {
const traceInfo = JSON.parse(traceText);
this._trace = traceInfo.trace;
this._logbookEntries = traceInfo.logbookEntries;
}

private _showTab(ev) {
this._view = (ev.target as any).view;
}
Expand Down