UNPKG

iobroker.lovelace

Version:

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

1 lines 12.3 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[14022],{64037:function(t,a,i){i.a(t,async function(t,o){try{i.r(a),i.d(a,{HaAutomationTrace:function(){return Y}});i(94490),i(18111),i(20116),i(13579),i(69112),i(33110),i(3362),i(27495),i(62953),i(3296),i(27208),i(48408),i(14603),i(47566),i(98721);var e=i(40445),s=(i(68825),i(5124)),r=i(67576),n=i(36312),h=i(1087),d=i(91926),c=i(15638),l=i(18350),_=i(29823),u=(i(70947),i(26300)),p=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),C=i(14503),x=i(30039),A=i(48240),T=t([l,_,u,p,g,v,b,m,w,f,I,A,$]);[l,_,u,p,g,v,b,m,w,f,I,A,$]=T.then?(await T)():T;let M,L,z,H,E,q,Z,V,N,S,P,R,U,O,j,B=t=>t;const D="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",F="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",J="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",G="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",K="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",Q="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",X=["details","timeline","logbook","automation_config"];class Y extends s.WF{render(){var t;const a=this._entityId?this.hass.states[this._entityId]:void 0,i=this._graph,o=null==i?void 0:i.trackedNodes,e=null==i?void 0:i.renderedNodes,r=(null==a?void 0:a.attributes.friendly_name)||this._entityId;return(0,s.qy)(M||(M=B` ${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,r,this.narrow,!this.narrow&&null!=a&&a.attributes.id?(0,s.qy)(L||(L=B` <ha-button appearance="plain" size="small" class="trace-link" @click="${0}" slot="toolbar-icon"> ${0} </ha-button> `),this._navigateToAutomation,this.hass.localize("ui.panel.config.automation.trace.edit_automation")):s.s6,this._handleDropdownSelect,this.hass.localize("ui.common.menu"),D,!a,this.hass.localize("ui.panel.config.automation.editor.show_info"),F,null!=a&&a.attributes.id&&this.narrow?(0,s.qy)(z||(z=B` <ha-dropdown-item value="edit_automation"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> `),this.hass.localize("ui.panel.config.automation.trace.edit_automation"),J):s.s6,this.hass.localize("ui.panel.config.automation.trace.refresh"),Q,!this._trace,this.hass.localize("ui.panel.config.automation.trace.download_trace"),W,this._traces&&this._traces.length>0?(0,s.qy)(H||(H=B` <ha-icon-button .label="${0}" .path="${0}" .disabled="${0}" @click="${0}"></ha-icon-button> <ha-trace-picker .hass="${0}" .traces="${0}" .value="${0}" @value-changed="${0}"></ha-trace-picker> <ha-icon-button .label="${0}" .path="${0}" .disabled="${0}" @click="${0}"></ha-icon-button> `),this.hass.localize("ui.panel.config.automation.trace.older_trace"),(0,c.qC)(this.hass.language,this.hass.translationMetadata.translations)?K:G,this._traces[this._traces.length-1].run_id===this._runId,this._pickOlderTrace,this.hass,this._traces,this._runId,this._pickTrace,this.hass.localize("ui.panel.config.automation.trace.newer_trace"),(0,c.qC)(this.hass.language,this.hass.translationMetadata.translations)?G:K,this._traces[0].run_id===this._runId,this._pickNewerTrace):"",void 0===this._traces?(0,s.qy)(E||(E=B`<div class="container"> ${0} </div>`),this.hass.localize("ui.common.loading")):0===this._traces.length?(0,s.qy)(q||(q=B`<div class="container"> ${0} </div>`),this.hass.localize("ui.panel.config.automation.trace.no_traces_found")):void 0===this._trace?"":(0,s.qy)(Z||(Z=B` <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,X.map(t=>(0,s.qy)(V||(V=B` <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.${t}`))),this._trace.blueprint_inputs?(0,s.qy)(N||(N=B` <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===o?s.s6:"details"===this._view?(0,s.qy)(S||(S=B` <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,o,e):"automation_config"===this._view?(0,s.qy)(P||(P=B` <ha-trace-config .trace="${0}"></ha-trace-config> `),this._trace):"logbook"===this._view?(0,s.qy)(R||(R=B` <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,s.qy)(U||(U=B` <ha-trace-blueprint-config .trace="${0}"></ha-trace-blueprint-config> `),this._trace):(0,s.qy)(O||(O=B` <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){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=null==t?void 0: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,x.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,d.oo)(`/config/automation/edit/${encodeURIComponent(this.hass.states[this._entityId].attributes.id)}`)}_handleDropdownSelect(t){var a;const i=null===(a=t.detail)||void 0===a||null===(a=a.item)||void 0===a?void 0:a.value;if(i)switch(i){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[C.RF,(0,s.AH)(j||(j=B`.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})],Y.prototype,"hass",void 0),(0,e.Cg)([(0,r.MZ)({attribute:!1})],Y.prototype,"automationId",void 0),(0,e.Cg)([(0,r.MZ)({attribute:!1})],Y.prototype,"automations",void 0),(0,e.Cg)([(0,r.MZ)({attribute:"is-wide",type:Boolean})],Y.prototype,"isWide",void 0),(0,e.Cg)([(0,r.MZ)({type:Boolean,reflect:!0})],Y.prototype,"narrow",void 0),(0,e.Cg)([(0,r.MZ)({attribute:!1})],Y.prototype,"route",void 0),(0,e.Cg)([(0,r.wk)()],Y.prototype,"_entityId",void 0),(0,e.Cg)([(0,r.wk)()],Y.prototype,"_traces",void 0),(0,e.Cg)([(0,r.wk)()],Y.prototype,"_runId",void 0),(0,e.Cg)([(0,r.wk)()],Y.prototype,"_selected",void 0),(0,e.Cg)([(0,r.wk)()],Y.prototype,"_trace",void 0),(0,e.Cg)([(0,r.wk)()],Y.prototype,"_logbookEntries",void 0),(0,e.Cg)([(0,r.wk)()],Y.prototype,"_view",void 0),(0,e.Cg)([(0,r.P)("hat-script-graph")],Y.prototype,"_graph",void 0),Y=(0,e.Cg)([(0,r.EM)("ha-automation-trace")],Y),o()}catch(M){o(M)}})}}]);