iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 17.4 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[1929],{54531:function(e,t,n){"use strict";function r(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,c=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return s=e.done,e},e:function(e){c=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(c)throw a}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,{zJ:function(){return l},Xr:function(){return u},Qc:function(){return f}});var o=["zone","persistent_notification"],a=function(e,t){if("call-service"===t.action&&t.service_data&&t.service_data.entity_id){var n=t.service_data.entity_id;Array.isArray(n)||(n=[n]);var i,o=r(n);try{for(o.s();!(i=o.n()).done;){var a=i.value;e.add(a)}}catch(s){o.e(s)}finally{o.f()}}},s=function(e,t){"string"!=typeof t?(t.entity&&e.add(t.entity),t.camera_image&&e.add(t.camera_image),t.tap_action&&a(e,t.tap_action),t.hold_action&&a(e,t.hold_action)):e.add(t)},c=function e(t,n){n.entity&&s(t,n.entity),n.entities&&Array.isArray(n.entities)&&n.entities.forEach((function(e){return s(t,e)})),n.card&&e(t,n.card),n.cards&&Array.isArray(n.cards)&&n.cards.forEach((function(n){return e(t,n)})),n.elements&&Array.isArray(n.elements)&&n.elements.forEach((function(n){return e(t,n)})),n.badges&&Array.isArray(n.badges)&&n.badges.forEach((function(e){return s(t,e)}))},l=function(e){var t=new Set;return e.views.forEach((function(e){return c(t,e)})),t},u=function(e,t){for(var n=new Set,r=0,i=Object.keys(e.states);r<i.length;r++){var a=i[r];t.has(a)||o.includes(a.split(".",1)[0])||n.add(a)}return n},f=function(e,t){var n=l(t);return u(e,n)}},4398:function(e,t,n){"use strict";n.d(t,{i:function(){return i}});var r=n(47181),i=function(e,t){(0,r.B)(e,"show-dialog",{dialogTag:"hui-dialog-select-view",dialogImport:function(){return Promise.all([n.e(5009),n.e(4358),n.e(6755),n.e(6372),n.e(4359),n.e(6436),n.e(4821),n.e(1900),n.e(5024)]).then(n.bind(n,9700))},dialogParams:t})}},28279:function(e,t,n){"use strict";n.r(t),n.d(t,{HuiUnusedEntities:function(){return U}});n(29119);var r=n(15652),i=n(55317),o=n(81471),a=n(58831),s=n(91741),c=n(87744),l=n(54531),u=n(47512),f=n(4398);n(59110),n(52039);function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function h(){var e=w(["\n :host {\n background: var(--lovelace-background);\n overflow: hidden;\n }\n .container {\n display: flex;\n flex-direction: column;\n height: 100%;\n }\n ha-card {\n --ha-card-box-shadow: none;\n --ha-card-border-radius: 0;\n }\n hui-entity-picker-table {\n flex-grow: 1;\n margin-top: -20px;\n }\n .fab {\n position: sticky;\n float: right;\n right: calc(16px + env(safe-area-inset-right));\n bottom: calc(16px + env(safe-area-inset-bottom));\n z-index: 1;\n }\n .fab.rtl {\n right: initial;\n left: 0;\n bottom: 0;\n padding-right: 16px;\n padding-left: calc(16px + env(safe-area-inset-left));\n }\n mwc-fab {\n position: relative;\n bottom: calc(-80px - env(safe-area-inset-bottom));\n transition: bottom 0.3s;\n }\n .fab.selected mwc-fab {\n bottom: 0;\n }\n "]);return h=function(){return e},e}function p(e){return function(e){if(Array.isArray(e))return I(e)}(e)||R(e)||T(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(){var e=w(["\n <br />","\n "]);return v=function(){return e},e}function y(){var e=w(['\n <ha-card\n header="','"\n >\n <div class="card-content">\n ',"\n ","\n </div>\n </ha-card>\n "]);return y=function(){return e},e}function m(){var e=w(['\n <div class="container">\n ',"\n <hui-entity-picker-table\n .hass=","\n .narrow=","\n .entities=","\n @selected-changed=",'\n ></hui-entity-picker-table>\n </div>\n <div\n class="fab ','"\n >\n <mwc-fab\n .label=',"\n @click=",'\n >\n <ha-svg-icon slot="icon" .path=',"></ha-svg-icon>\n </mwc-fab>\n </div>\n "]);return m=function(){return e},e}function b(){var e=w([""]);return b=function(){return e},e}function g(){var e=w([""]);return g=function(){return e},e}function w(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=M(e);if(t){var i=M(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A(this,n)}}function A(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?C(e):t}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S(){S=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(n){t.forEach((function(t){t.kind===n&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var n=e.prototype;["method","field"].forEach((function(r){t.forEach((function(t){var i=t.placement;if(t.kind===r&&("static"===i||"prototype"===i)){var o="static"===i?e:n;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var n=t.descriptor;if("field"===t.kind){var r=t.initializer;n={enumerable:n.enumerable,writable:n.writable,configurable:n.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,n)},decorateClass:function(e,t){var n=[],r=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!j(e))return n.push(e);var t=this.decorateElement(e,i);n.push(t.element),n.push.apply(n,t.extras),r.push.apply(r,t.finishers)}),this),!t)return{elements:n,finishers:r};var o=this.decorateConstructor(n,t);return r.push.apply(r,o.finishers),o.finishers=r,o},addElementPlacement:function(e,t,n){var r=t[e.placement];if(!n&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var n=[],r=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&r.push(c.finisher);var l=c.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);n.push.apply(n,l)}}return{element:e,finishers:r,extras:n}},decorateConstructor:function(e,t){for(var n=[],r=t.length-1;r>=0;r--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[r])(i)||i);if(void 0!==o.finisher&&n.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:n}},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)||R(t)||T(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 n=z(e.key),r=String(e.placement);if("static"!==r&&"prototype"!==r&&"own"!==r)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 "'+r+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:n,placement:r,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:D(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 n=D(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:n}},runClassFinishers:function(e,t){for(var n=0;n<t.length;n++){var r=(0,t[n])(e);if(void 0!==r){if("function"!=typeof r)throw new TypeError("Finishers must return a constructor.");e=r}}return e},disallowProperty:function(e,t,n){if(void 0!==e[t])throw new TypeError(n+" can't have a ."+t+" property.")}};return e}function P(e){var t,n=z(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 r={kind:"field"===e.kind?"field":"method",key:n,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(r.decorators=e.decorators),"field"===e.kind&&(r.initializer=e.value),r}function O(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function j(e){return e.decorators&&e.decorators.length}function x(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function D(e,t){var n=e[t];if(void 0!==n&&"function"!=typeof n)throw new TypeError("Expected '"+t+"' to be a function");return n}function z(e){var t=function(e,t){if("object"!==d(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==d(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===d(t)?t:String(t)}function T(e,t){if(e){if("string"==typeof e)return I(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I(e,t):void 0}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function R(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function F(e,t,n){return(F="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=M(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}function M(e){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var U=function(e,t,n,r){var i=S();if(r)for(var o=0;o<r.length;o++)i=r[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),n),s=i.decorateClass(function(e){for(var t=[],n=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var i,o=e[r];if("method"===o.kind&&(i=t.find(n)))if(x(o.descriptor)||x(i.descriptor)){if(j(o)||j(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(j(o)){if(j(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}O(o,i)}else t.push(o)}return t}(a.d.map(P)),e);return i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,r.Mo)("hui-unused-entities")],(function(e,t){var n=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&E(e,t)}(r,t);var n=_(r);function r(){var t;k(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return t=n.call.apply(n,[this].concat(o)),e(C(t)),t}return r}(t);return{F:n,d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"lovelace",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.Cb)({type:Boolean})],key:"narrow",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_unusedEntities",value:function(){return[]}},{kind:"field",decorators:[(0,r.sz)()],key:"_selectedEntities",value:function(){return[]}},{kind:"get",key:"_config",value:function(){return this.lovelace.config}},{kind:"method",key:"updated",value:function(e){F(M(n.prototype),"updated",this).call(this,e),e.has("lovelace")&&this._getUnusedEntities()}},{kind:"method",key:"render",value:function(){var e=this;return this.hass&&this.lovelace?"storage"===this.lovelace.mode&&!1===this.lovelace.editMode?(0,r.dy)(b()):(0,r.dy)(m(),this.narrow?"":(0,r.dy)(y(),this.hass.localize("ui.panel.lovelace.unused_entities.title"),this.hass.localize("ui.panel.lovelace.unused_entities.available_entities"),"storage"===this.lovelace.mode?(0,r.dy)(v(),this.hass.localize("ui.panel.lovelace.unused_entities.select_to_add")):""),this.hass,this.narrow,this._unusedEntities.map((function(t){var n=e.hass.states[t];return{icon:"",entity_id:t,stateObj:n,name:(0,s.C)(n),domain:(0,a.M)(t),last_changed:n.last_changed}})),this._handleSelectedChanged,(0,o.$)({rtl:(0,c.HE)(this.hass),selected:this._selectedEntities.length}),this.hass.localize("ui.panel.lovelace.editor.edit_card.add"),this._addToLovelaceView,i.qX5):(0,r.dy)(g())}},{kind:"method",key:"_getUnusedEntities",value:function(){if(this.hass&&this.lovelace){this._selectedEntities=[];var e=(0,l.Qc)(this.hass,this._config);this._unusedEntities=p(e).sort()}}},{kind:"method",key:"_handleSelectedChanged",value:function(e){this._selectedEntities=e.detail.selectedEntities}},{kind:"method",key:"_addToLovelaceView",value:function(){var e=this;1!==this.lovelace.config.views.length?(0,f.i)(this,{lovelaceConfig:this.lovelace.config,allowDashboardChange:!1,viewSelectedCallback:function(t,n,r){(0,u.f)(e,{lovelaceConfig:e.lovelace.config,saveConfig:e.lovelace.saveConfig,path:[r],entities:e._selectedEntities})}}):(0,u.f)(this,{lovelaceConfig:this.lovelace.config,saveConfig:this.lovelace.saveConfig,path:[0],entities:this._selectedEntities})}},{kind:"get",static:!0,key:"styles",value:function(){return(0,r.iv)(h())}}]}}),r.oi)}}]);
//# sourceMappingURL=chunk.16611dab2d5d4d01ca4e.js.map