iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 11.6 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[34174],{66033:function(e,t,a){a.d(t,{L:function(){return s}});const s=(e,t)=>{const a=e.floor_id;return{area:e,floor:(a?t[a]:void 0)||null}}},66086:function(e,t,a){a.a(e,async function(e,t){try{a(74423),a(18111),a(22489),a(61701),a(3362),a(62953);var s=a(40445),i=a(5124),r=a(67576),n=a(22786),o=a(1087),l=a(65522),d=a(55931),h=a(66033),c=a(49852),u=a(53641),p=a(65063),g=a(34023),_=(a(75064),a(38508)),v=a(26300),m=(a(67094),e([_,v]));[_,v]=m.then?(await m)():m;let y,f,b,C,$,w,A,M=e=>e;const L="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",k="M20 2H4C2.9 2 2 2.9 2 4V20C2 21.11 2.9 22 4 22H20C21.11 22 22 21.11 22 20V4C22 2.9 21.11 2 20 2M4 6L6 4H10.9L4 10.9V6M4 13.7L13.7 4H18.6L4 18.6V13.7M20 18L18 20H13.1L20 13.1V18M20 10.3L10.3 20H5.4L20 5.4V10.3Z",V="___ADD_NEW___";class x extends i.WF{willUpdate(e){var t;this._pendingAreaId&&e.has("hass")&&this.hass.areas!==(null===(t=e.get("hass"))||void 0===t?void 0:t.areas)&&this.hass.areas[this._pendingAreaId]&&(this._setValue(this._pendingAreaId),this._pendingAreaId=void 0)}async open(){var e;await this.updateComplete,await(null===(e=this._picker)||void 0===e?void 0:e.open())}render(){var e;const t=null!==(e=this.label)&&void 0!==e?e:this.hass.localize("ui.components.area-picker.area"),a=this._computeValueRenderer(this.hass.areas);let s=t;if(this.value&&t){const e=this.hass.areas[this.value];if(e){const{floor:t}=(0,h.L)(e,this.hass.floors);t&&(s=void 0)}}return(0,i.qy)(y||(y=M` <ha-generic-picker .hass="${0}" .autofocus="${0}" .label="${0}" .helper="${0}" .notFoundLabel="${0}" .emptyLabel="${0}" .disabled="${0}" .required="${0}" .value="${0}" .getItems="${0}" .getAdditionalItems="${0}" .valueRenderer="${0}" .addButtonLabel="${0}" .searchKeys="${0}" .unknownItemText="${0}" -changed="${0}"> </ha-generic-picker> `),this.hass,this.autofocus,s,this.helper,this._notFoundLabel,this.hass.localize("ui.components.area-picker.no_areas"),this.disabled,this.required,this.value,this._getItems,this._getAdditionalItems,a,this.addButtonLabel,c.P,this.hass.localize("ui.components.area-picker.unknown"),this._valueChanged)}_valueChanged(e){e.stopPropagation();const t=e.detail.value;if(t){if(t.startsWith(V)){this.hass.loadFragmentTranslation("config");const e=t.substring(V.length);return void(0,g.J)(this,{suggestedName:e,createEntry:async e=>{try{const t=await(0,u.L3)(this.hass,e);this.hass.areas[t.area_id]?this._setValue(t.area_id):this._pendingAreaId=t.area_id}catch(t){(0,p.showAlertDialog)(this,{title:this.hass.localize("ui.components.area-picker.failed_create_area"),text:t.message})}}})}this._setValue(t)}else this._setValue(void 0)}_setValue(e){this.value=e,(0,o.r)(this,"value-changed",{value:e}),(0,o.r)(this,"change")}constructor(...e){super(...e),this.noAdd=!1,this.disabled=!1,this.required=!1,this._getAreasMemoized=(0,n.A)(c.j),this._computeValueRenderer=(0,n.A)(e=>e=>{const t=this.hass.areas[e];if(!t)return(0,i.qy)(f||(f=M` <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> <span slot="headline">${0}</span> `),k,t);const{floor:a}=(0,h.L)(t,this.hass.floors),s=t?(0,l.A)(t):void 0,r=a?(0,d.X)(a):void 0,n=t.icon;return(0,i.qy)(b||(b=M` ${0} <span slot="headline">${0}</span> ${0} `),n?(0,i.qy)(C||(C=M`<ha-icon slot="start" .icon="${0}"></ha-icon>`),n):(0,i.qy)($||($=M`<ha-svg-icon slot="start" .path="${0}"></ha-svg-icon>`),k),s,r?(0,i.qy)(w||(w=M`<span slot="supporting-text">${0}</span>`),r):i.s6)}),this._getItems=()=>this._getAreasMemoized(this.hass.areas,this.hass.floors,this.hass.devices,this.hass.entities,this.hass.states,this.includeDomains,this.excludeDomains,this.includeDeviceClasses,this.deviceFilter,this.entityFilter,this.excludeAreas),this._allAreaNames=(0,n.A)(e=>Object.values(e).map(e=>{var t;return null===(t=(0,l.A)(e))||void 0===t?void 0:t.toLowerCase()}).filter(Boolean)),this._getAdditionalItems=e=>{if(this.noAdd)return[];const t=this._allAreaNames(this.hass.areas);return e&&!t.includes(e.toLowerCase())?[{id:V+e,primary:this.hass.localize("ui.components.area-picker.add_new_suggestion",{name:e}),icon_path:L}]:[{id:V,primary:this.hass.localize("ui.components.area-picker.add_new"),icon_path:L}]},this._notFoundLabel=e=>this.hass.localize("ui.components.area-picker.no_match",{term:(0,i.qy)(A||(A=M`<b>‘${0}’</b>`),e)})}}(0,s.Cg)([(0,r.MZ)({attribute:!1})],x.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)()],x.prototype,"label",void 0),(0,s.Cg)([(0,r.MZ)()],x.prototype,"value",void 0),(0,s.Cg)([(0,r.MZ)()],x.prototype,"helper",void 0),(0,s.Cg)([(0,r.MZ)()],x.prototype,"placeholder",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean,attribute:"no-add"})],x.prototype,"noAdd",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"include-domains"})],x.prototype,"includeDomains",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"exclude-domains"})],x.prototype,"excludeDomains",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"include-device-classes"})],x.prototype,"includeDeviceClasses",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"exclude-areas"})],x.prototype,"excludeAreas",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],x.prototype,"deviceFilter",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],x.prototype,"entityFilter",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],x.prototype,"disabled",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],x.prototype,"required",void 0),(0,s.Cg)([(0,r.MZ)({attribute:"add-button-label"})],x.prototype,"addButtonLabel",void 0),(0,s.Cg)([(0,r.P)("ha-generic-picker")],x.prototype,"_picker",void 0),(0,s.Cg)([(0,r.wk)()],x.prototype,"_pendingAreaId",void 0),x=(0,s.Cg)([(0,r.EM)("ha-area-picker")],x),t()}catch(y){t(y)}})},77677:function(e,t,a){a.a(e,async function(e,t){try{a(74423),a(44114),a(18111),a(22489),a(61701),a(3362),a(46058),a(62953);var s=a(40445),i=a(5124),r=a(67576),n=a(1087),o=a(24717),l=a(14503),d=a(38962),h=a(66086),c=(a(67094),e([d,h]));[d,h]=c.then?(await c)():c;let u,p,g,_,v,m,y,f,b=e=>e;const C="M14 16.94V12.94H5.08L5.05 10.93H14V6.94L19 11.94Z";class $ extends i.WF{get lastSeenSegments(){return this._segments}willUpdate(e){super.willUpdate(e),e.has("entityId")&&this.entityId&&this._loadSegments()}async _loadSegments(){this._loading=!0,this._error=void 0;try{const e=await(0,o.qT)(this.hass,this.entityId);this._segments=e.segments}catch(e){this._error=e.message||"Failed to load segments",this._segments=void 0}finally{this._loading=!1}}render(){if(this._loading)return(0,i.qy)(u||(u=b` <div class="loading">${0}...</div> `),this.hass.localize("ui.common.loading"));if(this._error)return(0,i.qy)(p||(p=b` <ha-alert alert-type="error">${0}</ha-alert> `),this._error);if(!this._segments||0===this._segments.length)return(0,i.qy)(g||(g=b` <ha-alert alert-type="info"> ${0} </ha-alert> `),this.hass.localize("ui.dialogs.vacuum_segment_mapping.no_segments"));const e=this._groupSegments(this._segments);return(0,i.qy)(_||(_=b` ${0} `),Object.entries(e).map(([e,t])=>(0,i.qy)(v||(v=b` ${0} ${0} `),e?(0,i.qy)(m||(m=b`<h2>${0}</h2>`),e):i.s6,t.map(e=>this._renderSegment(e)))))}_groupSegments(e){const t={};for(const a of e){const e=a.group||"";t[e]||(t[e]=[]),t[e].push(a)}return t}_renderSegment(e){const t=this._getSegmentAreas(e.id);return(0,i.qy)(y||(y=b` <div class="segment-row"> <span class="segment-name">${0}</span> <ha-svg-icon class="arrow" .path="${0}"></ha-svg-icon> <ha-area-picker .hass="${0}" .value="${0}" .label="${0}" -changed="${0}" data-segment-id="${0}"></ha-area-picker> </div> `),e.name,C,this.hass,t,this.hass.localize("ui.dialogs.vacuum_segment_mapping.area_label"),this._handleAreaChanged,e.id)}_getSegmentAreas(e){if(this.value)for(const[t,a]of Object.entries(this.value))if(a.includes(e))return t}_areaChanged(e,t){t.stopPropagation();const a=t.detail.value,s=Object.assign({},this.value);for(const i of Object.keys(s))s[i]=s[i].filter(t=>t!==e),0===s[i].length&&delete s[i];a&&(s[a]||(s[a]=[]),s[a].push(e)),(0,n.r)(this,"value-changed",{value:s})}constructor(...e){super(...e),this._loading=!1,this._handleAreaChanged=e=>{const t=e.currentTarget.dataset.segmentId;t&&this._areaChanged(t,e)}}}$.styles=[l.RF,(0,i.AH)(f||(f=b`:host{display:block}.segment-row{display:flex;align-items:center;gap:var(--ha-space-4);padding:var(--ha-space-2) var(--ha-space-4)}.segment-name{flex:1;font:var(--ha-font-body-l);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.arrow{flex-shrink:0;color:var(--secondary-text-color)} (max-width:600px){.arrow{display:none}}ha-area-picker{flex:2;min-width:0;max-width:300px}h2{margin:0;margin-inline-start:var(--ha-space-4)}.loading{padding:var(--ha-space-4);text-align:center;color:var(--secondary-text-color)}`))],(0,s.Cg)([(0,r.MZ)({attribute:!1})],$.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)({attribute:"entity-id"})],$.prototype,"entityId",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],$.prototype,"value",void 0),(0,s.Cg)([(0,r.wk)()],$.prototype,"_segments",void 0),(0,s.Cg)([(0,r.wk)()],$.prototype,"_loading",void 0),(0,s.Cg)([(0,r.wk)()],$.prototype,"_error",void 0),$=(0,s.Cg)([(0,r.EM)("ha-vacuum-segment-area-mapper")],$),t()}catch(u){t(u)}})},49852:function(e,t,a){a.d(t,{P:function(){return d},j:function(){return l}});a(74423),a(18111),a(81148),a(22489),a(61701),a(13579);var s=a(65522),i=a(71727),r=a(55931),n=a(66033),o=a(58594);const l=(e,t,a,l,d,h,c,u,p,g,_,v="")=>{let m,y,f={};const b=Object.values(e),C=Object.values(a),$=Object.values(l);(h||c||u||p||g)&&(f=(0,o.g2)($),m=C,y=$.filter(e=>e.area_id),h&&(m=m.filter(e=>{const t=f[e.id];return!(!t||!t.length)&&f[e.id].some(e=>h.includes((0,i.m)(e.entity_id)))}),y=y.filter(e=>h.includes((0,i.m)(e.entity_id)))),c&&(m=m.filter(e=>{const t=f[e.id];return!t||!t.length||$.every(e=>!c.includes((0,i.m)(e.entity_id)))}),y=y.filter(e=>!c.includes((0,i.m)(e.entity_id)))),u&&(m=m.filter(e=>{const t=f[e.id];return!(!t||!t.length)&&f[e.id].some(e=>{const t=d[e.entity_id];return!!t&&(t.attributes.device_class&&u.includes(t.attributes.device_class))})}),y=y.filter(e=>{const t=d[e.entity_id];return t.attributes.device_class&&u.includes(t.attributes.device_class)})),p&&(m=m.filter(e=>p(e))),g&&(m=m.filter(e=>{const t=f[e.id];return!(!t||!t.length)&&f[e.id].some(e=>{const t=d[e.entity_id];return!!t&&g(t)})}),y=y.filter(e=>{const t=d[e.entity_id];return!!t&&g(t)})));let w,A=b;m&&(w=m.filter(e=>e.area_id).map(e=>e.area_id)),y&&(w=(null!=w?w:[]).concat(y.filter(e=>e.area_id).map(e=>e.area_id))),w&&(A=A.filter(e=>w.includes(e.area_id))),_&&(A=A.filter(e=>!_.includes(e.area_id)));return A.map(e=>{const{floor:a}=(0,n.L)(e,t),i=a?(0,r.X)(a):void 0,o=(0,s.A)(e);return{id:`${v}${e.area_id}`,primary:o||e.area_id,secondary:i,icon:e.icon||void 0,icon_path:e.icon?void 0:"M20 2H4C2.9 2 2 2.9 2 4V20C2 21.11 2.9 22 4 22H20C21.11 22 22 21.11 22 20V4C22 2.9 21.11 2 20 2M4 6L6 4H10.9L4 10.9V6M4 13.7L13.7 4H18.6L4 18.6V13.7M20 18L18 20H13.1L20 13.1V18M20 10.3L10.3 20H5.4L20 5.4V10.3Z",search_labels:{areaId:e.area_id,aliases:e.aliases.join(" ")}}})},d=[{name:"primary",weight:10},{name:"search_labels.aliases",weight:8},{name:"secondary",weight:6},{name:"search_labels.domain",weight:4},{name:"search_labels.areaId",weight:2}]},34023:function(e,t,a){a.d(t,{E:function(){return i},J:function(){return r}});a(3362),a(62953);var s=a(1087);const i=()=>Promise.all([a.e(32450),a.e(7305),a.e(92769),a.e(3283),a.e(85010),a.e(89100),a.e(33889),a.e(62574),a.e(26092),a.e(39005),a.e(8851),a.e(66201),a.e(52808),a.e(33887),a.e(33790),a.e(61023)]).then(a.bind(a,39803)),r=(e,t)=>{(0,s.r)(e,"show-dialog",{dialogTag:"dialog-area-registry-detail",dialogImport:i,dialogParams:t})}}}]);