UNPKG

iobroker.lovelace

Version:

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

124 lines (112 loc) 19.3 kB
/*! For license information please see chunk.67d7b6a907fe1e9b4ba1.js.LICENSE.txt */ (self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[4403],{51644:(e,t,i)=>{"use strict";i.d(t,{$:()=>o,P:()=>a});i(65233),i(26110);var n=i(8621),r=i(87156);const o={properties:{pressed:{type:Boolean,readOnly:!0,value:!1,reflectToAttribute:!0,observer:"_pressedChanged"},toggles:{type:Boolean,value:!1,reflectToAttribute:!0},active:{type:Boolean,value:!1,notify:!0,reflectToAttribute:!0},pointerDown:{type:Boolean,readOnly:!0,value:!1},receivedFocusFromKeyboard:{type:Boolean,readOnly:!0},ariaActiveAttribute:{type:String,value:"aria-pressed",observer:"_ariaActiveAttributeChanged"}},listeners:{down:"_downHandler",up:"_upHandler",tap:"_tapHandler"},observers:["_focusChanged(focused)","_activeChanged(active, ariaActiveAttribute)"],keyBindings:{"enter:keydown":"_asyncClick","space:keydown":"_spaceKeyDownHandler","space:keyup":"_spaceKeyUpHandler"},_mouseEventRe:/^mouse/,_tapHandler:function(){this.toggles?this._userActivate(!this.active):this.active=!1},_focusChanged:function(e){this._detectKeyboardFocus(e),e||this._setPressed(!1)},_detectKeyboardFocus:function(e){this._setReceivedFocusFromKeyboard(!this.pointerDown&&e)},_userActivate:function(e){this.active!==e&&(this.active=e,this.fire("change"))},_downHandler:function(e){this._setPointerDown(!0),this._setPressed(!0),this._setReceivedFocusFromKeyboard(!1)},_upHandler:function(){this._setPointerDown(!1),this._setPressed(!1)},_spaceKeyDownHandler:function(e){var t=e.detail.keyboardEvent,i=(0,r.vz)(t).localTarget;this.isLightDescendant(i)||(t.preventDefault(),t.stopImmediatePropagation(),this._setPressed(!0))},_spaceKeyUpHandler:function(e){var t=e.detail.keyboardEvent,i=(0,r.vz)(t).localTarget;this.isLightDescendant(i)||(this.pressed&&this._asyncClick(),this._setPressed(!1))},_asyncClick:function(){this.async((function(){this.click()}),1)},_pressedChanged:function(e){this._changedButtonState()},_ariaActiveAttributeChanged:function(e,t){t&&t!=e&&this.hasAttribute(t)&&this.removeAttribute(t)},_activeChanged:function(e,t){this.toggles?this.setAttribute(this.ariaActiveAttribute,e?"true":"false"):this.removeAttribute(this.ariaActiveAttribute),this._changedButtonState()},_controlStateChanged:function(){this.disabled?this._setPressed(!1):this._changedButtonState()},_changedButtonState:function(){this._buttonStateChanged&&this._buttonStateChanged()}},a=[n.G,o]},52003:(e,t,i)=>{"use strict";i.d(t,{F:()=>n,C:()=>r});const n=async(e,t,n=!1)=>{if(!e.parentNode)throw new Error("Cannot setup Leaflet map on disconnected element");const r=(await i.e(6085).then(i.t.bind(i,70208,23))).default;r.Icon.Default.imagePath="/static/images/leaflet/images/",n&&await i.e(7716).then(i.t.bind(i,27716,23));const a=r.map(e),s=document.createElement("link");s.setAttribute("href","/static/images/leaflet/leaflet.css"),s.setAttribute("rel","stylesheet"),e.parentNode.appendChild(s),a.setView([52.3731339,4.8903147],13);return[a,r,o(r,Boolean(t)).addTo(a)]},r=(e,t,i,n)=>(t.removeLayer(i),(i=o(e,n)).addTo(t),i),o=(e,t)=>e.tileLayer(`https://{s}.basemaps.cartocdn.com/${t?"dark_all":"light_all"}/{z}/{x}/{y}${e.Browser.retina?"@2x.png":".png"}`,{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, &copy; <a href="https://carto.com/attributions">CARTO</a>',subdomains:"abcd",minZoom:0,maxZoom:20})},83849:(e,t,i)=>{"use strict";i.d(t,{c:()=>o});var n=i(47181),r=i(72055);const o=(e,t)=>{const i=(null==t?void 0:t.replace)||!1;var o;i?r.E.history.replaceState(null!==(o=r.E.history.state)&&void 0!==o&&o.root?{root:!0}:null,"",e):r.E.history.pushState(null,"",e),(0,n.B)(r.E,"location-changed",{replace:i})}},45841:(e,t,i)=>{"use strict";i.d(t,{V3:()=>r,fT:()=>a});var n=i(83849);const r=i(38353).u;let o;const a=e=>{o=e,(0,n.c)("/config/zone/new")}},58404:(e,t,i)=>{"use strict";i.r(t);i(53918),i(30879),i(27662),i(84281);var n=i(50424),r=i(55358),o=i(47181),a=(i(51482),i(20122));var s=i(76307);function c(){c=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(n){t.forEach((function(t){var r=t.placement;if(t.kind===n&&("static"===r||"prototype"===r)){var o="static"===r?e:i;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var i=t.descriptor;if("field"===t.kind){var n=t.initializer;i={enumerable:i.enumerable,writable:i.writable,configurable:i.configurable,value:void 0===n?void 0:n.call(e)}}Object.defineProperty(e,t.key,i)},decorateClass:function(e,t){var i=[],n=[],r={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,r)}),this),e.forEach((function(e){if(!u(e))return i.push(e);var t=this.decorateElement(e,r);i.push(t.element),i.push.apply(i,t.extras),n.push.apply(n,t.finishers)}),this),!t)return{elements:i,finishers:n};var o=this.decorateConstructor(i,t);return n.push.apply(n,o.finishers),o.finishers=n,o},addElementPlacement:function(e,t,i){var n=t[e.placement];if(!i&&-1!==n.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");n.push(e.key)},decorateElement:function(e,t){for(var i=[],n=[],r=e.decorators,o=r.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,r[o])(s)||s);e=c.element,this.addElementPlacement(e,t),c.finisher&&n.push(c.finisher);var l=c.extras;if(l){for(var d=0;d<l.length;d++)this.addElementPlacement(l[d],t);i.push.apply(i,l)}}return{element:e,finishers:n,extras:i}},decorateConstructor:function(e,t){for(var i=[],n=t.length-1;n>=0;n--){var r=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(r)||r);if(void 0!==o.finisher&&i.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: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&&null!=e[Symbol.iterator]||null!=e["@@iterator"])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=f(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 r=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:i,placement:n,descriptor:Object.assign({},r)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(r,"get","The property descriptor of a field descriptor"),this.disallowProperty(r,"set","The property descriptor of a field descriptor"),this.disallowProperty(r,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:h(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=h(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:i}},runClassFinishers:function(e,t){for(var i=0;i<t.length;i++){var n=(0,t[i])(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,i){if(void 0!==e[t])throw new TypeError(i+" can't have a ."+t+" property.")}};return e}function l(e){var t,i=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 n={kind:"field"===e.kind?"field":"method",key:i,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 d(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function u(e){return e.decorators&&e.decorators.length}function p(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function h(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 f(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;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,n=new Array(t);i<t;i++)n[i]=e[i];return n}function v(e,t,i){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=y(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(i):r.value}})(e,t,i||e)}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const g=[52.3731339,4.8903147],_=matchMedia("(prefers-color-scheme: dark)");!function(e,t,i,n){var r=c();if(n)for(var o=0;o<n.length;o++)r=n[o](r);var a=t((function(e){r.initializeInstanceElements(e,s.elements)}),i),s=r.decorateClass(function(e){for(var t=[],i=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},n=0;n<e.length;n++){var r,o=e[n];if("method"===o.kind&&(r=t.find(i)))if(p(o.descriptor)||p(r.descriptor)){if(u(o)||u(r))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");r.descriptor=o.descriptor}else{if(u(o)){if(u(r))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");r.decorators=o.decorators}d(o,r)}else t.push(o)}return t}(a.d.map(l)),e);r.initializeClassElements(a.F,s.elements),r.runClassFinishers(a.F,s.finishers)}([(0,r.Mo)("onboarding-core-config")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.Cb)()],key:"onboardingLocalize",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_working",value:()=>!1},{kind:"field",decorators:[(0,r.SB)()],key:"_name",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_location",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_elevation",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_unitSystem",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_timeZone",value:void 0},{kind:"method",key:"render",value:function(){return n.dy` <p> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.intro","name",this.hass.user.name)} </p> <paper-input .label=${this.onboardingLocalize("ui.panel.page-onboarding.core-config.location_name")} name="name" .disabled=${this._working} .value=${this._nameValue} @value-changed=${this._handleChange} ></paper-input> <div class="middle-text"> <p> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.intro_location")} </p> <div class="row"> <div> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.intro_location_detect")} </div> <mwc-button @click=${this._detect}> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.button_detect")} </mwc-button> </div> </div> <div class="row"> <ha-location-editor class="flex" .hass=${this.hass} .location=${this._locationValue} .fitZoom=${14} .darkMode=${_.matches} @change=${this._locationChanged} ></ha-location-editor> </div> <div class="row"> <paper-input class="flex" .label=${this.hass.localize("ui.panel.config.core.section.core.core_config.time_zone")} name="timeZone" list="timezones" .disabled=${this._working} .value=${this._timeZoneValue} @value-changed=${this._handleChange} ></paper-input> <paper-input class="flex" .label=${this.hass.localize("ui.panel.config.core.section.core.core_config.elevation")} name="elevation" type="number" .disabled=${this._working} .value=${this._elevationValue} @value-changed=${this._handleChange} > <span slot="suffix"> ${this.hass.localize("ui.panel.config.core.section.core.core_config.elevation_meters")} </span> </paper-input> </div> <div class="row"> <div class="flex"> ${this.hass.localize("ui.panel.config.core.section.core.core_config.unit_system")} </div> <paper-radio-group class="flex" .selected=${this._unitSystemValue} @selected-changed=${this._unitSystemChanged} > <paper-radio-button name="metric" .disabled=${this._working}> ${this.hass.localize("ui.panel.config.core.section.core.core_config.unit_system_metric")} <div class="secondary"> ${this.hass.localize("ui.panel.config.core.section.core.core_config.metric_example")} </div> </paper-radio-button> <paper-radio-button name="imperial" .disabled=${this._working}> ${this.hass.localize("ui.panel.config.core.section.core.core_config.unit_system_imperial")} <div class="secondary"> ${this.hass.localize("ui.panel.config.core.section.core.core_config.imperial_example")} </div> </paper-radio-button> </paper-radio-group> </div> <div class="footer"> <mwc-button @click=${this._save} .disabled=${this._working}> ${this.onboardingLocalize("ui.panel.page-onboarding.core-config.finish")} </mwc-button> </div> `}},{kind:"method",key:"firstUpdated",value:function(e){v(y(i.prototype),"firstUpdated",this).call(this,e),setTimeout((()=>this.shadowRoot.querySelector("paper-input").focus()),100),this.addEventListener("keypress",(e=>{13===e.keyCode&&this._save(e)}));this.shadowRoot.querySelector("[name=timeZone]").inputElement.appendChild((()=>{const e=document.createElement("datalist");return e.id="timezones",Object.keys(a).forEach((t=>{const i=document.createElement("option");i.value=t,i.innerHTML=a[t],e.appendChild(i)})),e})())}},{kind:"get",key:"_nameValue",value:function(){return void 0!==this._name?this._name:this.onboardingLocalize("ui.panel.page-onboarding.core-config.location_name_default")}},{kind:"get",key:"_locationValue",value:function(){return this._location||g}},{kind:"get",key:"_elevationValue",value:function(){return void 0!==this._elevation?this._elevation:0}},{kind:"get",key:"_timeZoneValue",value:function(){return this._timeZone}},{kind:"get",key:"_unitSystemValue",value:function(){return void 0!==this._unitSystem?this._unitSystem:"metric"}},{kind:"method",key:"_handleChange",value:function(e){const t=e.currentTarget;this[`_${t.name}`]=t.value}},{kind:"method",key:"_locationChanged",value:function(e){this._location=e.currentTarget.location}},{kind:"method",key:"_unitSystemChanged",value:function(e){this._unitSystem=e.detail.value}},{kind:"method",key:"_detect",value:async function(){this._working=!0;try{const t=await(e=this.hass,e.callWS({type:"config/core/detect"}));t.latitude&&t.longitude&&(this._location=[Number(t.latitude),Number(t.longitude)]),t.elevation&&(this._elevation=String(t.elevation)),t.unit_system&&(this._unitSystem=t.unit_system),t.time_zone&&(this._timeZone=t.time_zone)}catch(e){alert(`Failed to detect location information: ${e.message}`)}finally{this._working=!1}var e}},{kind:"method",key:"_save",value:async function(e){e.preventDefault(),this._working=!0;try{const e=this._locationValue;await(t=this.hass,i={location_name:this._nameValue,latitude:e[0],longitude:e[1],elevation:Number(this._elevationValue),unit_system:this._unitSystemValue,time_zone:this._timeZoneValue||"UTC"},t.callWS({type:"config/core/update",...i}));const n=await(0,s.Rj)(this.hass);(0,o.B)(this,"onboarding-step",{type:"core_config",result:n})}catch(e){this._working=!1,alert(`Failed to save: ${e.message}`)}var t,i}},{kind:"get",static:!0,key:"styles",value:function(){return n.iv` .row { display: flex; flex-direction: row; margin: 0 -8px; align-items: center; } .secondary { color: var(--secondary-text-color); } .flex { flex: 1; } .middle-text { margin: 24px 0; } .row > * { margin: 0 8px; } .footer { margin-top: 16px; text-align: right; } `}}]}}),n.oi)}}]); //# sourceMappingURL=chunk.67d7b6a907fe1e9b4ba1.js.map