iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 10.6 kB
JavaScript
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["94377"],{29073:function(e,t,a){a.d(t,{u:()=>x});var o=a(61701),n=a(72621),i=(a(71695),a(9359),a(31526),a(70104),a(19423),a(40251),a(47021),a(57243)),l=a(50778),r=a(29567),s=a(36522);a(99426),a(66671);let d,c,u,m,h,p,b,v,y,k=e=>e;const f={boolean:()=>Promise.all([a.e("29570"),a.e("79350")]).then(a.bind(a,8353)),constant:()=>a.e("69654").then(a.bind(a,5606)),float:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("62022")]).then(a.bind(a,53203)),grid:()=>a.e("45036").then(a.bind(a,20018)),expandable:()=>a.e("42653").then(a.bind(a,91624)),integer:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("42950"),a.e("29570"),a.e("65505"),a.e("92139"),a.e("17375"),a.e("42849")]).then(a.bind(a,96116)),multi_select:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("91552"),a.e("78456"),a.e("56898"),a.e("42950"),a.e("29570"),a.e("65505"),a.e("5080"),a.e("50408"),a.e("13204"),a.e("99562")]).then(a.bind(a,84545)),positive_time_period_dict:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("91552"),a.e("78456"),a.e("41258"),a.e("56898"),a.e("35671"),a.e("3688"),a.e("38336"),a.e("63016")]).then(a.bind(a,15063)),select:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("91552"),a.e("78456"),a.e("24199"),a.e("41258"),a.e("56898"),a.e("78943"),a.e("35671"),a.e("42950"),a.e("29570"),a.e("65505"),a.e("7010"),a.e("62524"),a.e("34561"),a.e("47818"),a.e("22542")]).then(a.bind(a,62706)),string:()=>Promise.all([a.e("46379"),a.e("66031"),a.e("36620")]).then(a.bind(a,8327)),optional_actions:()=>a.e("85230").then(a.bind(a,26709))},g=(e,t)=>e?!t.name||t.flatten?e:e[t.name]:null;let x=(0,o.Z)([(0,l.Mo)("ha-form")],(function(e,t){class a extends t{constructor(...t){super(...t),e(this)}}return{F:a,d:[{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"data",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"schema",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"error",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"warning",value:void 0},{kind:"field",decorators:[(0,l.Cb)({type:Boolean})],key:"disabled",value(){return!1}},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"computeError",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"computeWarning",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"computeLabel",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"computeHelper",value:void 0},{kind:"field",decorators:[(0,l.Cb)({attribute:!1})],key:"localizeValue",value:void 0},{kind:"method",key:"getFormProperties",value:function(){return{}}},{kind:"method",key:"focus",value:async function(){await this.updateComplete;const e=this.renderRoot.querySelector(".root");if(e)for(const t of e.children)if("HA-ALERT"!==t.tagName){t instanceof i.fl&&await t.updateComplete,t.focus();break}}},{kind:"method",key:"willUpdate",value:function(e){e.has("schema")&&this.schema&&this.schema.forEach((e=>{var t;"selector"in e||null===(t=f[e.type])||void 0===t||t.call(f)}))}},{kind:"method",key:"render",value:function(){return(0,i.dy)(d||(d=k` <div class="root" part="root"> ${0} ${0} </div> `),this.error&&this.error.base?(0,i.dy)(c||(c=k` <ha-alert alert-type="error"> ${0} </ha-alert> `),this._computeError(this.error.base,this.schema)):"",this.schema.map((e=>{var t;const a=((e,t)=>e&&t.name?e[t.name]:null)(this.error,e),o=((e,t)=>e&&t.name?e[t.name]:null)(this.warning,e);return(0,i.dy)(u||(u=k` ${0} ${0} `),a?(0,i.dy)(m||(m=k` <ha-alert own-margin alert-type="error"> ${0} </ha-alert> `),this._computeError(a,e)):o?(0,i.dy)(h||(h=k` <ha-alert own-margin alert-type="warning"> ${0} </ha-alert> `),this._computeWarning(o,e)):"","selector"in e?(0,i.dy)(p||(p=k`<ha-selector .schema="${0}" .hass="${0}" .name="${0}" .selector="${0}" .value="${0}" .label="${0}" .disabled="${0}" .placeholder="${0}" .helper="${0}" .localizeValue="${0}" .required="${0}" .context="${0}"></ha-selector>`),e,this.hass,e.name,e.selector,g(this.data,e),this._computeLabel(e,this.data),e.disabled||this.disabled||!1,e.required?"":e.default,this._computeHelper(e),this.localizeValue,e.required||!1,this._generateContext(e)):(0,r.h)(this.fieldElementName(e.type),Object.assign({schema:e,data:g(this.data,e),label:this._computeLabel(e,this.data),helper:this._computeHelper(e),disabled:this.disabled||e.disabled||!1,hass:this.hass,localize:null===(t=this.hass)||void 0===t?void 0:t.localize,computeLabel:this.computeLabel,computeHelper:this.computeHelper,localizeValue:this.localizeValue,context:this._generateContext(e)},this.getFormProperties())))})))}},{kind:"method",key:"fieldElementName",value:function(e){return`ha-form-${e}`}},{kind:"method",key:"_generateContext",value:function(e){if(!e.context)return;const t={};for(const[a,o]of Object.entries(e.context))t[a]=this.data[o];return t}},{kind:"method",key:"createRenderRoot",value:function(){const e=(0,n.Z)(a,"createRenderRoot",this,3)([]);return this.addValueChangedListener(e),e}},{kind:"method",key:"addValueChangedListener",value:function(e){e.addEventListener("value-changed",(e=>{e.stopPropagation();const t=e.target.schema;if(e.target===this)return;const a=!t.name||"flatten"in t&&t.flatten?e.detail.value:{[t.name]:e.detail.value};this.data=Object.assign(Object.assign({},this.data),a),(0,s.B)(this,"value-changed",{value:this.data})}))}},{kind:"method",key:"_computeLabel",value:function(e,t){return this.computeLabel?this.computeLabel(e,t):e?e.name:""}},{kind:"method",key:"_computeHelper",value:function(e){return this.computeHelper?this.computeHelper(e):""}},{kind:"method",key:"_computeError",value:function(e,t){return Array.isArray(e)?(0,i.dy)(b||(b=k`<ul> ${0} </ul>`),e.map((e=>(0,i.dy)(v||(v=k`<li> ${0} </li>`),this.computeError?this.computeError(e,t):e)))):this.computeError?this.computeError(e,t):e}},{kind:"method",key:"_computeWarning",value:function(e,t){return this.computeWarning?this.computeWarning(e,t):e}},{kind:"field",static:!0,key:"styles",value(){return(0,i.iv)(y||(y=k`.root>*{display:block}.root>:not([own-margin]):not(:last-child){margin-bottom:24px}ha-alert[own-margin]{margin-bottom:4px}`))}}]}}),i.oi)},61320:function(e,t,a){a.r(t),a.d(t,{HaSelectorSelector:()=>h});var o=a(61701),n=(a(71695),a(9359),a(70104),a(19423),a(47021),a(57243)),i=a(50778),l=a(27486),r=a(36522);a(99426),a(29073);let s,d,c=e=>e;const u={number:{min:1,max:100}},m={action:[],area:[{name:"multiple",selector:{boolean:{}}}],attribute:[{name:"entity_id",selector:{entity:{}}}],boolean:[],color_temp:[{name:"unit",selector:{select:{options:["kelvin","mired"]}}},{name:"min",selector:{number:{mode:"box"}}},{name:"max",selector:{number:{mode:"box"}}}],condition:[],date:[],datetime:[],device:[{name:"multiple",selector:{boolean:{}}}],duration:[{name:"enable_day",selector:{boolean:{}}},{name:"enable_millisecond",selector:{boolean:{}}}],entity:[{name:"multiple",selector:{boolean:{}}}],floor:[{name:"multiple",selector:{boolean:{}}}],icon:[],location:[],media:[],number:[{name:"min",selector:{number:{mode:"box",step:"any"}}},{name:"max",selector:{number:{mode:"box",step:"any"}}},{name:"step",selector:{number:{mode:"box",step:"any"}}}],object:[],color_rgb:[],select:[{name:"options",selector:{object:{}}},{name:"multiple",selector:{boolean:{}}}],state:[{name:"entity_id",selector:{entity:{}}}],target:[],template:[],text:[{name:"multiple",selector:{boolean:{}}},{name:"multiline",selector:{boolean:{}}},{name:"prefix",selector:{text:{}}},{name:"suffix",selector:{text:{}}}],theme:[],time:[]};let h=(0,o.Z)([(0,i.Mo)("ha-selector-selector")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"value",value:void 0},{kind:"field",decorators:[(0,i.Cb)()],key:"label",value:void 0},{kind:"field",decorators:[(0,i.Cb)()],key:"helper",value:void 0},{kind:"field",decorators:[(0,i.Cb)({type:Boolean,reflect:!0})],key:"disabled",value(){return!1}},{kind:"field",decorators:[(0,i.Cb)({type:Boolean,reflect:!0})],key:"required",value(){return!0}},{kind:"field",key:"_yamlMode",value(){return!1}},{kind:"method",key:"shouldUpdate",value:function(e){return 1!==e.size||!e.has("hass")}},{kind:"field",key:"_schema",value(){return(0,l.Z)(((e,t)=>[{name:"type",selector:{select:{mode:"dropdown",required:!0,options:Object.keys(m).concat("manual").map((e=>({label:t(`ui.components.selectors.selector.types.${e}`)||e,value:e})))}}},..."manual"===e?[{name:"manual",selector:{object:{}}}]:[],...m[e]?m[e].length>1?[{name:"",type:"expandable",title:t("ui.components.selectors.selector.options"),schema:m[e]}]:m[e]:[]]))}},{kind:"method",key:"render",value:function(){let e,t;if(this._yamlMode)t="manual",e={type:t,manual:this.value};else{t=Object.keys(this.value)[0];const a=Object.values(this.value)[0];e=Object.assign({type:t},"object"==typeof a?a:[])}const a=this._schema(t,this.hass.localize);return(0,n.dy)(s||(s=c`<ha-card> <div class="card-content"> <p>${0}</p> <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" -changed="${0}"></ha-form></div></ha-card>`),this.label?this.label:"",this.hass,e,a,this._computeLabelCallback,this._valueChanged)}},{kind:"method",key:"_valueChanged",value:function(e){e.stopPropagation();const t=e.detail.value,a=t.type;if(!a||"object"!=typeof t||0===Object.keys(t).length)return;const o=Object.keys(this.value)[0];if("manual"===a&&!this._yamlMode)return this._yamlMode=!0,void this.requestUpdate();if("manual"===a&&void 0===t.manual)return;let n;"manual"!==a&&(this._yamlMode=!1),delete t.type,n="manual"===a?t.manual:a===o?{[a]:Object.assign({},t.manual?t.manual[o]:t)}:{[a]:Object.assign({},u[a])},(0,r.B)(this,"value-changed",{value:n})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>this.hass.localize(`ui.components.selectors.selector.${e.name}`)||e.name}},{kind:"field",static:!0,key:"styles",value(){return(0,n.iv)(d||(d=c`:host{--expansion-panel-summary-padding:0 16px}ha-alert{display:block;margin-bottom:16px}ha-card{margin:0 0 16px 0}ha-card.disabled{pointer-events:none;color:var(--disabled-text-color)}.card-content{padding:0px 16px 16px 16px}.title{font-size:16px;padding-top:16px;overflow:hidden;text-overflow:ellipsis;margin-bottom:16px;padding-left:16px;padding-right:4px;padding-inline-start:16px;padding-inline-end:4px;white-space:nowrap}`))}}]}}),n.oi)}}]);
//# sourceMappingURL=94377.04077779d15287ea.js.map