UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 11.9 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[52422],{74706:function(t,i,e){e.a(t,async function(t,a){try{e.r(i),e.d(i,{HaScriptTrace:function(){return tt}});e(94490),e(18111),e(20116),e(13579),e(69112),e(33110),e(3362),e(27495),e(62953),e(3296),e(27208),e(48408),e(14603),e(47566),e(98721);var o=e(40445),s=(e(68825),e(35211)),r=e(5124),n=e(67576),c=e(36312),h=e(1087),d=e(91926),l=e(18350),p=e(29823),_=(e(70947),e(26300)),g=e(66289),u=(e(62647),e(98920)),v=e(7370),b=e(193),w=e(29804),f=e(73003),$=e(68886),y=e(22792),k=e(86531),m=e(61165),I=e(65063),C=e(81310),x=e(14503),T=e(30039),A=e(48240),L=t([l,p,_,g,u,v,b,w,f,$,C,A,k]);[l,p,_,g,u,v,b,w,f,$,C,A,k]=L.then?(await L)():L;let M,H,E,q,z,S,Z,V,N,R,U,P,O,j,B,D=t=>t;const F="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",W="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",J="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",G="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",K="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",X="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",Y=["details","timeline","logbook","config"];class tt extends r.WF{render(){var t;const i=this._entityId?this.hass.states[this._entityId]:void 0,e=this._graph,a=null==e?void 0:e.trackedNodes,o=null==e?void 0:e.renderedNodes,s=(null==i?void 0:i.attributes.friendly_name)||this._entityId;return(0,r.qy)(M||(M=D` ${0} <hass-subpage .hass="${0}" .narrow="${0}" .header="${0}" .scrollable="${0}"> ${0} <ha-dropdown slot="toolbar-icon" @wa-select="${0}"> <ha-icon-button slot="trigger" .label="${0}" .path="${0}"></ha-icon-button> <ha-dropdown-item .disabled="${0}" value="show_info"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> ${0} <wa-divider></wa-divider> <ha-dropdown-item value="refresh"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> <ha-dropdown-item .disabled="${0}" value="download_trace"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> </ha-dropdown> <div class="toolbar"> ${0} </div> ${0} </hass-subpage> `),"",this.hass,this.narrow,s,this.narrow,!this.narrow&&this.scriptId?(0,r.qy)(H||(H=D` <ha-button class="trace-link" @click="${0}" slot="toolbar-icon" appearance="plain"> ${0} </ha-button> `),this._navigateToScript,this.hass.localize("ui.panel.config.script.trace.edit_script")):r.s6,this._handleDropdownSelect,this.hass.localize("ui.common.menu"),F,!i,this.hass.localize("ui.panel.config.script.editor.show_info"),J,this.narrow&&this.scriptId?(0,r.qy)(E||(E=D`<ha-dropdown-item value="edit_script"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> `),this.hass.localize("ui.panel.config.script.trace.edit_script"),G):r.s6,this.hass.localize("ui.panel.config.automation.trace.refresh"),X,!this._trace,this.hass.localize("ui.panel.config.automation.trace.download_trace"),W,this._traces&&this._traces.length>0?(0,r.qy)(q||(q=D` <ha-icon-button .disabled="${0}" .label="${0}" @click="${0}" .path="${0}"></ha-icon-button> <ha-trace-picker .hass="${0}" .traces="${0}" .value="${0}" @value-changed="${0}"></ha-trace-picker> <ha-icon-button .disabled="${0}" .label="${0}" @click="${0}" .path="${0}"></ha-icon-button> `),this._traces[this._traces.length-1].run_id===this._runId,this.hass.localize("ui.panel.config.automation.trace.older_trace"),this._pickOlderTrace,K,this.hass,this._traces,this._runId,this._pickTrace,this._traces[0].run_id===this._runId,this.hass.localize("ui.panel.config.automation.trace.newer_trace"),this._pickNewerTrace,Q):"",void 0===this._traces?(0,r.qy)(z||(z=D`<div class="container">Loading…</div>`)):0===this._traces.length?(0,r.qy)(S||(S=D`<div class="container"> ${0} </div>`),this.hass.localize("ui.panel.config.automation.trace.no_traces_found")):void 0===this._trace?"":(0,r.qy)(Z||(Z=D` <div class="main"> <div class="graph"> <hat-script-graph .hass="${0}" .trace="${0}" .selected="${0}" @graph-node-selected="${0}"></hat-script-graph> </div> <div class="info"> <ha-tab-group @wa-tab-show="${0}"> ${0} ${0} </ha-tab-group> ${0} </div> </div> `),this.hass,this._trace,null===(t=this._selected)||void 0===t?void 0:t.path,this._pickNode,this._handleTabChanged,Y.map(t=>(0,r.qy)(V||(V=D` <ha-tab-group-tab slot="nav" .active="${0}" .panel="${0}"> ${0} </ha-tab-group-tab> `),this._view===t,t,this.hass.localize(`ui.panel.config.automation.trace.tabs.${"config"===t?"script_config":t}`))),this._trace.blueprint_inputs?(0,r.qy)(N||(N=D` <ha-tab-group-tab slot="nav" .active="${0}" panel="blueprint"> ${0} </ha-tab-group-tab> `),"blueprint"===this._view,this.hass.localize("ui.panel.config.automation.trace.tabs.blueprint_config")):"",void 0===this._selected||void 0===this._logbookEntries||void 0===a?"":"details"===this._view?(0,r.qy)(R||(R=D` <ha-trace-path-details .hass="${0}" .narrow="${0}" .trace="${0}" .selected="${0}" .logbookEntries="${0}" .trackedNodes="${0}" .renderedNodes="${0}"></ha-trace-path-details> `),this.hass,this.narrow,this._trace,this._selected,this._logbookEntries,a,o):"config"===this._view?(0,r.qy)(U||(U=D` <ha-trace-config .trace="${0}"></ha-trace-config> `),this._trace):"logbook"===this._view?(0,r.qy)(P||(P=D` <ha-trace-logbook .hass="${0}" .narrow="${0}" .trace="${0}" .logbookEntries="${0}"></ha-trace-logbook> `),this.hass,this.narrow,this._trace,this._logbookEntries):"blueprint"===this._view?(0,r.qy)(O||(O=D` <ha-trace-blueprint-config .trace="${0}"></ha-trace-blueprint-config> `),this._trace):(0,r.qy)(j||(j=D` <ha-trace-timeline .hass="${0}" .trace="${0}" .logbookEntries="${0}" .selected="${0}" @value-changed="${0}"></ha-trace-timeline> `),this.hass,this._trace,this._logbookEntries,this._selected,this._timelinePathPicked)))}firstUpdated(t){var i;if(super.firstUpdated(t),!this.scriptId)return;const e=new URLSearchParams(location.search);this._loadTraces(e.get("run_id")||void 0),this._entityId=null===(i=this._entityRegistry.find(t=>t.unique_id===this.scriptId))||void 0===i?void 0:i.entity_id}willUpdate(t){var i;(super.willUpdate(t),t.get("scriptId"))&&(this._traces=void 0,this._runId=void 0,this._trace=void 0,this._logbookEntries=void 0,this.scriptId&&(this._loadTraces(),this._entityId=null===(i=this._entityRegistry.find(t=>t.unique_id===this.scriptId))||void 0===i?void 0:i.entity_id));t.has("_runId")&&this._runId&&(this._trace=void 0,this._logbookEntries=void 0,this._loadTrace())}_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,m.d1)(this.hass,"script",this.scriptId),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,I.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,m.E4)(this.hass,"script",this.scriptId,this._runId);this._logbookEntries=(0,c.x)(this.hass.config,"logbook")?await(0,k.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),i=new Blob([t],{type:"application/json"}),e=URL.createObjectURL(i);(0,T.R)(e,`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 i=JSON.parse(t);this._trace=i.trace,this._logbookEntries=i.logbookEntries}_handleTabChanged(t){this._view=t.detail.name}_timelinePathPicked(t){const i=t.detail.value,e=this._graph.trackedNodes;e[i]&&(this._selected=e[i])}async _showInfo(){this._entityId&&(0,h.r)(this,"hass-more-info",{entityId:this._entityId})}_navigateToScript(){this.scriptId&&(0,d.oo)(`/config/script/edit/${this.scriptId}`)}_handleDropdownSelect(t){var i;const e=null===(i=t.detail)||void 0===i||null===(i=i.item)||void 0===i?void 0:i.value;if(e)switch(e){case"show_info":this._showInfo();break;case"refresh":this._refreshTraces();break;case"download_trace":this._downloadTrace();break;case"edit_script":this._navigateToScript()}}static get styles(){return[x.RF,(0,r.AH)(B||(B=D`.toolbar{display:flex;align-items:center;justify-content:center;height:var(--header-height);background-color:var(--primary-background-color);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)}: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-picker{flex-grow:1;max-width:500px}`))]}constructor(...t){super(...t),this.isWide=!1,this.narrow=!1,this._view="details"}}(0,o.Cg)([(0,n.MZ)({attribute:!1})],tt.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],tt.prototype,"scriptId",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],tt.prototype,"scripts",void 0),(0,o.Cg)([(0,n.MZ)({attribute:"is-wide",type:Boolean})],tt.prototype,"isWide",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],tt.prototype,"narrow",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],tt.prototype,"route",void 0),(0,o.Cg)([(0,n.wk)(),(0,s.Fg)({context:y.ih,subscribe:!0})],tt.prototype,"_entityRegistry",void 0),(0,o.Cg)([(0,n.wk)()],tt.prototype,"_entityId",void 0),(0,o.Cg)([(0,n.wk)()],tt.prototype,"_traces",void 0),(0,o.Cg)([(0,n.wk)()],tt.prototype,"_runId",void 0),(0,o.Cg)([(0,n.wk)()],tt.prototype,"_selected",void 0),(0,o.Cg)([(0,n.wk)()],tt.prototype,"_trace",void 0),(0,o.Cg)([(0,n.wk)()],tt.prototype,"_logbookEntries",void 0),(0,o.Cg)([(0,n.wk)()],tt.prototype,"_view",void 0),(0,o.Cg)([(0,n.P)("hat-script-graph")],tt.prototype,"_graph",void 0),tt=(0,o.Cg)([(0,n.EM)("ha-script-trace")],tt),a()}catch(M){a(M)}})}}]);