iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 17.9 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[3552],{73589:function(e,t,r){"use strict";r.d(t,{Z:function(){return i}});var n=function(e){var t=parseFloat(e);if(isNaN(t))throw new Error("".concat(e," is not a number"));return t};function i(e){if(!e)return null;try{if(e.endsWith("%"))return{w:100,h:n(e.substr(0,e.length-1))};var t=e.replace(":","x").split("x");return 0===t.length?null:1===t.length?{w:n(t[0]),h:1}:{w:n(t[0]),h:n(t[1])}}catch(r){}return null}},22814:function(e,t,r){"use strict";function n(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(l){return void r(l)}s.done?t(c):Promise.resolve(c).then(n,i)}function i(e){return function(){var t=this,r=arguments;return new Promise((function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,c,"next",e)}function c(e){n(o,i,a,s,c,"throw",e)}s(void 0)}))}}r.d(t,{iI:function(){return a},W2:function(){return o},TZ:function(){return s}});"".concat(location.protocol,"//").concat(location.host);var a=function(e,t){return e.callWS({type:"auth/sign_path",path:t})},o=function(){var e=i(regeneratorRuntime.mark((function e(t,r,n,i){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callWS({type:"config/auth_provider/homeassistant/create",user_id:r,username:n,password:i}));case 1:case"end":return e.stop()}}),e)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),s=function(){var e=i(regeneratorRuntime.mark((function e(t,r,n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.callWS({type:"config/auth_provider/homeassistant/admin_change_password",user_id:r,password:n}));case 1:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}()},97282:function(e,t,r){"use strict";var n=r(15652),i=r(81471),a=r(79865),o=r(49706),s=r(73589),c=(r(67250),r(50538)),l=r(56007);function u(e){return(u="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 d(){var e=g(['\n img {\n display: block;\n height: auto;\n transition: filter 0.2s linear;\n width: 100%;\n }\n\n .ratio {\n position: relative;\n width: 100%;\n height: 0;\n }\n\n .ratio img,\n .ratio div {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n\n #brokenImage {\n background: grey url("/static/images/image-broken.svg") center/36px\n no-repeat;\n }\n ']);return d=function(){return e},e}function f(e,t,r,n,i,a,o){try{var s=e[a](o),c=s.value}catch(l){return void r(l)}s.done?t(c):Promise.resolve(c).then(n,i)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function o(e){f(a,n,i,o,s,"next",e)}function s(e){f(a,n,i,o,s,"throw",e)}o(void 0)}))}}function p(){var e=g(['\n <img\n id="image"\n src=',"\n @error=","\n @load=","\n style=","\n />\n "]);return p=function(){return e},e}function m(){var e=g(["\n <ha-camera-stream\n muted\n .hass=","\n .stateObj=","\n ></ha-camera-stream>\n "]);return m=function(){return e},e}function v(){var e=g(["\n <div\n style=","\n class=","\n >\n ",'\n <div\n id="brokenImage"\n style=',"\n ></div>\n </div>\n "]);return v=function(){return e},e}function y(){var e=g([""]);return y=function(){return e},e}function g(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 b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(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 r,n=A(e);if(t){var i=A(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return E(this,r)}}function E(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?_(e):t}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function I(){I=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(n){t.forEach((function(t){var i=t.placement;if(t.kind===n&&("static"===i||"prototype"===i)){var a="static"===i?e:r;this.defineClassElement(a,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var n=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===n?void 0:n.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],n=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!S(e))return r.push(e);var t=this.decorateElement(e,i);r.push(t.element),r.push.apply(r,t.extras),n.push.apply(n,t.finishers)}),this),!t)return{elements:r,finishers:n};var a=this.decorateConstructor(r,t);return n.push.apply(n,a.finishers),a.finishers=n,a},addElementPlacement:function(e,t,r){var n=t[e.placement];if(!r&&-1!==n.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");n.push(e.key)},decorateElement:function(e,t){for(var r=[],n=[],i=e.decorators,a=i.length-1;a>=0;a--){var o=t[e.placement];o.splice(o.indexOf(e.key),1);var s=this.fromElementDescriptor(e),c=this.toElementFinisherExtras((0,i[a])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var l=c.extras;if(l){for(var u=0;u<l.length;u++)this.addElementPlacement(l[u],t);r.push.apply(r,l)}}return{element:e,finishers:n,extras:r}},decorateConstructor:function(e,t){for(var r=[],n=t.length-1;n>=0;n--){var i=this.fromClassDescriptor(e),a=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==a.finisher&&r.push(a.finisher),void 0!==a.elements){e=a.elements;for(var o=0;o<e.length-1;o++)for(var s=o+1;s<e.length;s++)if(e[o].key===e[s].key&&e[o].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[o].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&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return D(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)?D(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=j(e.key),n=String(e.placement);if("static"!==n&&"prototype"!==n&&"own"!==n)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 "'+n+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var a={kind:t,key:r,placement:n,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"),a.initializer=e.initializer),a},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:O(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=O(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var n=(0,t[r])(e);if(void 0!==n){if("function"!=typeof n)throw new TypeError("Finishers must return a constructor.");e=n}}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 C(e){var t,r=j(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 n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function P(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function S(e){return e.decorators&&e.decorators.length}function x(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function O(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 j(e){var t=function(e,t){if("object"!==u(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===u(t)?t:String(t)}function D(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function R(e,t,r){return(R="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=A(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function A(e){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}!function(e,t,r,n){var i=I();if(n)for(var a=0;a<n.length;a++)i=n[a](i);var o=t((function(e){i.initializeInstanceElements(e,s.elements)}),r),s=i.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===a.key&&e.placement===a.placement},n=0;n<e.length;n++){var i,a=e[n];if("method"===a.kind&&(i=t.find(r)))if(x(a.descriptor)||x(i.descriptor)){if(S(a)||S(i))throw new ReferenceError("Duplicated methods ("+a.key+") can't be decorated.");i.descriptor=a.descriptor}else{if(S(a)){if(S(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+a.key+").");i.decorators=a.decorators}P(a,i)}else t.push(a)}return t}(o.d.map(C)),e);i.initializeClassElements(o.F,s.elements),i.runClassFinishers(o.F,s.finishers)}([(0,n.Mo)("hui-image")],(function(e,t){var r,u,f=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&&b(e,t)}(n,t);var r=w(n);function n(){var t;k(this,n);for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];return t=r.call.apply(r,[this].concat(a)),e(_(t)),t}return n}(t);return{F:f,d:[{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"entity",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"image",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"stateImage",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"cameraImage",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"cameraView",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"aspectRatio",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"filter",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"stateFilter",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"darkModeImage",value:void 0},{kind:"field",decorators:[(0,n.Cb)()],key:"darkModeFilter",value:void 0},{kind:"field",decorators:[(0,n.sz)()],key:"_loadError",value:void 0},{kind:"field",decorators:[(0,n.sz)()],key:"_cameraImageSrc",value:void 0},{kind:"field",decorators:[(0,n.IO)("img")],key:"_image",value:void 0},{kind:"field",key:"_lastImageHeight",value:void 0},{kind:"field",key:"_cameraUpdater",value:void 0},{kind:"method",key:"connectedCallback",value:function(){R(A(f.prototype),"connectedCallback",this).call(this),this.cameraImage&&"live"!==this.cameraView&&this._startUpdateCameraInterval()}},{kind:"method",key:"disconnectedCallback",value:function(){R(A(f.prototype),"disconnectedCallback",this).call(this),this._stopUpdateCameraInterval()}},{kind:"method",key:"render",value:function(){if(!this.hass)return(0,n.dy)(y());var e,t,r=this.aspectRatio?(0,s.Z)(this.aspectRatio):null,c=this.entity?this.hass.states[this.entity]:void 0,u=c?c.state:l.nZ,d=!this.stateImage;if(this.cameraImage)"live"===this.cameraView?t=this.hass.states[this.cameraImage]:e=this._cameraImageSrc;else if(this.stateImage){var f=this.stateImage[u];f?e=f:(e=this.image,d=!0)}else e=this.darkModeImage&&this.hass.themes.darkMode?this.darkModeImage:this.image;e&&(e=this.hass.hassUrl(e));var h=this.filter||"";(this.hass.themes.darkMode&&this.darkModeFilter&&(h+=this.darkModeFilter),this.stateFilter&&this.stateFilter[u]&&(h+=this.stateFilter[u]),!h&&this.entity)&&(h=(!c||o.tj.includes(u))&&d?"grayscale(100%)":"");return(0,n.dy)(v(),(0,a.V)({paddingBottom:r&&r.w>0&&r.h>0?"".concat((100*r.h/r.w).toFixed(2),"%"):""}),(0,i.$)({ratio:Boolean(r&&r.w>0&&r.h>0)}),this.cameraImage&&"live"===this.cameraView?(0,n.dy)(m(),this.hass,t):(0,n.dy)(p(),e,this._onImageError,this._onImageLoad,(0,a.V)({filter:h,display:this._loadError?"none":"block"})),(0,a.V)({height:"".concat(this._lastImageHeight||"100","px"),display:this._loadError?"block":"none"}))}},{kind:"method",key:"updated",value:function(e){if(e.has("hass")){var t=e.get("hass");t&&t.connected===this.hass.connected||(this.hass.connected&&"live"!==this.cameraView?(this._updateCameraImageSrc(),this._startUpdateCameraInterval()):this.hass.connected||(this._stopUpdateCameraInterval(),this._cameraImageSrc=void 0,this._loadError=!0))}else e.has("cameraImage")&&"live"!==this.cameraView&&(this._updateCameraImageSrc(),this._startUpdateCameraInterval())}},{kind:"method",key:"_startUpdateCameraInterval",value:function(){var e=this;this._stopUpdateCameraInterval(),this.cameraImage&&this.isConnected&&(this._cameraUpdater=window.setInterval((function(){return e._updateCameraImageSrc()}),1e4))}},{kind:"method",key:"_stopUpdateCameraInterval",value:function(){this._cameraUpdater&&(clearInterval(this._cameraUpdater),this._cameraUpdater=void 0)}},{kind:"method",key:"_onImageError",value:function(){this._loadError=!0}},{kind:"method",key:"_onImageLoad",value:(u=h(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._loadError=!1,e.next=3,this.updateComplete;case 3:this._lastImageHeight=this._image.offsetHeight;case 4:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{kind:"method",key:"_updateCameraImageSrc",value:(r=h(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.hass&&this.cameraImage){e.next=2;break}return e.abrupt("return");case 2:if(this.hass.states[this.cameraImage]){e.next=6;break}return this._onImageError(),e.abrupt("return");case 6:return e.next=8,(0,c.i4)(this.hass,this.cameraImage);case 8:this._cameraImageSrc=e.sent;case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{kind:"get",static:!0,key:"styles",value:function(){return(0,n.iv)(d())}}]}}),n.oi)}}]);
//# sourceMappingURL=chunk.a005f6bbbeb0f326cd87.js.map