UNPKG

iobroker.lovelace

Version:

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

122 lines (115 loc) 16.4 kB
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[9626],{24381:(e,t,i)=>{"use strict";i.d(t,{Q:()=>r});const r=(e,t)=>e?t.map((t=>t in e.attributes?"has-"+t:"")).filter((e=>""!==e)).join(" "):""},31811:(e,t,i)=>{"use strict";var r=i(15652),n=i(41181),s=i(29821);function o(){o=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(!c(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 a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,n[s])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&r.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],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 a=o+1;a<e.length;a++)if(e[o].key===e[a].key&&e[o].placement===e[a].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 h(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)?h(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=p(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=p(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 l(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 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 p(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 h(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}let f;!function(e,t,i,r){var n=o();if(r)for(var s=0;s<r.length;s++)n=r[s](n);var u=t((function(e){n.initializeInstanceElements(e,p.elements)}),i),p=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(d(s.descriptor)||d(n.descriptor)){if(c(s)||c(n))throw new ReferenceError("Duplicated methods ("+s.key+") can't be decorated.");n.descriptor=s.descriptor}else{if(c(s)){if(c(n))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+s.key+").");n.decorators=s.decorators}l(s,n)}else t.push(s)}return t}(u.d.map(a)),e);n.initializeClassElements(u.F,p.elements),n.runClassFinishers(u.F,p.finishers)}([(0,r.Mo)("ha-attributes")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)()],key:"stateObj",value:void 0},{kind:"field",decorators:[(0,r.Cb)({attribute:"extra-filters"})],key:"extraFilters",value:void 0},{kind:"method",key:"render",value:function(){return this.stateObj?r.dy` <div> ${this.computeDisplayAttributes(Object.keys(s.Z.LOGIC_STATE_ATTRIBUTES).concat(this.extraFilters?this.extraFilters.split(","):[])).map((e=>r.dy` <div class="data-entry"> <div class="key"> ${e.replace(/_/g," ").replace(/\bid\b/g,"ID")} </div> <div class="value"> ${this.formatAttribute(e)} </div> </div> `))} ${this.stateObj.attributes.attribution?r.dy` <div class="attribution"> ${this.stateObj.attributes.attribution} </div> `:""} </div> `:r.dy``}},{kind:"get",static:!0,key:"styles",value:function(){return r.iv` .data-entry { display: flex; flex-direction: row; justify-content: space-between; } .data-entry .value { max-width: 200px; overflow-wrap: break-word; } .key:first-letter { text-transform: capitalize; } .attribution { color: var(--secondary-text-color); text-align: right; } pre { font-family: inherit; font-size: inherit; } `}},{kind:"method",key:"computeDisplayAttributes",value:function(e){return this.stateObj?Object.keys(this.stateObj.attributes).filter((t=>-1===e.indexOf(t))):[]}},{kind:"method",key:"formatAttribute",value:function(e){if(!this.stateObj)return"-";const t=this.stateObj.attributes[e];return this.formatAttributeValue(t)}},{kind:"method",key:"formatAttributeValue",value:function(e){if(null===e)return"-";if(Array.isArray(e)&&e.some((e=>e instanceof Object))||!Array.isArray(e)&&e instanceof Object){f||(f=Promise.all([i.e(9033),i.e(1572)]).then(i.t.bind(i,50947,7)));const t=f.then((t=>t.safeDump(e)));return r.dy` <pre>${(0,n.C)(t,"")}</pre> `}return Array.isArray(e)?e.join(", "):e}}]}}),r.oi)},81303:(e,t,i)=>{"use strict";i(8878);const r=customElements.get("paper-dropdown-menu");customElements.define("ha-paper-dropdown-menu",class extends r{ready(){super.ready(),setTimeout((()=>{"rtl"===window.getComputedStyle(this).direction&&(this.style.textAlign="right")}),100)}})},69626:(e,t,i)=>{"use strict";i.r(t);i(21157),i(10983),i(53973),i(51095);var r=i(50856),n=i(28426),s=i(24381),o=(i(31811),i(81303),i(43709),i(11052)),a=i(1265);class l extends((0,a.Z)((0,o.I)(n.H3))){static get template(){return r.d` <style include="iron-flex"></style> <style> .container-speed_list, .container-direction, .container-oscillating { display: none; } .has-speed_list .container-speed_list, .has-direction .container-direction, .has-oscillating .container-oscillating { display: block; } ha-paper-dropdown-menu { width: 100%; } paper-item { cursor: pointer; } </style> <div class$="[[computeClassNames(stateObj)]]"> <div class="container-speed_list"> <ha-paper-dropdown-menu label-float="" dynamic-align="" label="[[localize('ui.card.fan.speed')]]" > <paper-listbox slot="dropdown-content" selected="[[stateObj.attributes.speed]]" on-selected-changed="speedChanged" attr-for-selected="item-name" > <template is="dom-repeat" items="[[stateObj.attributes.speed_list]]" > <paper-item item-name$="[[item]]">[[item]]</paper-item> </template> </paper-listbox> </ha-paper-dropdown-menu> </div> <div class="container-oscillating"> <div class="center horizontal layout single-row"> <div class="flex">[[localize('ui.card.fan.oscillate')]]</div> <ha-switch checked="[[oscillationToggleChecked]]" on-change="oscillationToggleChanged" > </ha-switch> </div> </div> <div class="container-direction"> <div class="direction"> <div>[[localize('ui.card.fan.direction')]]</div> <ha-icon-button icon="hass:rotate-left" on-click="onDirectionReverse" title="[[localize('ui.card.fan.reverse')]]" disabled="[[computeIsRotatingReverse(stateObj)]]" ></ha-icon-button> <ha-icon-button icon="hass:rotate-right" on-click="onDirectionForward" title="[[localize('ui.card.fan.forward')]]" disabled="[[computeIsRotatingForward(stateObj)]]" ></ha-icon-button> </div> </div> </div> <ha-attributes state-obj="[[stateObj]]" extra-filters="speed,speed_list,oscillating,direction" ></ha-attributes> `}static get properties(){return{hass:{type:Object},stateObj:{type:Object,observer:"stateObjChanged"},oscillationToggleChecked:{type:Boolean}}}stateObjChanged(e,t){e&&this.setProperties({oscillationToggleChecked:e.attributes.oscillating}),t&&setTimeout((()=>{this.fire("iron-resize")}),500)}computeClassNames(e){return"more-info-fan "+(0,s.Q)(e,["oscillating","speed_list","direction"])}speedChanged(e){const t=this.stateObj.attributes.speed,i=e.detail.value;i&&t!==i&&this.hass.callService("fan","turn_on",{entity_id:this.stateObj.entity_id,speed:i})}oscillationToggleChanged(e){const t=this.stateObj.attributes.oscillating,i=e.target.checked;t!==i&&this.hass.callService("fan","oscillate",{entity_id:this.stateObj.entity_id,oscillating:i})}onDirectionReverse(){this.hass.callService("fan","set_direction",{entity_id:this.stateObj.entity_id,direction:"reverse"})}onDirectionForward(){this.hass.callService("fan","set_direction",{entity_id:this.stateObj.entity_id,direction:"forward"})}computeIsRotatingReverse(e){return"reverse"===e.attributes.direction}computeIsRotatingForward(e){return"forward"===e.attributes.direction}}customElements.define("more-info-fan",l)},11052:(e,t,i)=>{"use strict";i.d(t,{I:()=>s});var r=i(76389),n=i(47181);const s=(0,r.o)((e=>class extends e{fire(e,t,i){return i=i||{},(0,n.B)(i.node||this,e,t,i)}}))},29821:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const r={DOMAIN_DEVICE_CLASS:{binary_sensor:["battery","cold","connectivity","door","garage_door","gas","heat","light","lock","moisture","motion","moving","occupancy","opening","plug","power","presence","problem","safety","smoke","sound","vibration","window"],cover:["awning","blind","curtain","damper","door","garage","shade","shutter","window"],humidifier:["dehumidifier","humidifier"],sensor:["battery","humidity","illuminance","temperature","pressure","power","signal_strength","timestamp"],switch:["switch","outlet"]},UNKNOWN_TYPE:"json",ADD_TYPE:"key-value",TYPE_TO_TAG:{string:"ha-customize-string",json:"ha-customize-string",icon:"ha-customize-icon",boolean:"ha-customize-boolean",array:"ha-customize-array","key-value":"ha-customize-key-value"}};r.LOGIC_STATE_ATTRIBUTES=r.LOGIC_STATE_ATTRIBUTES||{entity_picture:void 0,friendly_name:{type:"string",description:"Name"},icon:{type:"icon"},emulated_hue:{type:"boolean",domains:["emulated_hue"]},emulated_hue_name:{type:"string",domains:["emulated_hue"]},haaska_hidden:void 0,haaska_name:void 0,supported_features:void 0,attribution:void 0,restored:void 0,custom_ui_more_info:{type:"string"},custom_ui_state_card:{type:"string"},device_class:{type:"array",options:r.DOMAIN_DEVICE_CLASS,description:"Device class",domains:["binary_sensor","cover","humidifier","sensor","switch"]},assumed_state:{type:"boolean",domains:["switch","light","cover","climate","fan","humidifier","group","water_heater"]},initial_state:{type:"string",domains:["automation"]},unit_of_measurement:{type:"string"}};const n=r}}]); //# sourceMappingURL=chunk.7aef465b312de5a1acd9.js.map