UNPKG

iobroker.lovelace

Version:

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

493 lines (439 loc) 24.4 kB
/*! For license information please see chunk.363a0938f1d21cdb7219.js.LICENSE.txt */ (self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[6755],{21157:(e,t,i)=>{"use strict";i(43437);const r=i(50856).d` /* Most common used flex styles*/ <dom-module id="iron-flex"> <template> <style> .layout.horizontal, .layout.vertical { display: -ms-flexbox; display: -webkit-flex; display: flex; } .layout.inline { display: -ms-inline-flexbox; display: -webkit-inline-flex; display: inline-flex; } .layout.horizontal { -ms-flex-direction: row; -webkit-flex-direction: row; flex-direction: row; } .layout.vertical { -ms-flex-direction: column; -webkit-flex-direction: column; flex-direction: column; } .layout.wrap { -ms-flex-wrap: wrap; -webkit-flex-wrap: wrap; flex-wrap: wrap; } .layout.no-wrap { -ms-flex-wrap: nowrap; -webkit-flex-wrap: nowrap; flex-wrap: nowrap; } .layout.center, .layout.center-center { -ms-flex-align: center; -webkit-align-items: center; align-items: center; } .layout.center-justified, .layout.center-center { -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; } .flex { -ms-flex: 1 1 0.000000001px; -webkit-flex: 1; flex: 1; -webkit-flex-basis: 0.000000001px; flex-basis: 0.000000001px; } .flex-auto { -ms-flex: 1 1 auto; -webkit-flex: 1 1 auto; flex: 1 1 auto; } .flex-none { -ms-flex: none; -webkit-flex: none; flex: none; } </style> </template> </dom-module> /* Basic flexbox reverse styles */ <dom-module id="iron-flex-reverse"> <template> <style> .layout.horizontal-reverse, .layout.vertical-reverse { display: -ms-flexbox; display: -webkit-flex; display: flex; } .layout.horizontal-reverse { -ms-flex-direction: row-reverse; -webkit-flex-direction: row-reverse; flex-direction: row-reverse; } .layout.vertical-reverse { -ms-flex-direction: column-reverse; -webkit-flex-direction: column-reverse; flex-direction: column-reverse; } .layout.wrap-reverse { -ms-flex-wrap: wrap-reverse; -webkit-flex-wrap: wrap-reverse; flex-wrap: wrap-reverse; } </style> </template> </dom-module> /* Flexbox alignment */ <dom-module id="iron-flex-alignment"> <template> <style> /** * Alignment in cross axis. */ .layout.start { -ms-flex-align: start; -webkit-align-items: flex-start; align-items: flex-start; } .layout.center, .layout.center-center { -ms-flex-align: center; -webkit-align-items: center; align-items: center; } .layout.end { -ms-flex-align: end; -webkit-align-items: flex-end; align-items: flex-end; } .layout.baseline { -ms-flex-align: baseline; -webkit-align-items: baseline; align-items: baseline; } /** * Alignment in main axis. */ .layout.start-justified { -ms-flex-pack: start; -webkit-justify-content: flex-start; justify-content: flex-start; } .layout.center-justified, .layout.center-center { -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; } .layout.end-justified { -ms-flex-pack: end; -webkit-justify-content: flex-end; justify-content: flex-end; } .layout.around-justified { -ms-flex-pack: distribute; -webkit-justify-content: space-around; justify-content: space-around; } .layout.justified { -ms-flex-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; } /** * Self alignment. */ .self-start { -ms-align-self: flex-start; -webkit-align-self: flex-start; align-self: flex-start; } .self-center { -ms-align-self: center; -webkit-align-self: center; align-self: center; } .self-end { -ms-align-self: flex-end; -webkit-align-self: flex-end; align-self: flex-end; } .self-stretch { -ms-align-self: stretch; -webkit-align-self: stretch; align-self: stretch; } .self-baseline { -ms-align-self: baseline; -webkit-align-self: baseline; align-self: baseline; } /** * multi-line alignment in main axis. */ .layout.start-aligned { -ms-flex-line-pack: start; /* IE10 */ -ms-align-content: flex-start; -webkit-align-content: flex-start; align-content: flex-start; } .layout.end-aligned { -ms-flex-line-pack: end; /* IE10 */ -ms-align-content: flex-end; -webkit-align-content: flex-end; align-content: flex-end; } .layout.center-aligned { -ms-flex-line-pack: center; /* IE10 */ -ms-align-content: center; -webkit-align-content: center; align-content: center; } .layout.between-aligned { -ms-flex-line-pack: justify; /* IE10 */ -ms-align-content: space-between; -webkit-align-content: space-between; align-content: space-between; } .layout.around-aligned { -ms-flex-line-pack: distribute; /* IE10 */ -ms-align-content: space-around; -webkit-align-content: space-around; align-content: space-around; } </style> </template> </dom-module> /* Non-flexbox positioning helper styles */ <dom-module id="iron-flex-factors"> <template> <style> .flex, .flex-1 { -ms-flex: 1 1 0.000000001px; -webkit-flex: 1; flex: 1; -webkit-flex-basis: 0.000000001px; flex-basis: 0.000000001px; } .flex-2 { -ms-flex: 2; -webkit-flex: 2; flex: 2; } .flex-3 { -ms-flex: 3; -webkit-flex: 3; flex: 3; } .flex-4 { -ms-flex: 4; -webkit-flex: 4; flex: 4; } .flex-5 { -ms-flex: 5; -webkit-flex: 5; flex: 5; } .flex-6 { -ms-flex: 6; -webkit-flex: 6; flex: 6; } .flex-7 { -ms-flex: 7; -webkit-flex: 7; flex: 7; } .flex-8 { -ms-flex: 8; -webkit-flex: 8; flex: 8; } .flex-9 { -ms-flex: 9; -webkit-flex: 9; flex: 9; } .flex-10 { -ms-flex: 10; -webkit-flex: 10; flex: 10; } .flex-11 { -ms-flex: 11; -webkit-flex: 11; flex: 11; } .flex-12 { -ms-flex: 12; -webkit-flex: 12; flex: 12; } </style> </template> </dom-module> <dom-module id="iron-positioning"> <template> <style> .block { display: block; } [hidden] { display: none !important; } .invisible { visibility: hidden !important; } .relative { position: relative; } .fit { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } body.fullbleed { margin: 0; height: 100vh; } .scroll { -webkit-overflow-scrolling: touch; overflow: auto; } /* fixed position */ .fixed-bottom, .fixed-left, .fixed-right, .fixed-top { position: fixed; } .fixed-top { top: 0; left: 0; right: 0; } .fixed-right { top: 0; right: 0; bottom: 0; } .fixed-bottom { right: 0; bottom: 0; left: 0; } .fixed-left { top: 0; bottom: 0; left: 0; } </style> </template> </dom-module> `;r.setAttribute("style","display: none;"),document.head.appendChild(r.content)},8544:(e,t,i)=>{"use strict";i(10983);var r=i(50856),n=i(28426),s=i(56007),o=i(44817);class l extends n.H3{static get template(){return r.d` <style> .state { white-space: nowrap; } [invisible] { visibility: hidden !important; } </style> <div class="state"> <ha-icon-button aria-label="Open cover" icon="[[computeOpenIcon(stateObj)]]" on-click="onOpenTap" invisible$="[[!entityObj.supportsOpen]]" disabled="[[computeOpenDisabled(stateObj, entityObj)]]" ></ha-icon-button> <ha-icon-button aria-label="Stop the cover from moving" icon="hass:stop" on-click="onStopTap" invisible$="[[!entityObj.supportsStop]]" disabled="[[computeStopDisabled(stateObj)]]" ></ha-icon-button> <ha-icon-button aria-label="Close cover" icon="[[computeCloseIcon(stateObj)]]" on-click="onCloseTap" invisible$="[[!entityObj.supportsClose]]" disabled="[[computeClosedDisabled(stateObj, entityObj)]]" ></ha-icon-button> </div> `}static get properties(){return{hass:{type:Object},stateObj:{type:Object},entityObj:{type:Object,computed:"computeEntityObj(hass, stateObj)"}}}computeEntityObj(e,t){return new o.ZP(e,t)}computeOpenIcon(e){switch(e.attributes.device_class){case"awning":case"door":case"gate":return"hass:arrow-expand-horizontal";default:return"hass:arrow-up"}}computeCloseIcon(e){switch(e.attributes.device_class){case"awning":case"door":case"gate":return"hass:arrow-collapse-horizontal";default:return"hass:arrow-down"}}computeStopDisabled(e){return e.state===s.nZ}computeOpenDisabled(e,t){if(e.state===s.nZ)return!0;const i=!0===e.attributes.assumed_state;return(t.isFullyOpen||t.isOpening)&&!i}computeClosedDisabled(e,t){if(e.state===s.nZ)return!0;const i=!0===e.attributes.assumed_state;return(t.isFullyClosed||t.isClosing)&&!i}onOpenTap(e){e.stopPropagation(),this.entityObj.openCover()}onCloseTap(e){e.stopPropagation(),this.entityObj.closeCover()}onStopTap(e){e.stopPropagation(),this.entityObj.stopCover()}}customElements.define("ha-cover-controls",l)},37466:(e,t,i)=>{"use strict";i(21157),i(10983);var r=i(50856),n=i(28426),s=i(56007),o=i(44817);class l extends n.H3{static get template(){return r.d` <style include="iron-flex"></style> <style> :host { white-space: nowrap; } [invisible] { visibility: hidden !important; } </style> <ha-icon-button aria-label="Open cover tilt" icon="hass:arrow-top-right" on-click="onOpenTiltTap" title="Open tilt" invisible$="[[!entityObj.supportsOpenTilt]]" disabled="[[computeOpenDisabled(stateObj, entityObj)]]" ></ha-icon-button> <ha-icon-button aria-label="Stop cover from moving" icon="hass:stop" on-click="onStopTiltTap" invisible$="[[!entityObj.supportsStopTilt]]" disabled="[[computeStopDisabled(stateObj)]]" title="Stop tilt" ></ha-icon-button> <ha-icon-button aria-label="Close cover tilt" icon="hass:arrow-bottom-left" on-click="onCloseTiltTap" title="Close tilt" invisible$="[[!entityObj.supportsCloseTilt]]" disabled="[[computeClosedDisabled(stateObj, entityObj)]]" ></ha-icon-button> `}static get properties(){return{hass:{type:Object},stateObj:{type:Object},entityObj:{type:Object,computed:"computeEntityObj(hass, stateObj)"}}}computeEntityObj(e,t){return new o.ZP(e,t)}computeStopDisabled(e){return e.state===s.nZ}computeOpenDisabled(e,t){if(e.state===s.nZ)return!0;const i=!0===e.attributes.assumed_state;return t.isFullyOpenTilt&&!i}computeClosedDisabled(e,t){if(e.state===s.nZ)return!0;const i=!0===e.attributes.assumed_state;return t.isFullyClosedTilt&&!i}onOpenTiltTap(e){e.stopPropagation(),this.entityObj.openCoverTilt()}onCloseTiltTap(e){e.stopPropagation(),this.entityObj.closeCoverTilt()}onStopTiltTap(e){e.stopPropagation(),this.entityObj.stopCoverTilt()}}customElements.define("ha-cover-tilt-controls",l)},16755:(e,t,i)=>{"use strict";i.r(t);var r=i(15652),n=(i(8544),i(37466),i(44817)),s=i(53658),o=(i(91476),i(75502));function l(){l=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(i){t.forEach((function(t){t.kind===i&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var i=e.prototype;["method","field"].forEach((function(r){t.forEach((function(t){var n=t.placement;if(t.kind===r&&("static"===n||"prototype"===n)){var s="static"===n?e:i;this.defineClassElement(s,t)}}),this)}),this)},defineClassElement:function(e,t){var i=t.descriptor;if("field"===t.kind){var r=t.initializer;i={enumerable:i.enumerable,writable:i.writable,configurable:i.configurable,value:void 0===r?void 0:r.call(e)}}Object.defineProperty(e,t.key,i)},decorateClass:function(e,t){var i=[],r=[],n={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,n)}),this),e.forEach((function(e){if(!p(e))return i.push(e);var t=this.decorateElement(e,n);i.push(t.element),i.push.apply(i,t.extras),r.push.apply(r,t.finishers)}),this),!t)return{elements:i,finishers:r};var s=this.decorateConstructor(i,t);return r.push.apply(r,s.finishers),s.finishers=r,s},addElementPlacement:function(e,t,i){var r=t[e.placement];if(!i&&-1!==r.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");r.push(e.key)},decorateElement:function(e,t){for(var i=[],r=[],n=e.decorators,s=n.length-1;s>=0;s--){var o=t[e.placement];o.splice(o.indexOf(e.key),1);var l=this.fromElementDescriptor(e),a=this.toElementFinisherExtras((0,n[s])(l)||l);e=a.element,this.addElementPlacement(e,t),a.finisher&&r.push(a.finisher);var c=a.extras;if(c){for(var p=0;p<c.length;p++)this.addElementPlacement(c[p],t);i.push.apply(i,c)}}return{element:e,finishers:r,extras:i}},decorateConstructor:function(e,t){for(var i=[],r=t.length-1;r>=0;r--){var n=this.fromClassDescriptor(e),s=this.toClassDescriptor((0,t[r])(n)||n);if(void 0!==s.finisher&&i.push(s.finisher),void 0!==s.elements){e=s.elements;for(var o=0;o<e.length-1;o++)for(var l=o+1;l<e.length;l++)if(e[o].key===e[l].key&&e[o].placement===e[l].placement)throw new TypeError("Duplicated element ("+e[o].key+")")}}return{elements:e,finishers:i}},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 i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?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 i=d(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 n=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var s={kind:t,key:i,placement:r,descriptor:Object.assign({},n)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(n,"get","The property descriptor of a field descriptor"),this.disallowProperty(n,"set","The property descriptor of a field descriptor"),this.disallowProperty(n,"value","The property descriptor of a field descriptor"),s.initializer=e.initializer),s},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:u(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 i=u(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:i}},runClassFinishers:function(e,t){for(var i=0;i<t.length;i++){var r=(0,t[i])(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,i){if(void 0!==e[t])throw new TypeError(i+" can't have a ."+t+" property.")}};return e}function a(e){var t,i=d(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:i,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 c(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function p(e){return e.decorators&&e.decorators.length}function f(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function u(e,t){var i=e[t];if(void 0!==i&&"function"!=typeof i)throw new TypeError("Expected '"+t+"' to be a function");return i}function d(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=typeof r)return r;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 m(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}!function(e,t,i,r){var n=l();if(r)for(var s=0;s<r.length;s++)n=r[s](n);var o=t((function(e){n.initializeInstanceElements(e,u.elements)}),i),u=n.decorateClass(function(e){for(var t=[],i=function(e){return"method"===e.kind&&e.key===s.key&&e.placement===s.placement},r=0;r<e.length;r++){var n,s=e[r];if("method"===s.kind&&(n=t.find(i)))if(f(s.descriptor)||f(n.descriptor)){if(p(s)||p(n))throw new ReferenceError("Duplicated methods ("+s.key+") can't be decorated.");n.descriptor=s.descriptor}else{if(p(s)){if(p(n))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+s.key+").");n.decorators=s.decorators}c(s,n)}else t.push(s)}return t}(o.d.map(a)),e);n.initializeClassElements(o.F,u.elements),n.runClassFinishers(o.F,u.finishers)}([(0,r.Mo)("hui-cover-entity-row")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{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:"method",key:"setConfig",value:function(e){if(!e)throw new Error("Configuration error");this._config=e}},{kind:"method",key:"shouldUpdate",value:function(e){return(0,s.G)(this,e)}},{kind:"method",key:"render",value:function(){if(!this._config||!this.hass)return r.dy``;const e=this.hass.states[this._config.entity];return e?r.dy` <hui-generic-entity-row .hass=${this.hass} .config=${this._config}> ${(0,n.pu)(e)?r.dy` <ha-cover-tilt-controls .hass=${this.hass} .stateObj=${e} ></ha-cover-tilt-controls> `:r.dy` <ha-cover-controls .hass=${this.hass} .stateObj=${e} ></ha-cover-controls> `} </hui-generic-entity-row> `:r.dy` <hui-warning> ${(0,o.i)(this.hass,this._config.entity)} </hui-warning> `}},{kind:"get",static:!0,key:"styles",value:function(){return r.iv` ha-cover-controls, ha-cover-tilt-controls { margin-right: -0.57em; } `}}]}}),r.oi)},44817:(e,t,i)=>{"use strict";i.d(t,{ZP:()=>n,pu:()=>s});var r=i(40095);class n{constructor(e,t){this.hass=e,this.stateObj=t,this._attr=t.attributes,this._feat=this._attr.supported_features}get isFullyOpen(){return void 0!==this._attr.current_position?100===this._attr.current_position:"open"===this.stateObj.state}get isFullyClosed(){return void 0!==this._attr.current_position?0===this._attr.current_position:"closed"===this.stateObj.state}get isFullyOpenTilt(){return 100===this._attr.current_tilt_position}get isFullyClosedTilt(){return 0===this._attr.current_tilt_position}get isOpening(){return"opening"===this.stateObj.state}get isClosing(){return"closing"===this.stateObj.state}get supportsOpen(){return(0,r.e)(this.stateObj,1)}get supportsClose(){return(0,r.e)(this.stateObj,2)}get supportsSetPosition(){return(0,r.e)(this.stateObj,4)}get supportsStop(){return(0,r.e)(this.stateObj,8)}get supportsOpenTilt(){return(0,r.e)(this.stateObj,16)}get supportsCloseTilt(){return(0,r.e)(this.stateObj,32)}get supportsStopTilt(){return(0,r.e)(this.stateObj,64)}get supportsSetTiltPosition(){return(0,r.e)(this.stateObj,128)}get isTiltOnly(){const e=this.supportsOpen||this.supportsClose||this.supportsStop;return(this.supportsOpenTilt||this.supportsCloseTilt||this.supportsStopTilt)&&!e}openCover(){this.callService("open_cover")}closeCover(){this.callService("close_cover")}stopCover(){this.callService("stop_cover")}openCoverTilt(){this.callService("open_cover_tilt")}closeCoverTilt(){this.callService("close_cover_tilt")}stopCoverTilt(){this.callService("stop_cover_tilt")}setCoverPosition(e){this.callService("set_cover_position",{position:e})}setCoverTiltPosition(e){this.callService("set_cover_tilt_position",{tilt_position:e})}callService(e,t={}){t.entity_id=this.stateObj.entity_id,this.hass.callService("cover",e,t)}}function s(e){const t=(e=>(0,r.e)(e,1))(e)||(e=>(0,r.e)(e,2))(e)||(e=>(0,r.e)(e,8))(e);return((e=>(0,r.e)(e,16))(e)||(e=>(0,r.e)(e,32))(e)||(e=>(0,r.e)(e,64))(e))&&!t}}}]); //# sourceMappingURL=chunk.363a0938f1d21cdb7219.js.map