UNPKG

iobroker.lovelace

Version:

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

2 lines 18.9 kB
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[1878],{81878:function(e,t,n){"use strict";n.r(t);n(30879);var r=n(15652),i=n(81471),o=n(62877),a=n(47181),s=(n(22098),n(91937),"number"),c=n(64588),l=n(75502);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=_(["\n ha-card {\n padding-bottom: 16px;\n position: relative;\n height: 100%;\n box-sizing: border-box;\n --alarm-color-disarmed: var(--label-badge-green);\n --alarm-color-pending: var(--label-badge-yellow);\n --alarm-color-triggered: var(--label-badge-red);\n --alarm-color-armed: var(--label-badge-red);\n --alarm-color-autoarm: rgba(0, 153, 255, 0.1);\n --alarm-state-color: var(--alarm-color-armed);\n }\n\n ha-label-badge {\n --ha-label-badge-color: var(--alarm-state-color);\n --label-badge-text-color: var(--alarm-state-color);\n --label-badge-background-color: var(--card-background-color);\n color: var(--alarm-state-color);\n position: absolute;\n right: 12px;\n top: 12px;\n cursor: pointer;\n }\n\n .disarmed {\n --alarm-state-color: var(--alarm-color-disarmed);\n }\n\n .triggered {\n --alarm-state-color: var(--alarm-color-triggered);\n animation: pulse 1s infinite;\n }\n\n .arming {\n --alarm-state-color: var(--alarm-color-pending);\n animation: pulse 1s infinite;\n }\n\n .pending {\n --alarm-state-color: var(--alarm-color-pending);\n animation: pulse 1s infinite;\n }\n\n @keyframes pulse {\n 0% {\n opacity: 1;\n }\n 50% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n paper-input {\n margin: 0 auto 8px;\n max-width: 150px;\n text-align: center;\n }\n\n .state {\n margin-left: 16px;\n position: relative;\n bottom: 16px;\n color: var(--alarm-state-color);\n animation: none;\n }\n\n #keypad {\n display: flex;\n justify-content: center;\n flex-wrap: wrap;\n margin: auto;\n width: 100%;\n max-width: 300px;\n }\n\n #keypad mwc-button {\n text-size: 20px;\n padding: 8px;\n width: 30%;\n box-sizing: border-box;\n }\n\n .actions {\n margin: 0 8px;\n padding-top: 20px;\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n }\n\n .actions mwc-button {\n margin: 0 4px 4px;\n }\n\n mwc-button#disarm {\n color: var(--error-color);\n }\n "]);return d=function(){return e},e}function f(){var e=_(['\n <mwc-button\n .value="','"\n @click="','"\n outlined\n >\n ',"\n </mwc-button>\n "]);return f=function(){return e},e}function p(){var e=_([" <mwc-button disabled></mwc-button> "]);return p=function(){return e},e}function h(){var e=_(['\n <div id="keypad">\n ',"\n </div>\n "]);return h=function(){return e},e}function m(){var e=_([""]);return m=function(){return e},e}function y(){var e=_(['\n <paper-input\n id="alarmCode"\n .label=','\n type="password"\n ></paper-input>\n ']);return y=function(){return e},e}function v(){var e=_([""]);return v=function(){return e},e}function b(){var e=_(['\n <mwc-button\n .action="','"\n @click="','"\n outlined\n >\n ',"\n </mwc-button>\n "]);return b=function(){return e},e}function g(){var e=_(['\n <ha-card\n .header="','"\n >\n <ha-label-badge\n class="','"\n .icon="','"\n .label="','"\n @click=','\n ></ha-label-badge>\n <div id="armActions" class="actions">\n ',"\n </div>\n ","\n ","\n </ha-card>\n "]);return g=function(){return e},e}function k(){var e=_(["\n <hui-warning>\n ","\n </hui-warning>\n "]);return k=function(){return e},e}function w(){var e=_([""]);return w=function(){return e},e}function _(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function E(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(l){return void n(l)}s.done?t(c):Promise.resolve(c).then(r,i)}function x(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function a(e){E(o,r,i,a,s,"next",e)}function s(e){E(o,r,i,a,s,"throw",e)}a(void 0)}))}}function P(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C(e,t){return(C=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(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=U(e);if(t){var i=U(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return D(this,n)}}function D(e,t){return!t||"object"!==u(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 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(!T(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)||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 M(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)?M(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:I(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=I(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 z(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 A(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function T(e){return e.decorators&&e.decorators.length}function R(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function I(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"!==u(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!==u(r))return r;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 M(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 L(e,t,n){return(L="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=U(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 U(e){return(U=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var $={armed_away:"hass:shield-lock",armed_custom_bypass:"hass:security",armed_home:"hass:shield-home",armed_night:"hass:shield-home",disarmed:"hass:shield-check",pending:"hass:shield-outline",triggered:"hass:bell-ring"},B=["1","2","3","4","5","6","7","8","9","","0","clear"];!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(R(o.descriptor)||R(i.descriptor)){if(T(o)||T(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(T(o)){if(T(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}A(o,i)}else t.push(o)}return t}(a.d.map(z)),e);i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,r.Mo)("hui-alarm-panel-card")],(function(e,t){var u,_,E=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&&C(e,t)}(r,t);var n=O(r);function r(){var t;P(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(j(t)),t}return r}(t);return{F:E,d:[{kind:"method",static:!0,key:"getConfigElement",value:(_=x(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all([n.e(5009),n.e(4358),n.e(6755),n.e(1041),n.e(8374),n.e(4268),n.e(8946),n.e(4333),n.e(4535),n.e(1803)]).then(n.bind(n,89021));case 2:return e.abrupt("return",document.createElement("hui-alarm-panel-card-editor"));case 3:case"end":return e.stop()}}),e)}))),function(){return _.apply(this,arguments)})},{kind:"method",static:!0,key:"getStubConfig",value:function(e,t,n){return{type:"alarm-panel",states:["arm_home","arm_away"],entity:(0,c.j)(e,1,t,n,["alarm_control_panel"])[0]||""}}},{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_config",value:void 0},{kind:"field",decorators:[(0,r.IO)("#alarmCode")],key:"_input",value:void 0},{kind:"method",key:"getCardSize",value:(u=x(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._config&&this.hass){e.next=2;break}return e.abrupt("return",9);case 2:return t=this.hass.states[this._config.entity],e.abrupt("return",t&&t.attributes.code_format===s?9:4);case 4:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{kind:"method",key:"setConfig",value:function(e){if(!e||!e.entity||"alarm_control_panel"!==e.entity.split(".")[0])throw new Error("Invalid card configuration");this._config=Object.assign({},{states:["arm_away","arm_home"]},e)}},{kind:"method",key:"updated",value:function(e){if(L(U(E.prototype),"updated",this).call(this,e),this._config&&this.hass){var t=e.get("hass"),n=e.get("_config");t&&n&&t.themes===this.hass.themes&&n.theme===this._config.theme||(0,o.R)(this,this.hass.themes,this._config.theme)}}},{kind:"method",key:"shouldUpdate",value:function(e){if(e.has("_config"))return!0;var t=e.get("hass");return!t||t.themes!==this.hass.themes||t.language!==this.hass.language||t.states[this._config.entity]!==this.hass.states[this._config.entity]}},{kind:"method",key:"render",value:function(){var e=this;if(!this._config||!this.hass)return(0,r.dy)(w());var t,n,o,a=this.hass.states[this._config.entity];return a?(0,r.dy)(g(),this._config.name||a.attributes.friendly_name||this._stateDisplay(a.state),(0,i.$)((t={},n=a.state,o=!0,n in t?Object.defineProperty(t,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[n]=o,t)),$[a.state]||"hass:shield-outline",this._stateIconLabel(a.state),this._handleMoreInfo,("disarmed"===a.state?this._config.states:["disarm"]).map((function(t){return(0,r.dy)(b(),t,e._handleActionClick,e._actionDisplay(t))})),a.attributes.code_format?(0,r.dy)(y(),this.hass.localize("ui.card.alarm_control_panel.code")):(0,r.dy)(v()),a.attributes.code_format!==s?(0,r.dy)(m()):(0,r.dy)(h(),B.map((function(t){return""===t?(0,r.dy)(p()):(0,r.dy)(f(),t,e._handlePadClick,"clear"===t?e.hass.localize("ui.card.alarm_control_panel.clear_code"):t)})))):(0,r.dy)(k(),(0,l.i)(this.hass,this._config.entity))}},{kind:"method",key:"_stateIconLabel",value:function(e){var t=e.split("_").pop();return"disarmed"!==t&&"triggered"!==t&&t?this._stateDisplay(e):""}},{kind:"method",key:"_actionDisplay",value:function(e){return this.hass.localize("ui.card.alarm_control_panel.".concat(e))}},{kind:"method",key:"_stateDisplay",value:function(e){return this.hass.localize("component.alarm_control_panel.state._.".concat(e))}},{kind:"method",key:"_handlePadClick",value:function(e){var t=e.currentTarget.value;this._input.value="clear"===t?"":this._input.value+t}},{kind:"method",key:"_handleActionClick",value:function(e){var t,n,r,i,o=this._input;t=this.hass,n=this._config.entity,r=e.currentTarget.action,i=(null==o?void 0:o.value)||void 0,t.callService("alarm_control_panel","alarm_".concat(r),{entity_id:n,code:i}),o&&(o.value="")}},{kind:"method",key:"_handleMoreInfo",value:function(){(0,a.B)(this,"hass-more-info",{entityId:this._config.entity})}},{kind:"get",static:!0,key:"styles",value:function(){return(0,r.iv)(d())}}]}}),r.oi)}}]); //# sourceMappingURL=chunk.74072bc0ee24e12346e8.js.map