iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.15 kB
JavaScript
;(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[20196],{23929:function(e,t,s){s.a(e,async function(e,i){try{s.d(t,{k:function(){return v}});var o=s(86518),a=(s(18111),s(61701),s(62953),s(40445)),n=s(5124),r=s(67576),d=s(22786),c=s(1087),l=s(52763),u=e([l]);l=(u.then?(await u)():u)[0];let m,p=e=>e;const f=["customize_modes"];function _(e){const{customize_modes:t}=e;return(0,o.A)(e,f)}class v extends n.WF{setConfig(e){e.type===this.descriptor.featureType&&(this._config=e)}render(){var e;if(!this.hass||!this._config)return n.s6;const t=null!==(e=this.context)&&void 0!==e&&e.entity_id?this.hass.states[this.context.entity_id]:void 0,{modeField:s,defaultStyle:i}=this.descriptor,o=Object.assign(Object.assign({style:i},this._config),{},{customize_modes:void 0!==this._config[s]}),a=this._schema(this.hass.localize,t,o.customize_modes);return(0,n.qy)(m||(m=p` <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" @value-changed="${0}"></ha-form> `),this.hass,o,a,this._computeLabelCallback,this._valueChanged)}_valueChanged(e){var t;const s=e.detail.value,i=s.customize_modes;let o=_(s);const a=null!==(t=this.context)&&void 0!==t&&t.entity_id?this.hass.states[this.context.entity_id]:void 0,{modeField:n,getAvailableModesOrdered:r}=this.descriptor,d=n;i&&!o[d]&&(o=Object.assign(Object.assign({},o),{},{[n]:r(a)})),i||void 0===o[d]||delete o[d],(0,c.r)(this,"config-changed",{config:o})}constructor(...e){super(...e),this._schema=(0,d.A)((e,t,s)=>{var i;const o=this.descriptor,a=null!==(i=o.styleListI18nFeatureId)&&void 0!==i?i:o.i18nFeatureId;return[{name:"style",selector:{select:{multiple:!1,mode:"list",options:["dropdown","icons"].map(t=>({value:t,label:e(`ui.panel.lovelace.editor.features.types.${a}.style_list.${t}`)}))}}},{name:"customize_modes",selector:{boolean:{}}},...s?[{name:o.modeField,selector:{select:{reorder:!0,multiple:!0,options:o.getAvailableModesOrdered(t).map(e=>({value:e,label:o.getModeLabel(this.hass,t,e)}))}}}]:[]]}),this._computeLabelCallback=e=>{const t=this.descriptor.i18nFeatureId,{modeField:s}=this.descriptor;return"style"===e.name||"customize_modes"===e.name||e.name===s?this.hass.localize(`ui.panel.lovelace.editor.features.types.${t}.${e.name}`):""}}}(0,a.Cg)([(0,r.MZ)({attribute:!1})],v.prototype,"hass",void 0),(0,a.Cg)([(0,r.MZ)({attribute:!1})],v.prototype,"context",void 0),(0,a.Cg)([(0,r.wk)()],v.prototype,"_config",void 0),i()}catch(h){i(h)}})},97999:function(e,t,s){s.a(e,async function(e,i){try{s.r(t),s.d(t,{HuiFanPresetModesCardFeatureEditor:function(){return c}});s(62953);var o=s(40445),a=s(67576),n=s(23929),r=e([n]);n=(r.then?(await r)():r)[0];const d={featureType:"fan-preset-modes",i18nFeatureId:"fan-preset-modes",modeField:"preset_modes",defaultStyle:"dropdown",getAvailableModesOrdered:e=>{var t;return null!==(t=null==e?void 0:e.attributes.preset_modes)&&void 0!==t?t:[]},getModeLabel:(e,t,s)=>t?e.formatEntityAttributeValue(t,"preset_mode",s):s};class c extends n.k{constructor(...e){super(...e),this.descriptor=d}}c=(0,o.Cg)([(0,a.EM)("hui-fan-preset-modes-card-feature-editor")],c),i()}catch(d){i(d)}})}}]);