UNPKG

iobroker.lovelace

Version:

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

65 lines (60 loc) 15.7 kB
/*! For license information please see chunk.b32d61c070c4d275f56f.js.LICENSE.txt */ (self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[4302],{24731:(e,t,r)=>{"use strict";r.d(t,{s:()=>i.s});var i=r(78389)},13690:(e,t,r)=>{"use strict";r.d(t,{r:()=>a});var i=r(99602),o=r(55122),n=r(57724);const s=(e,t,r)=>{const i=new Map;for(let o=t;o<=r;o++)i.set(e[o],o);return i},a=(0,o.XM)(class extends o.Xe{constructor(e){if(super(e),e.type!==o.pX.CHILD)throw Error("repeat() can only be used in text expressions")}Mt(e,t,r){let i;void 0===r?r=t:void 0!==t&&(i=t);const o=[],n=[];let s=0;for(const t of e)o[s]=i?i(t,s):s,n[s]=r(t,s),s++;return{values:n,keys:o}}render(e,t,r){return this.Mt(e,t,r).values}update(e,[t,r,o]){var a;const l=(0,n.i9)(e),{values:c,keys:d}=this.Mt(t,r,o);if(!l)return this.Pt=d,c;const h=null!==(a=this.Pt)&&void 0!==a?a:this.Pt=[],f=[];let u,p,m=0,y=l.length-1,g=0,v=c.length-1;for(;m<=y&&g<=v;)if(null===l[m])m++;else if(null===l[y])y--;else if(h[m]===d[g])f[g]=(0,n.fk)(l[m],c[g]),m++,g++;else if(h[y]===d[v])f[v]=(0,n.fk)(l[y],c[v]),y--,v--;else if(h[m]===d[v])f[v]=(0,n.fk)(l[m],c[v]),(0,n._Y)(e,f[v+1],l[m]),m++,v--;else if(h[y]===d[g])f[g]=(0,n.fk)(l[y],c[g]),(0,n._Y)(e,l[m],l[y]),y--,g++;else if(void 0===u&&(u=s(d,g,v),p=s(h,m,y)),u.has(h[m]))if(u.has(h[y])){const t=p.get(d[g]),r=void 0!==t?l[t]:null;if(null===r){const t=(0,n._Y)(e,l[m]);(0,n.fk)(t,c[g]),f[g]=t}else f[g]=(0,n.fk)(r,c[g]),(0,n._Y)(e,l[m],r),l[t]=null;g++}else(0,n.ws)(l[y]),y--;else(0,n.ws)(l[m]),m++;for(;g<=v;){const t=(0,n._Y)(e,f[v+1]);(0,n.fk)(t,c[g]),f[g++]=t}for(;m<=y;){const e=l[m++];null!==e&&(0,n.ws)(e)}return this.Pt=d,(0,n.hl)(e,f),i.Jb}})},25516:(e,t,r)=>{"use strict";r.d(t,{i:()=>i});const i=e=>t=>({kind:"method",placement:"prototype",key:t.key,descriptor:{set(e){this[`__${String(t.key)}`]=e},get(){return this[`__${String(t.key)}`]},enumerable:!0,configurable:!0},finisher(r){const i=r.prototype.connectedCallback;r.prototype.connectedCallback=function(){if(i.call(this),this[t.key]){const r=this.renderRoot.querySelector(e);if(!r)return;r.scrollTop=this[t.key]}}}})},8436:(e,t,r)=>{"use strict";r.r(t),r.d(t,{HuiLogbookCard:()=>E});var i=r(50424),o=r(55358),n=r(76666),s=r(7323),a=r(62877),l=r(22311),c=r(8330),d=(r(22098),r(31206),r(55422)),h=(r(97740),r(15688)),f=r(90271);r(75502);function u(){u=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var o=t.placement;if(t.kind===i&&("static"===o||"prototype"===o)){var n="static"===o?e:r;this.defineClassElement(n,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],o={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,o)}),this),e.forEach((function(e){if(!y(e))return r.push(e);var t=this.decorateElement(e,o);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var n=this.decorateConstructor(r,t);return i.push.apply(i,n.finishers),n.finishers=i,n},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],o=e.decorators,n=o.length-1;n>=0;n--){var s=t[e.placement];s.splice(s.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,o[n])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var o=this.fromClassDescriptor(e),n=this.toClassDescriptor((0,t[i])(o)||o);if(void 0!==n.finisher&&r.push(n.finisher),void 0!==n.elements){e=n.elements;for(var s=0;s<e.length-1;s++)for(var a=s+1;a<e.length;a++)if(e[s].key===e[a].key&&e[s].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[s].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=k(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+i+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var n={kind:t,key:r,placement:i,descriptor:Object.assign({},o)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(o,"get","The property descriptor of a field descriptor"),this.disallowProperty(o,"set","The property descriptor of a field descriptor"),this.disallowProperty(o,"value","The property descriptor of a field descriptor"),n.initializer=e.initializer),n},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:v(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=v(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function p(e){var t,r=k(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function m(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function y(e){return e.decorators&&e.decorators.length}function g(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function v(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function k(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function w(e,t,r){return(w="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var i=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_(e)););return e}(e,t);if(i){var o=Object.getOwnPropertyDescriptor(i,t);return o.get?o.get.call(r):o.value}})(e,t,r||e)}function _(e){return(_=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}let E=function(e,t,r,i){var o=u();if(i)for(var n=0;n<i.length;n++)o=i[n](o);var s=t((function(e){o.initializeInstanceElements(e,a.elements)}),r),a=o.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===n.key&&e.placement===n.placement},i=0;i<e.length;i++){var o,n=e[i];if("method"===n.kind&&(o=t.find(r)))if(g(n.descriptor)||g(o.descriptor)){if(y(n)||y(o))throw new ReferenceError("Duplicated methods ("+n.key+") can't be decorated.");o.descriptor=n.descriptor}else{if(y(n)){if(y(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+n.key+").");o.decorators=n.decorators}m(n,o)}else t.push(n)}return t}(s.d.map(p)),e);return o.initializeClassElements(s.F,a.elements),o.runClassFinishers(s.F,a.finishers)}([(0,o.Mo)("hui-logbook-card")],(function(e,t){class u extends t{constructor(...t){super(...t),e(this)}}return{F:u,d:[{kind:"method",static:!0,key:"getConfigElement",value:async function(){return await Promise.all([r.e(5009),r.e(2955),r.e(8161),r.e(1041),r.e(1657),r.e(4268),r.e(3098),r.e(6087),r.e(4159),r.e(4535),r.e(6902),r.e(4237)]).then(r.bind(r,74237)),document.createElement("hui-logbook-card-editor")}},{kind:"method",static:!0,key:"getStubConfig",value:function(e,t,r){return{entities:(0,h.j)(e,3,t,r,["light","switch"])}}},{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_config",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_logbookEntries",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_persons",value:()=>({})},{kind:"field",decorators:[(0,o.SB)()],key:"_configEntities",value:void 0},{kind:"field",key:"_lastLogbookDate",value:void 0},{kind:"field",key:"_throttleGetLogbookEntries",value(){return(0,c.P)((()=>{this._getLogBookData()}),1e4)}},{kind:"method",key:"getCardSize",value:function(){var e;return 9+(null!==(e=this._config)&&void 0!==e&&e.title?1:0)}},{kind:"method",key:"setConfig",value:function(e){if(!e.entities.length)throw new Error("Entities must be specified");this._configEntities=(0,f.A)(e.entities),this._config={hours_to_show:24,...e}}},{kind:"method",key:"shouldUpdate",value:function(e){if(e.has("_config")||e.has("_persons")||e.has("_logbookEntries"))return!0;const t=e.get("hass");if(!this._configEntities||!t||t.themes!==this.hass.themes||t.locale!==this.hass.locale)return!0;for(const e of this._configEntities)if(t.states[e.entity]!==this.hass.states[e.entity])return!0;return!1}},{kind:"method",key:"firstUpdated",value:function(){this._fetchPersonNames()}},{kind:"method",key:"updated",value:function(e){if(w(_(u.prototype),"updated",this).call(this,e),!this._config||!this.hass)return;const t=e.has("_config"),r=e.has("hass"),i=e.get("hass"),o=e.get("_config");if((r&&(null==i?void 0:i.themes)!==this.hass.themes||t&&(null==o?void 0:o.theme)!==this._config.theme)&&(0,a.R)(this,this.hass.themes,this._config.theme),!t||(null==o?void 0:o.entities)===this._config.entities&&(null==o?void 0:o.hours_to_show)===this._config.hours_to_show)i&&this._configEntities.some((e=>i.states[e.entity]!==this.hass.states[e.entity]))&&setTimeout(this._throttleGetLogbookEntries,1e3);else{if(this._logbookEntries=void 0,this._lastLogbookDate=void 0,!this._configEntities)return;this._throttleGetLogbookEntries()}}},{kind:"method",key:"render",value:function(){return this.hass&&this._config?(0,s.p)(this.hass,"logbook")?i.dy` <ha-card .header=${this._config.title} class=${(0,n.$)({"no-header":!this._config.title})} > <div class="content"> ${this._logbookEntries?this._logbookEntries.length?i.dy` <ha-logbook narrow relative-time virtualize .hass=${this.hass} .entries=${this._logbookEntries} .userIdToName=${this._persons} ></ha-logbook> `:i.dy` <div class="no-entries"> ${this.hass.localize("ui.components.logbook.entries_not_found")} </div> `:i.dy` <ha-circular-progress active alt=${this.hass.localize("ui.common.loading")} ></ha-circular-progress> `} </div> </ha-card> `:i.dy` <hui-warning> ${this.hass.localize("ui.components.logbook.component_not_loaded")}</hui-warning > `:i.dy``}},{kind:"method",key:"_getLogBookData",value:async function(){if(!this.hass||!this._config||!(0,s.p)(this.hass,"logbook"))return;const e=new Date((new Date).getTime()-60*this._config.hours_to_show*60*1e3),t=this._lastLogbookDate||e,r=new Date,i=await(0,d.rM)(this.hass,t.toISOString(),r.toISOString(),this._configEntities.map((e=>e.entity)).toString(),!0),o=this._logbookEntries?[...i,...this._logbookEntries]:i;this._logbookEntries=o.filter((t=>new Date(t.when)>e)),this._lastLogbookDate=r}},{kind:"method",key:"_fetchPersonNames",value:function(){this.hass&&Object.values(this.hass.states).forEach((e=>{e.attributes.user_id&&"person"===(0,l.N)(e)&&(this._persons[e.attributes.user_id]=e.attributes.friendly_name)}))}},{kind:"get",static:!0,key:"styles",value:function(){return[i.iv` ha-card { height: 100%; display: flex; flex-direction: column; justify-content: space-between; } .content { padding: 0 16px 16px; } .no-header .content { padding-top: 16px; } .no-entries { text-align: center; padding: 16px; color: var(--secondary-text-color); } ha-logbook { height: 385px; display: block; } ha-circular-progress { display: flex; justify-content: center; } `]}}]}}),i.oi)}}]); //# sourceMappingURL=chunk.b32d61c070c4d275f56f.js.map