iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 11.6 kB
JavaScript
export const __rspack_esm_id=14022;export const __rspack_esm_ids=[14022];export const __webpack_modules__={64037(t,a,i){i.a(t,async function(t,o){try{i.r(a),i.d(a,{HaAutomationTrace:()=>N});i(18111),i(20116),i(13579),i(69112),i(33110),i(14603),i(47566),i(98721);var e=i(62826),s=(i(68825),i(5124)),r=i(22441),n=i(36312),h=i(1087),c=i(91926),d=i(15638),l=i(18350),_=i(29823),p=(i(70947),i(26300)),u=i(66289),g=(i(62647),i(98920)),v=i(7370),b=i(193),m=i(29804),w=i(73003),f=i(68886),$=i(86531),k=i(61165),y=i(65063),I=i(81310),x=i(14503),C=i(30039),A=i(48240),T=t([l,_,p,u,g,v,b,m,w,f,I,A,$]);[l,_,p,u,g,v,b,m,w,f,I,A,$]=T.then?(await T)():T;const M="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",L="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",z="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",H="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",E="M1,12L5,16V13H17.17C17.58,14.17 18.69,15 20,15A3,3 0 0,0 23,12A3,3 0 0,0 20,9C18.69,9 17.58,9.83 17.17,11H5V8L1,12Z",q="M23,12L19,16V13H6.83C6.42,14.17 5.31,15 4,15A3,3 0 0,1 1,12A3,3 0 0,1 4,9C5.31,9 6.42,9.83 6.83,11H19V8L23,12Z",Z="M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z",V=["details","timeline","logbook","automation_config"];class N extends s.WF{render(){const t=this._entityId?this.hass.states[this._entityId]:void 0,a=this._graph,i=a?.trackedNodes,o=a?.renderedNodes,e=t?.attributes.friendly_name||this._entityId;return s.qy` ${""} <hass-subpage .hass="${this.hass}" .narrow="${this.narrow}" .header="${e}" .scrollable="${this.narrow}"> ${!this.narrow&&t?.attributes.id?s.qy` <ha-button appearance="plain" size="small" class="trace-link" ="${this._navigateToAutomation}" slot="toolbar-icon"> ${this.hass.localize("ui.panel.config.automation.trace.edit_automation")} </ha-button> `:s.s6} <ha-dropdown slot="toolbar-icon" -select="${this._handleDropdownSelect}"> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${M}"></ha-icon-button> <ha-dropdown-item .disabled="${!t}" value="show_info"> ${this.hass.localize("ui.panel.config.automation.editor.show_info")} <ha-svg-icon slot="icon" .path="${z}"></ha-svg-icon> </ha-dropdown-item> ${t?.attributes.id&&this.narrow?s.qy` <ha-dropdown-item value="edit_automation"> ${this.hass.localize("ui.panel.config.automation.trace.edit_automation")} <ha-svg-icon slot="icon" .path="${H}"></ha-svg-icon> </ha-dropdown-item> `:s.s6} <wa-divider></wa-divider> <ha-dropdown-item value="refresh"> ${this.hass.localize("ui.panel.config.automation.trace.refresh")} <ha-svg-icon slot="icon" .path="${Z}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${!this._trace}" value="download_trace"> ${this.hass.localize("ui.panel.config.automation.trace.download_trace")} <ha-svg-icon slot="icon" .path="${L}"></ha-svg-icon> </ha-dropdown-item> </ha-dropdown> <div class="toolbar"> ${this._traces&&this._traces.length>0?s.qy` <ha-icon-button .label="${this.hass.localize("ui.panel.config.automation.trace.older_trace")}" .path="${(0,d.qC)(this.hass.language,this.hass.translationMetadata.translations)?q:E}" .disabled="${this._traces[this._traces.length-1].run_id===this._runId}" ="${this._pickOlderTrace}"></ha-icon-button> <ha-trace-picker .hass="${this.hass}" .traces="${this._traces}" .value="${this._runId}" -changed="${this._pickTrace}"></ha-trace-picker> <ha-icon-button .label="${this.hass.localize("ui.panel.config.automation.trace.newer_trace")}" .path="${(0,d.qC)(this.hass.language,this.hass.translationMetadata.translations)?E:q}" .disabled="${this._traces[0].run_id===this._runId}" ="${this._pickNewerTrace}"></ha-icon-button> `:""} </div> ${void 0===this._traces?s.qy`<div class="container"> ${this.hass.localize("ui.common.loading")} </div>`:0===this._traces.length?s.qy`<div class="container"> ${this.hass.localize("ui.panel.config.automation.trace.no_traces_found")} </div>`:void 0===this._trace?"":s.qy` <div class="main"> <div class="graph"> <hat-script-graph .hass="${this.hass}" .trace="${this._trace}" .selected="${this._selected?.path}" -node-selected="${this._pickNode}"></hat-script-graph> </div> <div class="info"> <ha-tab-group -tab-show="${this._handleTabChanged}"> ${V.map(t=>s.qy` <ha-tab-group-tab slot="nav" .active="${this._view===t}" .panel="${t}"> ${this.hass.localize(`ui.panel.config.automation.trace.tabs.${t}`)} </ha-tab-group-tab> `)} ${this._trace.blueprint_inputs?s.qy` <ha-tab-group-tab slot="nav" .active="${"blueprint"===this._view}" panel="blueprint"> ${this.hass.localize("ui.panel.config.automation.trace.tabs.blueprint_config")} </ha-tab-group-tab> `:""} </ha-tab-group> ${void 0===this._selected||void 0===this._logbookEntries||void 0===i?s.s6:"details"===this._view?s.qy` <ha-trace-path-details .hass="${this.hass}" .narrow="${this.narrow}" .trace="${this._trace}" .selected="${this._selected}" .logbookEntries="${this._logbookEntries}" .trackedNodes="${i}" .renderedNodes="${o}"></ha-trace-path-details> `:"automation_config"===this._view?s.qy` <ha-trace-config .trace="${this._trace}"></ha-trace-config> `:"logbook"===this._view?s.qy` <ha-trace-logbook .hass="${this.hass}" .narrow="${this.narrow}" .trace="${this._trace}" .logbookEntries="${this._logbookEntries}"></ha-trace-logbook> `:"blueprint"===this._view?s.qy` <ha-trace-blueprint-config .trace="${this._trace}"></ha-trace-blueprint-config> `:s.qy` <ha-trace-timeline .hass="${this.hass}" .trace="${this._trace}" .logbookEntries="${this._logbookEntries}" .selected="${this._selected}" -changed="${this._timelinePathPicked}"></ha-trace-timeline> `} </div> </div> `} </hass-subpage> `}firstUpdated(t){if(super.firstUpdated(t),!this.automationId)return;const a=new URLSearchParams(location.search);this._loadTraces(a.get("run_id")||void 0)}updated(t){if(super.updated(t),t.get("automationId")&&(this._traces=void 0,this._entityId=void 0,this._runId=void 0,this._trace=void 0,this._logbookEntries=void 0,this.automationId&&this._loadTraces()),t.has("_runId")&&this._runId&&(this._trace=void 0,this._logbookEntries=void 0,this._loadTrace()),t.has("automations")&&this.automationId&&!this._entityId){const t=this.automations.find(t=>t.attributes.id===this.automationId);this._entityId=t?.entity_id}}_pickOlderTrace(){const t=this._traces.findIndex(t=>t.run_id===this._runId);this._runId=this._traces[t+1].run_id,this._selected=void 0}_pickNewerTrace(){const t=this._traces.findIndex(t=>t.run_id===this._runId);this._runId=this._traces[t-1].run_id,this._selected=void 0}_pickTrace(t){this._runId=t.detail.value,this._selected=void 0}_pickNode(t){this._selected=t.detail}_refreshTraces(){this._loadTraces()}async _loadTraces(t){if(this._traces=await(0,k.d1)(this.hass,"automation",this.automationId),this._traces.reverse(),t&&(this._runId=t),this._runId&&!this._traces.some(t=>t.run_id===this._runId)){if(this._runId=void 0,this._selected=void 0,t){const t=new URLSearchParams(location.search);t.delete("run_id"),history.replaceState(null,"",`${location.pathname}?${t.toString()}`)}await(0,y.showAlertDialog)(this,{text:this.hass.localize("ui.panel.config.automation.trace.trace_no_longer_available")})}!this._runId&&this._traces.length>0&&(this._runId=this._traces[0].run_id)}async _loadTrace(){const t=await(0,k.E4)(this.hass,"automation",this.automationId,this._runId);this._logbookEntries=(0,n.x)(this.hass.config,"logbook")?await(0,$.gd)(this.hass,t.timestamp.start,t.context.id):[],this._trace=t}_downloadTrace(){const t=JSON.stringify({trace:this._trace,logbookEntries:this._logbookEntries},void 0,2),a=new Blob([t],{type:"application/json"}),i=URL.createObjectURL(a);(0,C.R)(i,`trace ${this._entityId} ${this._trace.timestamp.start}.json`)}_importTrace(){const t=prompt(this.hass.localize("ui.panel.config.automation.trace.enter_downloaded_trace"));t&&(window.localStorage.setItem("devTrace",t),this._loadLocalTrace(t))}_loadLocalStorageTrace(){const t=window.localStorage.getItem("devTrace");t&&this._loadLocalTrace(t)}_loadLocalTrace(t){const a=JSON.parse(t);this._trace=a.trace,this._logbookEntries=a.logbookEntries}_handleTabChanged(t){this._view=t.detail.name}_timelinePathPicked(t){const a=t.detail.value,i=this._graph.trackedNodes;i[a]&&(this._selected=i[a])}_showInfo(){this.hass&&this._entityId&&(0,h.r)(this,"hass-more-info",{entityId:this._entityId})}_navigateToAutomation(){this._entityId&&this.hass.states[this._entityId]&&(0,c.oo)(`/config/automation/edit/${encodeURIComponent(this.hass.states[this._entityId].attributes.id)}`)}_handleDropdownSelect(t){const a=t.detail?.item?.value;if(a)switch(a){case"show_info":this._showInfo();break;case"refresh":this._refreshTraces();break;case"download_trace":this._downloadTrace();break;case"edit_automation":this._navigateToAutomation()}}static get styles(){return[x.RF,s.AH`.toolbar{display:flex;align-items:center;justify-content:center;font-size:var(--ha-font-size-xl);height:var(--header-height);padding:4px;background-color:var(--primary-background-color);font-weight:var(--ha-font-weight-normal);color:var(--app-header-text-color,#fff);border-bottom:var(--app-header-border-bottom,none);box-sizing:border-box}.main{flex:1;min-height:0;display:flex;overflow:hidden;background-color:var(--card-background-color);direction:ltr}:host([narrow]) .main{flex:none;height:auto;flex-direction:column;overflow:visible}.container{padding:16px}.graph{border-right:1px solid var(--divider-color);max-width:50%;box-sizing:border-box;display:flex;flex-direction:column;overflow:hidden}hat-script-graph{flex:1;min-width:0;min-height:0}:host([narrow]) .graph{max-width:100%;overflow:visible;height:auto}:host([narrow]) hat-script-graph{overflow:visible;flex:none}.info{flex:1;overflow-y:auto;background-color:var(--card-background-color)}ha-tab-group{background-color:var(--primary-background-color);border-bottom:1px solid var(--divider-color);direction:var(--direction)}ha-tab-group-tab::part(base){padding:2px 16px}:host([narrow]) .info{overflow:visible}.trace-link{text-decoration:none}ha-trace-logbook{direction:var(--direction)}ha-trace-picker{flex-grow:1;max-width:500px}`]}constructor(...t){super(...t),this.isWide=!1,this.narrow=!1,this._view="details"}}(0,e.Cg)([(0,r.MZ)({attribute:!1})],N.prototype,"hass",void 0),(0,e.Cg)([(0,r.MZ)({attribute:!1})],N.prototype,"automationId",void 0),(0,e.Cg)([(0,r.MZ)({attribute:!1})],N.prototype,"automations",void 0),(0,e.Cg)([(0,r.MZ)({attribute:"is-wide",type:Boolean})],N.prototype,"isWide",void 0),(0,e.Cg)([(0,r.MZ)({type:Boolean,reflect:!0})],N.prototype,"narrow",void 0),(0,e.Cg)([(0,r.MZ)({attribute:!1})],N.prototype,"route",void 0),(0,e.Cg)([(0,r.wk)()],N.prototype,"_entityId",void 0),(0,e.Cg)([(0,r.wk)()],N.prototype,"_traces",void 0),(0,e.Cg)([(0,r.wk)()],N.prototype,"_runId",void 0),(0,e.Cg)([(0,r.wk)()],N.prototype,"_selected",void 0),(0,e.Cg)([(0,r.wk)()],N.prototype,"_trace",void 0),(0,e.Cg)([(0,r.wk)()],N.prototype,"_logbookEntries",void 0),(0,e.Cg)([(0,r.wk)()],N.prototype,"_view",void 0),(0,e.Cg)([(0,r.P)("hat-script-graph")],N.prototype,"_graph",void 0),N=(0,e.Cg)([(0,r.EM)("ha-automation-trace")],N),o()}catch(t){o(t)}})}};