iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
123 lines (111 loc) • 17 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[7393],{52003:(e,t,i)=>{"use strict";i.d(t,{F:()=>r,C:()=>n});const r=async(e,t,r=!1)=>{if(!e.parentNode)throw new Error("Cannot setup Leaflet map on disconnected element");const n=(await i.e(6567).then(i.t.bind(i,70208,7))).default;n.Icon.Default.imagePath="/static/images/leaflet/images/",r&&await i.e(1294).then(i.t.bind(i,27716,7));const a=n.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,n,o(n,Boolean(t)).addTo(a)]},n=(e,t,i,r)=>(t.removeLayer(i),(i=o(e,r)).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:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>, © <a href="https://carto.com/attributions">CARTO</a>',subdomains:"abcd",minZoom:0,maxZoom:20})},83849:(e,t,i)=>{"use strict";i.d(t,{c:()=>n});var r=i(47181);const n=(e,t,i=!1)=>{i?history.replaceState(null,"",t):history.pushState(null,"",t),(0,r.B)(window,"location-changed",{replace:i})}},96151:(e,t,i)=>{"use strict";i.d(t,{y:()=>r});const r=()=>new Promise((e=>{var t;t=e,requestAnimationFrame((()=>setTimeout(t,0)))}))},45841:(e,t,i)=>{"use strict";i.d(t,{V3:()=>n,fT:()=>a});var r=i(83849);const n="#FF9800";let o;const a=(e,t)=>{o=t,(0,r.c)(e,"/config/zone/new")}},58404:(e,t,i)=>{"use strict";i.r(t);i(53918),i(30879),i(27662),i(84281);var r=i(15652),n=i(47181),o=(i(51482),i(20122));var a=i(76307);function s(){s=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 o="static"===n?e:i;this.defineClassElement(o,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(!d(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 o=this.decorateConstructor(i,t);return r.push.apply(r,o.finishers),o.finishers=r,o},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,o=n.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,n[o])(s)||s);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),o=this.toClassDescriptor((0,t[r])(n)||n);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&&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=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 n=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={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"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:p(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=p(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 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 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 d(e){return e.decorators&&e.decorators.length}function u(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function p(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 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}function m(e,t,i){return(m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,i){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=v(e)););return e}(e,t);if(r){var n=Object.getOwnPropertyDescriptor(r,t);return n.get?n.get.call(i):n.value}})(e,t,i||e)}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}const y=[52.3731339,4.8903147],g=matchMedia("(prefers-color-scheme: dark)");!function(e,t,i,r){var n=s();if(r)for(var o=0;o<r.length;o++)n=r[o](n);var a=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===o.key&&e.placement===o.placement},r=0;r<e.length;r++){var n,o=e[r];if("method"===o.kind&&(n=t.find(i)))if(u(o.descriptor)||u(n.descriptor)){if(d(o)||d(n))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");n.descriptor=o.descriptor}else{if(d(o)){if(d(n))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");n.decorators=o.decorators}c(o,n)}else t.push(o)}return t}(a.d.map(l)),e);n.initializeClassElements(a.F,p.elements),n.runClassFinishers(a.F,p.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.sz)()],key:"_working",value:()=>!1},{kind:"field",decorators:[(0,r.sz)()],key:"_name",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_location",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_elevation",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_unitSystem",value:void 0},{kind:"field",decorators:[(0,r.sz)()],key:"_timeZone",value:void 0},{kind:"method",key:"render",value:function(){return r.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=${g.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){m(v(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(o).forEach((t=>{const i=document.createElement("option");i.value=t,i.innerHTML=o[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||y}},{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(t){alert("Failed to detect location information: "+t.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 r=await(0,a.Rj)(this.hass);(0,n.B)(this,"onboarding-step",{type:"core_config",result:r})}catch(r){this._working=!1,alert("Failed to save: "+r.message)}var t,i}},{kind:"get",static:!0,key:"styles",value:function(){return r.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;
}
`}}]}}),r.oi)}}]);
//# sourceMappingURL=chunk.d6093f0f36e886383088.js.map