iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 12.9 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[82333],{22547:function(t,e,i){i.d(e,{t:function(){return n}});const n=(t,e)=>t.substring(0,e.length)===e},72190:function(t,e,i){i.d(e,{c:function(){return y}});i(74423),i(45367),i(92731),i(62953);var n=i(90433),s=i(79468),o=i(39274),r=i(71727),a=i(69093),c=i(15090),l=i(52658),d=i(80880),h=i(22675),u=i(86030);const _={media_player:{paused:.5,idle:1},vacuum:{returning:.5}};let g=0;const v=new Map;function y(t,e,i){return function(t,e,i){var n;if(!i||t===h.Hh)return(0,u.a)("--history-unavailable-color",e);if(t===h.HV)return(0,u.a)("--history-unknown-color",e);const a=(0,r.m)(i.entity_id);if(("person"===a||"device_tracker"===a)&&!(c.vB[a]||[]).includes(t))return(0,u.a)(`--state-${a}-${(0,d.Y)(t,"_")}-color`,e);const g=(0,l.mg)(i,t);if(!g)return;const v=(0,u.a)(g,e);if(!v)return;const y=null===(n=_[a])||void 0===n?void 0:n[t];return y?(0,s.zm)((0,o.T)((0,s.Nc)((0,s.xp)(v)),y)):v}(t,e,i)||function(t,e,i){if(!i)return;const s=(0,a.t)(i),o=(c.vB[s]||"sensor"===s&&"enum"===i.attributes.device_class&&i.attributes.options||[]).indexOf(t);return-1!==o?(0,n.fI)(o,e):void 0}(t,e,i)||function(t,e){if(v.has(t))return v.get(t);const i=(0,n.fI)(g,e);return g++,v.set(t,i),i}(t,e)}},61165:function(t,e,i){i.d(e,{AB:function(){return l},Ci:function(){return c},E4:function(){return o},d1:function(){return r},gq:function(){return a}});i(16280),i(94490),i(18111),i(20116);if(66649!=i.j)var n=i(22547);var s=i(88249);const o=(t,e,i,n)=>t.callWS({type:"trace/get",domain:e,item_id:i,run_id:n}),r=(t,e,i)=>t.callWS({type:"trace/list",domain:e,item_id:i}),a=(t,e,i)=>t.callWS({type:"trace/contexts",domain:e,item_id:i}),c=(t,e)=>{const i=e.split("/").reverse();let n=t;for(;i.length;){const t=i.pop(),e=Number(t);if(isNaN(e)){let e=n[t];if(!e&&"sequence"===t)continue;e||"trigger"!==t||(e=n.triggers),e||"condition"!==t||(e=n.conditions),e||"action"!==t||(e=n.actions),n="trigger"===t?(0,s.aI)(e):e;continue}if(Array.isArray(n))n=n[e];else if(0!==e)throw new Error("If config is not an array, can only return index 0")}return n},l=t=>"trigger"===t||(0,n.t)(t,"trigger/")},11184:function(t,e,i){i.a(t,async function(t,e){try{i(74423),i(44114),i(18111),i(61701),i(27495),i(25440),i(62953);var n=i(40445),s=i(5124),o=i(67576),r=i(6412),a=i(89784),c=i(36312),l=i(72487),d=i(30162),h=i(26218),u=i(1087),_=i(71727),g=i(91926),v=i(72190),y=i(74281),m=(i(43661),i(36158)),p=i(95350),x=i(86531),f=i(14503),b=i(85614),$=i(44144),k=t([y,m,x,l,d]);[y,m,x,l,d]=k.then?(await k)():k;let C,w,z,I,M,q,E,S,B,N,T,P,W,Z,L,U,D,H,O=t=>t;const j=["script","automation"],A=t=>t.context_event_type||t.context_state||t.context_message,F=(t,e)=>e?t.replace(e," "):t;class G extends s.WF{willUpdate(t){(!this.hasUpdated&&this.virtualize||t.has("virtualize")&&this.virtualize)&&(this.hass.loadBackendTranslation("services"),this.hass.loadBackendTranslation("title"),(0,b.i)())}shouldUpdate(t){const e=t.get("hass"),i=void 0===e||e.locale!==this.hass.locale;return t.has("entries")||t.has("traceContexts")||i}render(){var t;return null!==(t=this.entries)&&void 0!==t&&t.length?(0,s.qy)(w||(w=O` <div class="container ha-scrollbar ${0}" ="${0}"> ${0} </div> `),(0,r.H)({narrow:this.narrow,"no-name":this.noName,"no-icon":this.noIcon}),this._saveScrollPos,this.virtualize?(0,s.qy)(z||(z=O`<lit-virtualizer ="${0}" scroller class="ha-scrollbar" .items="${0}" .renderItem="${0}"> </lit-virtualizer>`),this._visibilityChanged,this.entries,this._renderLogbookItem):this.entries.map((t,e)=>this._renderLogbookItem(t,e))):(0,s.qy)(C||(C=O` <div class="container no-entries"> ${0} </div> `),this.hass.localize("ui.components.logbook.entries_not_found"))}_saveScrollPos(t){this._savedScrollPos=t.target.scrollTop}_visibilityChanged(t){(0,u.r)(this,"hass-logbook-live",{enable:0===t.first})}_renderIndicator(t){const e=this.hass.states[t.entity_id],i=getComputedStyle(this),n={backgroundColor:void 0!==t.state?(0,v.c)(t.state,i,e):void 0};return(0,s.qy)(I||(I=O` <div class="indicator" style="${0}"></div> `),(0,a.W)(n))}_renderMessage(t,e,i,n,s){if(t.entity_id&&t.state)return n?(0,x.a$)(this.hass,this.hass.localize,t.state,n,i):t.state;const o=A(t);let r=t.message;if(j.includes(i)&&t.source){if(o)return"";r=(0,x.$O)(this.hass.localize,t.source)}return r?this._formatMessageWithPossibleEntity(o?F(r,t.context_entity_id):r,e,void 0,s):""}_renderUser(t){const e=t.context_user_id&&this.userIdToName[t.context_user_id];return e?`- ${e}`:""}_renderUnseenContextSourceEntity(t,e,i){return!t.context_entity_id||e.includes(t.context_entity_id)?"":(0,s.qy)(M||(M=O` (${0})`),this._renderEntity(t.context_entity_id,t.context_entity_id_name,i))}_renderContextMessage(t,e,i){if(t.context_state){const e=t.context_entity_id&&t.context_entity_id in this.hass.states?(0,x.dG)(this.hass.states[t.context_entity_id],t.context_state):void 0;return(0,s.qy)(q||(q=O`${0} ${0} ${0}`),this.hass.localize("ui.components.logbook.triggered_by_state_of"),this._renderEntity(t.context_entity_id,t.context_entity_id_name,i),e?(0,x.a$)(this.hass,this.hass.localize,t.context_state,e,(0,_.m)(t.context_entity_id)):t.context_state)}var n;if("call_service"===t.context_event_type)return(0,s.qy)(E||(E=O`${0} ${0}`),this.hass.localize("ui.components.logbook.triggered_by_action"),t.context_domain&&t.context_service?`${(0,p.p$)(this.hass.localize,t.context_domain)}:\n ${this.hass.localize(`component.${t.context_domain}.services.${t.context_service}.name`,this.hass.services[t.context_domain][t.context_service].description_placeholders)||(null===(n=this.hass.services[t.context_domain])||void 0===n||null===(n=n[t.context_service])||void 0===n?void 0:n.name)||t.context_service}`:"");if(!t.context_message||e.includes(t.context_entity_id))return"";if("automation_triggered"===t.context_event_type||"script_started"===t.context_event_type){const n=t.context_source?t.context_source:t.context_message.replace("triggered by ",""),o=(0,x.$O)(this.hass.localize,n);return(0,s.qy)(S||(S=O`${0} ${0} ${0}`),this.hass.localize("automation_triggered"===t.context_event_type?"ui.components.logbook.triggered_by_automation":"ui.components.logbook.triggered_by_script"),this._renderEntity(t.context_entity_id,t.context_entity_id_name,i),t.context_message?this._formatMessageWithPossibleEntity(o,e,void 0,i):"")}return(0,s.qy)(B||(B=O` ${0} ${0} ${0} ${0}`),this.hass.localize("ui.components.logbook.triggered_by"),t.context_name,this._formatMessageWithPossibleEntity(t.context_message,e,t.context_entity_id,i),this._renderUnseenContextSourceEntity(t,e,i))}_renderEntity(t,e,i){const n=t&&t in this.hass.states,o=e||n&&this.hass.states[t].attributes.friendly_name||t;return n?i?o:(0,s.qy)(N||(N=O`<button class="link" ="${0}" .entityId="${0}"> ${0} </button>`),this._entityClicked,t,o):o}_formatMessageWithPossibleEntity(t,e,i,n){if(-1!==t.indexOf(".")){const i=t.split(" ");for(let t=0,o=i.length;t<o;t++)if(i[t]in this.hass.states){const o=i[t];if(e.includes(o))return"";e.push(o);const r=i.splice(t);return r.shift(),(0,s.qy)(T||(T=O`${0} ${0} ${0}`),i.join(" "),this._renderEntity(o,this.hass.states[o].attributes.friendly_name,n),r.join(" "))}}if(i&&i in this.hass.states){const o=this.hass.states[i].attributes.friendly_name;if(o&&t.endsWith(o))return e.includes(i)?"":(e.push(i),t=t.substring(0,t.length-o.length),(0,s.qy)(P||(P=O`${0} ${0}`),t,this._renderEntity(i,o,n)))}return t}_entityClicked(t){const e=t.currentTarget.entityId;e&&(t.preventDefault(),t.stopPropagation(),(0,u.r)(this,"hass-more-info",{entityId:e}))}_handleClick(t){const e=t.currentTarget;e.traceLink&&((0,g.oo)(e.traceLink),(0,u.r)(this,"closed"))}static get styles(){return[f.RF,f.dp,f.og,(0,s.AH)(W||(W=O`:host([virtualize]){display:block;height:100%}.entry-container{width:100%}.entry{position:relative;display:flex;width:100%;line-height:var(--ha-line-height-expanded);padding:8px 16px;box-sizing:border-box;border-top:1px solid var(--divider-color);justify-content:space-between;align-items:center}.indicator{background-color:var(--disabled-color);height:8px;width:8px;border-radius:var(--ha-border-radius-sm);flex-shrink:0;margin-right:12px;margin-inline-start:initial;margin-inline-end:12px;direction:var(--direction)}ha-icon-next{color:var(--secondary-text-color)}.clickable{cursor:pointer}:not(.clickable) .entry.no-entity,:not(.clickable) .no-name .entry{cursor:default}.entry:hover{background-color:rgba(var(--rgb-primary-text-color),.04)}.narrow:not(.no-icon) .time{margin-left:32px;margin-inline-start:32px;margin-inline-end:initial;direction:var(--direction)}.message-relative_time{display:flex;flex-direction:column}.secondary{font-size:var(--ha-font-size-s);line-height:var(--ha-line-height-normal)}.secondary a{color:var(--secondary-text-color)}.date{margin:8px 0;padding:0 16px}.icon-message{display:flex;align-items:center}.no-entries{text-align:center;color:var(--secondary-text-color)}state-badge{margin-right:16px;margin-inline-start:initial;flex-shrink:0;color:var(--state-icon-color);margin-inline-end:16px;direction:var(--direction)}.message{color:var(--primary-text-color)}.no-name .message:first-letter{text-transform:capitalize}a{color:var(--primary-color);text-decoration:none}button.link{color:var(--state-icon-color);text-decoration:none}.container{max-height:var(--logbook-max-height)}.container,lit-virtualizer{height:100%}lit-virtualizer{contain:size layout!important}.narrow .entry{line-height:var(--ha-line-height-normal)}.narrow .icon-message state-badge{margin-left:0;margin-inline-start:0;margin-right:8px;margin-inline-end:8px;direction:var(--direction)}`))]}constructor(...t){super(...t),this.userIdToName={},this.traceContexts={},this.entries=[],this.narrow=!1,this.virtualize=!1,this.showIndicator=!1,this.noIcon=!1,this.noName=!1,this.relativeTime=!1,this._renderLogbookItem=(t,e)=>{var i;if(!t||void 0===e)return s.s6;const n=this.entries[e-1],o=[],a=t.entity_id?this.hass.states[t.entity_id]:void 0,h=a?(0,x.dG)(a,t.state):void 0,u=t.entity_id?(0,_.m)(t.entity_id):t.domain,g=h||t.icon||t.state||!u||!(0,c.x)(this.hass.config,u)?void 0:(0,$.MR)({domain:u,type:"icon",darkOptimized:null===(i=this.hass.themes)||void 0===i?void 0:i.darkMode},this.hass.auth.data.hassUrl),v=j.includes(t.domain)&&t.context_id&&t.context_id in this.traceContexts?this.traceContexts[t.context_id]:void 0,y=void 0!==v;return(0,s.qy)(Z||(Z=O` <div class="entry-container ${0}" .traceLink="${0}" ="${0}"> ${0} <div class="entry ${0}"> <div class="icon-message"> ${0} ${0} <div class="message-relative_time"> <div class="message"> ${0} ${0} ${0} </div> <div class="secondary"> <span>${0}</span> - <ha-relative-time .hass="${0}" .datetime="${0}" capitalize></ha-relative-time> ${0} ${0} </div> </div> </div> ${0} </div> </div> `),(0,r.H)({clickable:y}),v?`/config/${v.domain}/trace/${v.item_id}?run_id=${v.run_id}`:void 0,this._handleClick,0===e||null!=t&&t.when&&null!=n&&n.when&&new Date(1e3*t.when).toDateString()!==new Date(1e3*n.when).toDateString()?(0,s.qy)(L||(L=O` <h4 class="date"> ${0} </h4> `),(0,l.Yq)(new Date(1e3*t.when),this.hass.locale,this.hass.config)):s.s6,(0,r.H)({"no-entity":!t.entity_id}),this.noIcon?"":(0,s.qy)(U||(U=O` <state-badge .hass="${0}" .overrideIcon="${0}" .overrideImage="${0}" .stateObj="${0}" .stateColor="${0}"></state-badge> `),this.hass,t.icon,g,t.icon?void 0:h,!1),this.showIndicator?this._renderIndicator(t):"",this.noName?"":this._renderEntity(t.entity_id,t.name,y),this._renderMessage(t,o,u,h,y),this._renderContextMessage(t,o,y),(0,d.ie)(new Date(1e3*t.when),this.hass.locale,this.hass.config),this.hass,1e3*t.when,t.context_user_id?(0,s.qy)(D||(D=O`${0}`),this._renderUser(t)):"",y?`- ${this.hass.localize("ui.components.logbook.show_trace")}`:"",y?(0,s.qy)(H||(H=O`<ha-icon-next></ha-icon-next>`)):"")}}}(0,n.Cg)([(0,o.MZ)({attribute:!1})],G.prototype,"hass",void 0),(0,n.Cg)([(0,o.MZ)({attribute:!1})],G.prototype,"userIdToName",void 0),(0,n.Cg)([(0,o.MZ)({attribute:!1})],G.prototype,"traceContexts",void 0),(0,n.Cg)([(0,o.MZ)({attribute:!1})],G.prototype,"entries",void 0),(0,n.Cg)([(0,o.MZ)({type:Boolean,attribute:"narrow"})],G.prototype,"narrow",void 0),(0,n.Cg)([(0,o.MZ)({type:Boolean,attribute:"virtualize",reflect:!0})],G.prototype,"virtualize",void 0),(0,n.Cg)([(0,o.MZ)({type:Boolean,attribute:"show-indicator"})],G.prototype,"showIndicator",void 0),(0,n.Cg)([(0,o.MZ)({type:Boolean,attribute:"no-icon"})],G.prototype,"noIcon",void 0),(0,n.Cg)([(0,o.MZ)({type:Boolean,attribute:"no-name"})],G.prototype,"noName",void 0),(0,n.Cg)([(0,o.MZ)({type:Boolean,attribute:"relative-time"})],G.prototype,"relativeTime",void 0),(0,n.Cg)([(0,h.a)(".container")],G.prototype,"_savedScrollPos",void 0),(0,n.Cg)([(0,o.Ls)({passive:!0})],G.prototype,"_saveScrollPos",null),(0,n.Cg)([(0,o.Ls)({passive:!0})],G.prototype,"_visibilityChanged",null),G=(0,n.Cg)([(0,o.EM)("ha-logbook-renderer")],G),e()}catch(C){e(C)}})}}]);