iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 20.7 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[5369],{17324:function(e,t,n){"use strict";n.d(t,{N:function(){return r}});var r=function(e,t,n){return e.subscribeMessage((function(e){return t(e)}),Object.assign({type:"render_template"},n))}},5369:function(e,t,n){"use strict";n.r(t);n(53918);var r=n(15652),i=n(81471),o=n(38346),s=(n(31206),n(53822),n(17324)),a=n(11654),l=n(27322);function c(e,t,n,r,i,o,s){try{var a=e[o](s),l=a.value}catch(c){return void n(c)}a.done?t(l):Promise.resolve(l).then(r,i)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function s(e){c(o,r,i,s,a,"next",e)}function a(e){c(o,r,i,s,a,"throw",e)}s(void 0)}))}}function p(){var e=w(["\n :host {\n -ms-user-select: initial;\n -webkit-user-select: initial;\n -moz-user-select: initial;\n }\n\n .content {\n padding: 16px;\n direction: ltr;\n }\n\n .edit-pane {\n margin-right: 16px;\n }\n\n .edit-pane a {\n color: var(--primary-color);\n }\n\n .horizontal .edit-pane {\n max-width: 50%;\n }\n\n .render-pane {\n position: relative;\n max-width: 50%;\n }\n\n .render-spinner {\n position: absolute;\n top: 8px;\n right: 8px;\n }\n\n .rendered {\n @apply --paper-font-code1;\n clear: both;\n white-space: pre-wrap;\n background-color: var(--secondary-background-color);\n padding: 8px;\n }\n\n .all_listeners {\n color: var(--warning-color);\n }\n\n .rendered.error {\n color: var(--error-color);\n }\n "]);return p=function(){return e},e}function d(){var e=w([""]);return d=function(){return e},e}function f(){var e=w([' <span class="all_listeners">\n ',"\n </span>"]);return f=function(){return e},e}function h(){var e=w(["\n <li>\n <b\n >","</b\n >: ","\n </li>\n "]);return h=function(){return e},e}function m(){var e=w(["\n <li>\n <b\n >","</b\n >: ","\n </li>\n "]);return m=function(){return e},e}function v(){var e=w(["\n <p>\n ","\n </p>\n <ul>\n ","\n ","\n </ul>\n "]);return v=function(){return e},e}function y(){var e=w(['\n <p class="all_listeners">\n ',"\n </p>\n "]);return y=function(){return e},e}function b(){var e=w(["\n <p>\n ","\n </p>\n "]);return b=function(){return e},e}function _(){var e=w(["",":\n ",""]);return _=function(){return e},e}function k(){var e=w(['<ha-circular-progress\n class="render-spinner"\n active\n size="small"\n ></ha-circular-progress>']);return k=function(){return e},e}function g(){var e=w(['\n <div\n class="content ','"\n >\n <div class="edit-pane">\n <p>\n ','\n </p>\n <ul>\n <li>\n <a\n href="http://jinja.pocoo.org/docs/dev/templates/"\n target="_blank"\n rel="noreferrer"\n >','\n </a>\n </li>\n <li>\n <a\n href="','"\n target="_blank"\n rel="noreferrer"\n >\n ',"</a\n >\n </li>\n </ul>\n <p>\n ",'\n </p>\n <ha-code-editor\n mode="jinja2"\n .value=',"\n .error=","\n autofocus\n @value-changed=","\n ></ha-code-editor>\n <mwc-button @click=",">\n ",'\n </mwc-button>\n </div>\n\n <div class="render-pane">\n ',"\n ",'\n \x3c!-- prettier-ignore --\x3e\n <pre\n class="rendered ','"\n >',"","</pre>\n ","\n ","\n </div>\n </div>\n "]);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 E(e){return(E="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 R(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function T(e,t){return(T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function x(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=N(e);if(t){var i=N(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return z(this,n)}}function z(e,t){return!t||"object"!==E(t)&&"function"!=typeof t?j(e):t}function j(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function P(){P=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(!C(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 s=t[e.placement];s.splice(s.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,i[o])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&r.push(l.finisher);var c=l.extras;if(c){for(var u=0;u<c.length;u++)this.addElementPlacement(c[u],t);n.push.apply(n,c)}}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 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: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)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(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}}(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=F(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:A(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=A(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 O(e){var t,n=F(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 S(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function C(e){return e.decorators&&e.decorators.length}function D(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function A(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 F(e){var t=function(e,t){if("object"!==E(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==E(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===E(t)?t:String(t)}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 M(e,t,n){return(M="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=N(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 N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var U='{## Imitate available variables: ##}\n{% set my_test_json = {\n "temperature": 25,\n "unit": "°C"\n} %}\n\nThe temperature is {{ my_test_json.temperature }} {{ my_test_json.unit }}.\n\n{% if is_state("sun.sun", "above_horizon") -%}\n The sun rose {{ relative_time(states.sun.sun.last_changed) }} ago.\n{%- else -%}\n The sun will rise at {{ as_timestamp(strptime(state_attr("sun.sun", "next_rising"), "")) | timestamp_local }}.\n{%- endif %}\n\nFor loop example getting entity values in the weather domain:\n\n{% for state in states.weather -%}\n {%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%}\n {{ state.name | lower }} is {{state.state_with_unit}}\n{%- endfor %}.';!function(e,t,n,r){var i=P();if(r)for(var o=0;o<r.length;o++)i=r[o](i);var s=t((function(e){i.initializeInstanceElements(e,a.elements)}),n),a=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(D(o.descriptor)||D(i.descriptor)){if(C(o)||C(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(C(o)){if(C(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}S(o,i)}else t.push(o)}return t}(s.d.map(O)),e);i.initializeClassElements(s.F,a.elements),i.runClassFinishers(s.F,a.finishers)}([(0,r.Mo)("developer-tools-template")],(function(e,t){var n,c,w=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&&T(e,t)}(r,t);var n=x(r);function r(){var t;R(this,r);for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];return t=n.call.apply(n,[this].concat(o)),e(j(t)),t}return r}(t);return{F:w,d:[{kind:"field",decorators:[(0,r.Cb)()],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"narrow",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_error",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_rendering",value:function(){return!1}},{kind:"field",decorators:[(0,r.sz)()],key:"_templateResult",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_unsubRenderTemplate",value:void 0},{kind:"field",key:"_template",value:function(){return""}},{kind:"field",key:"_inited",value:function(){return!1}},{kind:"method",key:"connectedCallback",value:function(){M(N(w.prototype),"connectedCallback",this).call(this),this._template&&!this._unsubRenderTemplate&&this._subscribeTemplate()}},{kind:"method",key:"disconnectedCallback",value:function(){this._unsubscribeTemplate()}},{kind:"method",key:"firstUpdated",value:function(){localStorage&&localStorage["panel-dev-template-template"]?this._template=localStorage["panel-dev-template-template"]:this._template=U,this._subscribeTemplate(),this._inited=!0}},{kind:"method",key:"render",value:function(){var e,t,n,o,s,a,c,u,p,w=this,R=E(null===(e=this._templateResult)||void 0===e?void 0:e.result),T="object"===R?Array.isArray(null===(t=this._templateResult)||void 0===t?void 0:t.result)?"list":"dict":R;return(0,r.dy)(g(),(0,i.$)({layout:!this.narrow,horizontal:!this.narrow}),this.hass.localize("ui.panel.developer-tools.tabs.templates.description"),this.hass.localize("ui.panel.developer-tools.tabs.templates.jinja_documentation"),(0,l.R)(this.hass,"/docs/configuration/templating/"),this.hass.localize("ui.panel.developer-tools.tabs.templates.template_extensions"),this.hass.localize("ui.panel.developer-tools.tabs.templates.editor"),this._template,this._error,this._templateChanged,this._restoreDemo,this.hass.localize("ui.panel.developer-tools.tabs.templates.reset"),this._rendering?(0,r.dy)(k()):"",this._templateResult?(0,r.dy)(_(),this.hass.localize("ui.panel.developer-tools.tabs.templates.result_type"),T):"",(0,i.$)((c={error:Boolean(this._error)},p=T,(u=T)in c?Object.defineProperty(c,u,{value:p,enumerable:!0,configurable:!0,writable:!0}):c[u]=p,c)),this._error,"object"===R?JSON.stringify(this._templateResult.result,null,2):null===(n=this._templateResult)||void 0===n?void 0:n.result,(null===(o=this._templateResult)||void 0===o?void 0:o.listeners.time)?(0,r.dy)(b(),this.hass.localize("ui.panel.developer-tools.tabs.templates.time")):"",(null===(s=this._templateResult)||void 0===s?void 0:s.listeners)?this._templateResult.listeners.all?(0,r.dy)(y(),this.hass.localize("ui.panel.developer-tools.tabs.templates.all_listeners")):this._templateResult.listeners.domains.length||this._templateResult.listeners.entities.length?(0,r.dy)(v(),this.hass.localize("ui.panel.developer-tools.tabs.templates.listeners"),this._templateResult.listeners.domains.sort().map((function(e){return(0,r.dy)(m(),w.hass.localize("ui.panel.developer-tools.tabs.templates.domain"),e)})),this._templateResult.listeners.entities.sort().map((function(e){return(0,r.dy)(h(),w.hass.localize("ui.panel.developer-tools.tabs.templates.entity"),e)}))):(null===(a=this._templateResult)||void 0===a?void 0:a.listeners.time)?(0,r.dy)(d()):(0,r.dy)(f(),this.hass.localize("ui.panel.developer-tools.tabs.templates.no_listeners")):"")}},{kind:"get",static:!0,key:"styles",value:function(){return[a.Qx,(0,r.iv)(p())]}},{kind:"field",key:"_debounceRender",value:function(){var e=this;return(0,o.D)((function(){e._subscribeTemplate(),e._storeTemplate()}),500,!1)}},{kind:"method",key:"_templateChanged",value:function(e){this._template=e.detail.value,this._error&&(this._error=void 0),this._debounceRender()}},{kind:"method",key:"_subscribeTemplate",value:(c=u(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._rendering=!0,e.next=3,this._unsubscribeTemplate();case 3:return e.prev=3,this._unsubRenderTemplate=(0,s.N)(this.hass.connection,(function(e){t._templateResult=e,t._error=void 0}),{template:this._template,timeout:3}),e.next=7,this._unsubRenderTemplate;case 7:e.next=14;break;case 9:e.prev=9,e.t0=e.catch(3),this._error="Unknown error",e.t0.message&&(this._error=e.t0.message,this._templateResult=void 0),this._unsubRenderTemplate=void 0;case 14:return e.prev=14,this._rendering=!1,e.finish(14);case 17:case"end":return e.stop()}}),e,this,[[3,9,14,17]])}))),function(){return c.apply(this,arguments)})},{kind:"method",key:"_unsubscribeTemplate",value:(n=u(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._unsubRenderTemplate){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this._unsubRenderTemplate;case 5:(0,e.sent)(),this._unsubRenderTemplate=void 0,e.next=16;break;case 10:if(e.prev=10,e.t0=e.catch(2),"not_found"!==e.t0.code){e.next=15;break}e.next=16;break;case 15:throw e.t0;case 16:case"end":return e.stop()}}),e,this,[[2,10]])}))),function(){return n.apply(this,arguments)})},{kind:"method",key:"_storeTemplate",value:function(){this._inited&&(localStorage["panel-dev-template-template"]=this._template)}},{kind:"method",key:"_restoreDemo",value:function(){this._template=U,this._subscribeTemplate(),delete localStorage["panel-dev-template-template"]}}]}}),r.oi)},27322:function(e,t,n){"use strict";n.d(t,{R:function(){return r}});var r=function(e,t){return"https://www.iobroker.net/#".concat(e.language&&e.language.split("-")[0]||"en","/adapters/adapterref/iobroker.lovelace/README.md")}}}]);
//# sourceMappingURL=chunk.dbcaa444313d3a7880c6.js.map