UNPKG

iobroker.lovelace

Version:

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

1 lines 9.83 kB
export const __rspack_esm_id=88862;export const __rspack_esm_ids=[88862];export const __webpack_modules__={25453(e,a,t){t.a(e,async function(e,s){try{t.r(a),t.d(a,{HuiAreaCardEditor:()=>V});t(74423),t(18111),t(22489),t(61701),t(17642),t(58004),t(33853),t(45876),t(32475),t(15024),t(31698);var i=t(62826),o=t(5124),n=t(22441),r=t(22786),c=t(63533),l=t(1087),_=t(4423),h=t(52220),p=t(52763),u=t(64808),d=t(17366),m=t(91408),f=t(999),g=t(84698),v=t(7382),y=t(16161),b=e([p,d,f,y]);[p,d,f,y]=b.then?(await b)():b;const C="M10,9A1,1 0 0,1 11,8A1,1 0 0,1 12,9V13.47L13.21,13.6L18.15,15.79C18.68,16.03 19,16.56 19,17.14V21.5C18.97,22.32 18.32,22.97 17.5,23H11C10.62,23 10.26,22.85 10,22.57L5.1,18.37L5.84,17.6C6.03,17.39 6.3,17.28 6.58,17.28H6.8L10,19V9M11,5A4,4 0 0,1 15,9C15,10.5 14.2,11.77 13,12.46V11.24C13.61,10.69 14,9.89 14,9A3,3 0 0,0 11,6A3,3 0 0,0 8,9C8,9.89 8.39,10.69 9,11.24V12.46C7.8,11.77 7,10.5 7,9A4,4 0 0,1 11,5Z",$="M19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3M7 7H9V9H7V7M7 11H9V13H7V11M7 15H9V17H7V15M17 17H11V15H17V17M17 13H11V11H17V13M17 9H11V7H17V9Z",x="M4,9H20V11H4V9M4,13H14V15H4V13Z",H=(0,c.kp)(g.H,(0,c.Ik)({area:(0,c.lq)((0,c.Yj)()),name:(0,c.lq)((0,c.Yj)()),color:(0,c.lq)((0,c.Yj)()),navigation_path:(0,c.lq)((0,c.Yj)()),show_camera:(0,c.lq)((0,c.zM)()),display_type:(0,c.lq)((0,c.vP)(["compact","icon","picture","camera"])),vertical:(0,c.lq)((0,c.zM)()),camera_view:(0,c.lq)((0,c.Yj)()),alert_classes:(0,c.lq)((0,c.YO)((0,c.Yj)())),sensor_classes:(0,c.lq)((0,c.YO)((0,c.Yj)())),features:(0,c.lq)((0,c.YO)((0,c.bz)())),features_position:(0,c.lq)((0,c.vP)(["bottom","inline"])),aspect_ratio:(0,c.lq)((0,c.Yj)()),exclude_entities:(0,c.lq)((0,c.YO)((0,c.Yj)())),tap_action:(0,c.lq)(m.kn),image_tap_action:(0,c.lq)(m.kn)}));class V extends o.WF{_buildOptions(e,a,t){const s=[...new Set([...a,...t])].map(a=>{const t="sensor"===e?` (${d.SUM_DEVICE_CLASSES.includes(a)?this.hass.localize("ui.panel.lovelace.editor.card.area.sum"):this.hass.localize("ui.panel.lovelace.editor.card.area.median")})`:"";return{value:a,label:`${this.hass.localize(`component.${e}.entity_component.${a}.name`)||a}${t}`}});return s.sort((e,a)=>(0,h.SH)(e.label,a.label,this.hass.locale.language)),s}setConfig(e){(0,c.vA)(e,H);const a=e.display_type||(e.show_camera?"camera":"picture");this._config={...e,display_type:a},delete this._config.show_camera,this._featureContext={area_id:e.area,exclude_entities:e.exclude_entities}}async updated(){if(this.hass&&!this._numericDeviceClasses){const{numeric_device_classes:e}=await(0,u.KL)(this.hass);this._numericDeviceClasses=e}}render(){if(!this.hass||!this._config)return o.s6;const e=this._binaryClassesForArea(this._config.area,this._config.exclude_entities),a=this._sensorClassesForArea(this._config.area,this._config.exclude_entities,this._numericDeviceClasses),t=this._buildBinaryOptions(e,this._config.alert_classes||d.DEVICE_CLASSES.binary_sensor),s=this._buildSensorOptions(a,this._config.sensor_classes||d.DEVICE_CLASSES.sensor),i=this._config.display_type||(this._config.show_camera?"camera":"picture"),n=this._schema(this.hass.localize,i,t,s),r=this._config.vertical&&"compact"===i,c=this._featuresSchema(this.hass.localize,Boolean(r)),l={camera_view:"auto",alert_classes:d.DEVICE_CLASSES.binary_sensor,sensor_classes:d.DEVICE_CLASSES.sensor,display_type:i,content_layout:r?"vertical":"horizontal",...this._config};l.navigation_path&&!l.tap_action&&(l.tap_action={action:"navigate",navigation_path:l.navigation_path}),l.features_position&&!r||(l.features_position="bottom");const _=this._hasCompatibleFeatures(this._featureContext);return o.qy` <ha-form .hass="${this.hass}" .data="${l}" .schema="${n}" .computeLabel="${this._computeLabelCallback}" .computeHelper="${this._computeHelperCallback}" @value-changed="${this._valueChanged}"></ha-form> <ha-expansion-panel outlined> <ha-svg-icon slot="leading-icon" .path="${$}"></ha-svg-icon> <h3 slot="header"> ${this.hass.localize("ui.panel.lovelace.editor.card.generic.features")} </h3> <div class="content"> ${_?o.qy` <ha-form class="features-form" .hass="${this.hass}" .data="${l}" .schema="${c}" .computeLabel="${this._computeLabelCallback}" @value-changed="${this._valueChanged}"></ha-form> `:o.s6} <hui-card-features-editor .hass="${this.hass}" .context="${this._featureContext}" .features="${this._config.features??[]}" @features-changed="${this._featuresChanged}" @edit-detail-element="${this._editDetailElement}"></hui-card-features-editor> </div> </ha-expansion-panel> `}_valueChanged(e){const a=e.detail.value,t={features:this._config.features,...a};t.tap_action&&t.navigation_path&&delete t.navigation_path,"camera"!==t.display_type&&delete t.camera_view,t.image_tap_action&&("compact"===t.display_type||"camera"!==t.display_type&&"more-info"===t.image_tap_action.action)&&delete t.image_tap_action,t.content_layout&&(t.vertical="vertical"===t.content_layout,delete t.content_layout),(0,l.r)(this,"config-changed",{config:t})}_featuresChanged(e){if(e.stopPropagation(),!this._config||!this.hass)return;const a=e.detail.features,t={...this._config,features:a};0===a.length&&delete t.features,(0,l.r)(this,"config-changed",{config:t})}_editDetailElement(e){const a=e.detail.subElementConfig.index,t=this._config.features[a];(0,l.r)(this,"edit-sub-element",{config:t,saveConfig:e=>this._updateFeature(a,e),context:this._featureContext,type:"feature"})}_updateFeature(e,a){const t=this._config.features.concat();t[e]=a;const s={...this._config,features:t};(0,l.r)(this,"config-changed",{config:s})}static get styles(){return[v.U,o.AH`ha-form{display:block;margin-bottom:24px}.features-form{margin-bottom:8px}`]}constructor(...e){super(...e),this._featureContext={},this._schema=(0,r.A)((e,a,t,s)=>[{name:"area",selector:{area:{}}},{name:"content",flatten:!0,type:"expandable",iconPath:x,schema:[{name:"",type:"grid",schema:[{name:"name",selector:{text:{}}},{name:"color",selector:{ui_color:{}}},{name:"display_type",required:!0,selector:{select:{options:["compact","icon","picture","camera"].map(a=>({value:a,label:e(`ui.panel.lovelace.editor.card.area.display_type_options.${a}`)})),mode:"dropdown"}}},..."compact"===a?[{name:"content_layout",required:!0,selector:{select:{mode:"dropdown",options:["horizontal","vertical"].map(a=>({label:e(`ui.panel.lovelace.editor.card.area.content_layout_options.${a}`),value:a}))}}}]:[],..."camera"===a?[{name:"camera_view",selector:{select:{options:["auto","live"].map(a=>({value:a,label:e(`ui.panel.lovelace.editor.card.generic.camera_view_options.${a}`)})),mode:"dropdown"}}}]:[]]},{name:"alert_classes",selector:{select:{reorder:!0,multiple:!0,custom_value:!0,options:t}}},{name:"sensor_classes",selector:{select:{reorder:!0,multiple:!0,custom_value:!0,options:s}}}]},{name:"interactions",type:"expandable",flatten:!0,iconPath:C,schema:[{name:"tap_action",selector:{ui_action:{default_action:"none",actions:["navigate","url","perform-action","none"]}},context:f.Tq},..."compact"!==a?[{name:"image_tap_action",selector:{ui_action:{default_action:"camera"===a?"more-info":"none",actions:"camera"===a?["more-info","navigate","url","perform-action","none"]:["navigate","url","perform-action","none"]}},context:f.Tq}]:[]]}]),this._binaryClassesForArea=(0,r.A)((e,a)=>{if(!e)return[];const t=(0,_.r)(this.hass,{domain:"binary_sensor",area:e,entity_category:"none"}),s=Object.keys(this.hass.entities).filter(e=>t(e)&&!a?.includes(e)).map(e=>this.hass.states[e]?.attributes.device_class).filter(e=>Boolean(e));return[...new Set(s)]}),this._sensorClassesForArea=(0,r.A)((e,a,t)=>{if(!e)return[];const s=(0,_.r)(this.hass,{domain:"sensor",area:e,device_class:t,entity_category:"none"}),i=Object.keys(this.hass.entities).filter(e=>s(e)&&!a?.includes(e)).map(e=>this.hass.states[e]?.attributes.device_class).filter(e=>Boolean(e));return[...new Set(i)]}),this._buildBinaryOptions=(0,r.A)((e,a)=>this._buildOptions("binary_sensor",e,a)),this._buildSensorOptions=(0,r.A)((e,a)=>this._buildOptions("sensor",e,a)),this._featuresSchema=(0,r.A)((e,a)=>[{name:"features_position",required:!0,selector:{select:{mode:"box",options:["bottom","inline"].map(t=>({label:e(`ui.panel.lovelace.editor.card.tile.features_position_options.${t}`),description:e(`ui.panel.lovelace.editor.card.tile.features_position_options.${t}_description`),value:t,image:{src:`/static/images/form/tile_features_position_${t}.svg`,src_dark:`/static/images/form/tile_features_position_${t}_dark.svg`,flip_rtl:!0},disabled:a&&"inline"===t}))}}}]),this._hasCompatibleFeatures=(0,r.A)(e=>(0,y.uu)(this.hass,e).length>0),this._computeHelperCallback=e=>{if("alert_classes"===e.name)return"compact"===this._config?.display_type?this.hass.localize("ui.panel.lovelace.editor.card.area.alert_classes_helper"):void 0},this._computeLabelCallback=e=>{switch(e.name){case"area":return this.hass.localize("ui.panel.lovelace.editor.card.area.name");case"name":case"camera_view":case"content":case"interactions":case"tap_action":return this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`);case"image_tap_action":return this.hass.localize(`ui.panel.lovelace.editor.card.area.${e.name}`);case"features_position":return this.hass.localize(`ui.panel.lovelace.editor.card.tile.${e.name}`)}return this.hass.localize(`ui.panel.lovelace.editor.card.area.${e.name}`)}}}(0,i.Cg)([(0,n.MZ)({attribute:!1})],V.prototype,"hass",void 0),(0,i.Cg)([(0,n.wk)()],V.prototype,"_config",void 0),(0,i.Cg)([(0,n.wk)()],V.prototype,"_numericDeviceClasses",void 0),(0,i.Cg)([(0,n.wk)()],V.prototype,"_featureContext",void 0),V=(0,i.Cg)([(0,n.EM)("hui-area-card-editor")],V),s()}catch(e){s(e)}})},84698(e,a,t){t.d(a,{H:()=>i});var s=t(63533);const i=(0,s.Ik)({type:(0,s.Yj)(),view_layout:(0,s.bz)(),layout_options:(0,s.bz)(),grid_options:(0,s.bz)(),visibility:(0,s.bz)(),disabled:(0,s.lq)((0,s.zM)())})}};