UNPKG

iobroker.lovelace

Version:

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

1 lines 14.2 kB
export const __rspack_esm_id=34617;export const __rspack_esm_ids=[34617];export const __webpack_modules__={66033(e,t,a){a.d(t,{L:()=>s});const s=(e,t)=>{const a=e.floor_id;return{area:e,floor:(a?t[a]:void 0)||null}}},66086(e,t,a){a.a(e,async function(e,t){try{a(74423),a(18111),a(22489),a(61701);var s=a(62826),i=a(5124),r=a(22441),n=a(22786),o=a(1087),d=a(65522),l=a(55931),h=a(66033),c=a(49852),p=a(2514),u=a(65063),g=a(34023),_=(a(75064),a(38508)),m=a(26300),y=(a(67094),e([_,m]));[_,m]=y.then?(await y)():y;const v="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",f="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",b="___ADD_NEW___";class C extends i.WF{willUpdate(e){this._pendingAreaId&&e.has("hass")&&this.hass.areas!==e.get("hass")?.areas&&this.hass.areas[this._pendingAreaId]&&(this._setValue(this._pendingAreaId),this._pendingAreaId=void 0)}async open(){await this.updateComplete,await(this._picker?.open())}render(){const e=this.label??this.hass.localize("ui.components.area-picker.area"),t=this._computeValueRenderer(this.hass.areas);let a=e;if(this.value&&e){const e=this.hass.areas[this.value];if(e){const{floor:t}=(0,h.L)(e,this.hass.floors);t&&(a=void 0)}}return i.qy` <ha-generic-picker .hass="${this.hass}" .autofocus="${this.autofocus}" .label="${a}" .helper="${this.helper}" .notFoundLabel="${this._notFoundLabel}" .emptyLabel="${this.hass.localize("ui.components.area-picker.no_areas")}" .disabled="${this.disabled}" .required="${this.required}" .value="${this.value}" .getItems="${this._getItems}" .getAdditionalItems="${this._getAdditionalItems}" .valueRenderer="${t}" .addButtonLabel="${this.addButtonLabel}" .searchKeys="${c.P}" .unknownItemText="${this.hass.localize("ui.components.area-picker.unknown")}" @value-changed="${this._valueChanged}"> </ha-generic-picker> `}_valueChanged(e){e.stopPropagation();const t=e.detail.value;if(t){if(t.startsWith(b)){this.hass.loadFragmentTranslation("config");const e=t.substring(b.length);return void(0,g.J)(this,{suggestedName:e,createEntry:async e=>{try{const t=await(0,p.L3)(this.hass,e);this.hass.areas[t.area_id]?this._setValue(t.area_id):this._pendingAreaId=t.area_id}catch(e){(0,u.showAlertDialog)(this,{title:this.hass.localize("ui.components.area-picker.failed_create_area"),text:e.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 i.qy` <ha-svg-icon slot="start" .path="${f}"></ha-svg-icon> <span slot="headline">${t}</span> `;const{floor:a}=(0,h.L)(t,this.hass.floors),s=t?(0,d.A)(t):void 0,r=a?(0,l.X)(a):void 0,n=t.icon;return i.qy` ${n?i.qy`<ha-icon slot="start" .icon="${n}"></ha-icon>`:i.qy`<ha-svg-icon slot="start" .path="${f}"></ha-svg-icon>`} <span slot="headline">${s}</span> ${r?i.qy`<span slot="supporting-text">${r}</span>`: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=>(0,d.A)(e)?.toLowerCase()).filter(Boolean)),this._getAdditionalItems=e=>{if(this.noAdd)return[];const t=this._allAreaNames(this.hass.areas);return e&&!t.includes(e.toLowerCase())?[{id:b+e,primary:this.hass.localize("ui.components.area-picker.add_new_suggestion",{name:e}),icon_path:v}]:[{id:b,primary:this.hass.localize("ui.components.area-picker.add_new"),icon_path:v}]},this._notFoundLabel=e=>this.hass.localize("ui.components.area-picker.no_match",{term:i.qy`<b>‘${e}’</b>`})}}(0,s.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)()],C.prototype,"label",void 0),(0,s.Cg)([(0,r.MZ)()],C.prototype,"value",void 0),(0,s.Cg)([(0,r.MZ)()],C.prototype,"helper",void 0),(0,s.Cg)([(0,r.MZ)()],C.prototype,"placeholder",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean,attribute:"no-add"})],C.prototype,"noAdd",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"include-domains"})],C.prototype,"includeDomains",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"exclude-domains"})],C.prototype,"excludeDomains",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"include-device-classes"})],C.prototype,"includeDeviceClasses",void 0),(0,s.Cg)([(0,r.MZ)({type:Array,attribute:"exclude-areas"})],C.prototype,"excludeAreas",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"deviceFilter",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],C.prototype,"entityFilter",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"disabled",void 0),(0,s.Cg)([(0,r.MZ)({type:Boolean})],C.prototype,"required",void 0),(0,s.Cg)([(0,r.MZ)({attribute:"add-button-label"})],C.prototype,"addButtonLabel",void 0),(0,s.Cg)([(0,r.P)("ha-generic-picker")],C.prototype,"_picker",void 0),(0,s.Cg)([(0,r.wk)()],C.prototype,"_pendingAreaId",void 0),C=(0,s.Cg)([(0,r.EM)("ha-area-picker")],C),t()}catch(e){t(e)}})},77677(e,t,a){a.a(e,async function(e,t){try{a(74423),a(44114),a(18111),a(22489),a(61701),a(46058);var s=a(62826),i=a(5124),r=a(22441),n=a(1087),o=a(24717),d=a(14503),l=a(38962),h=a(66086),c=(a(67094),e([l,h]));[l,h]=c.then?(await c)():c;const p="M14 16.94V12.94H5.08L5.05 10.93H14V6.94L19 11.94Z";class u 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 i.qy` <div class="loading">${this.hass.localize("ui.common.loading")}...</div> `;if(this._error)return i.qy` <ha-alert alert-type="error">${this._error}</ha-alert> `;if(!this._segments||0===this._segments.length)return i.qy` <ha-alert alert-type="info"> ${this.hass.localize("ui.dialogs.vacuum_segment_mapping.no_segments")} </ha-alert> `;const e=this._groupSegments(this._segments);return i.qy` ${Object.entries(e).map(([e,t])=>i.qy` ${e?i.qy`<h2>${e}</h2>`: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 i.qy` <div class="segment-row"> <span class="segment-name">${e.name}</span> <ha-svg-icon class="arrow" .path="${p}"></ha-svg-icon> <ha-area-picker .hass="${this.hass}" .value="${t}" .label="${this.hass.localize("ui.dialogs.vacuum_segment_mapping.area_label")}" @value-changed="${this._handleAreaChanged}" data-segment-id="${e.id}"></ha-area-picker> </div> `}_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={...this.value};for(const t of Object.keys(s))s[t]=s[t].filter(t=>t!==e),0===s[t].length&&delete s[t];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)}}}u.styles=[d.RF,i.AH`: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)}@media (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})],u.prototype,"hass",void 0),(0,s.Cg)([(0,r.MZ)({attribute:"entity-id"})],u.prototype,"entityId",void 0),(0,s.Cg)([(0,r.MZ)({attribute:!1})],u.prototype,"value",void 0),(0,s.Cg)([(0,r.wk)()],u.prototype,"_segments",void 0),(0,s.Cg)([(0,r.wk)()],u.prototype,"_loading",void 0),(0,s.Cg)([(0,r.wk)()],u.prototype,"_error",void 0),u=(0,s.Cg)([(0,r.EM)("ha-vacuum-segment-area-mapper")],u),t()}catch(e){t(e)}})},49852(e,t,a){a.d(t,{P:()=>l,j:()=>d});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 d=(e,t,a,d,l,h,c,p,u,g,_,m="")=>{let y,v,f={};const b=Object.values(e),C=Object.values(a),w=Object.values(d);(h||c||p||u||g)&&(f=(0,o.g2)(w),y=C,v=w.filter(e=>e.area_id),h&&(y=y.filter(e=>{const t=f[e.id];return!(!t||!t.length)&&f[e.id].some(e=>h.includes((0,i.m)(e.entity_id)))}),v=v.filter(e=>h.includes((0,i.m)(e.entity_id)))),c&&(y=y.filter(e=>{const t=f[e.id];return!t||!t.length||w.every(e=>!c.includes((0,i.m)(e.entity_id)))}),v=v.filter(e=>!c.includes((0,i.m)(e.entity_id)))),p&&(y=y.filter(e=>{const t=f[e.id];return!(!t||!t.length)&&f[e.id].some(e=>{const t=l[e.entity_id];return!!t&&(t.attributes.device_class&&p.includes(t.attributes.device_class))})}),v=v.filter(e=>{const t=l[e.entity_id];return t.attributes.device_class&&p.includes(t.attributes.device_class)})),u&&(y=y.filter(e=>u(e))),g&&(y=y.filter(e=>{const t=f[e.id];return!(!t||!t.length)&&f[e.id].some(e=>{const t=l[e.entity_id];return!!t&&g(t)})}),v=v.filter(e=>{const t=l[e.entity_id];return!!t&&g(t)})));let M,$=b;y&&(M=y.filter(e=>e.area_id).map(e=>e.area_id)),v&&(M=(M??[]).concat(v.filter(e=>e.area_id).map(e=>e.area_id))),M&&($=$.filter(e=>M.includes(e.area_id))),_&&($=$.filter(e=>!_.includes(e.area_id)));return $.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:`${m}${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(" ")}}})},l=[{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}]},2514(e,t,a){a.d(t,{L3:()=>d,uG:()=>h,QI:()=>u,bQ:()=>p,WT:()=>c,ft:()=>o,gs:()=>l});a(44114);var s=a(35518),i=a(9899);const r=e=>e.sendMessagePromise({type:"config/area_registry/list"}),n=(e,t)=>e.subscribeEvents((0,i.s)(()=>r(e).then(e=>t.setState(e,!0)),500,!0),"area_registry_updated"),o=(e,t)=>(0,s.N)("_areaRegistry",r,n,e,t),d=(e,t)=>e.callWS({type:"config/area_registry/create",...t}),l=(e,t,a)=>e.callWS({type:"config/area_registry/update",area_id:t,...a}),h=(e,t)=>e.callWS({type:"config/area_registry/delete",area_id:t}),c=(e,t)=>e.callWS({type:"config/area_registry/reorder",area_ids:t}),p=e=>{const t={};for(const a of e)a.area_id&&(a.area_id in t||(t[a.area_id]=[]),t[a.area_id].push(a));return t},u=e=>{const t={};for(const a of e)a.area_id&&(a.area_id in t||(t[a.area_id]=[]),t[a.area_id].push(a));return t}},64480(e,t,a){a.a(e,async function(e,s){try{a.r(t),a.d(t,{HaMoreInfoViewVacuumSegmentMapping:()=>u});var i=a(62826),r=a(5124),n=a(22441),o=a(1087),d=a(18350),l=a(65829),h=a(77677),c=a(59241),p=e([d,l,h]);[d,l,h]=p.then?(await p)():p;class u extends r.WF{firstUpdated(){this._loadCurrentMapping()}async _loadCurrentMapping(){this.params.entityId&&(this._entry=await(0,c.v)(this.hass,this.params.entityId),this._entry?.options?.vacuum?this._areaMapping=this._entry.options.vacuum.area_mapping||{}:this._areaMapping={})}_valueChanged(e){this._areaMapping=e.detail.value,this._dirty=!0}async _save(){if(!this.params.entityId||!this._areaMapping)return;this._error=void 0,this._submitting=!0;const e=this.shadowRoot.querySelector("ha-vacuum-segment-area-mapper"),t={...this._entry?.options?.vacuum??{},area_mapping:this._areaMapping,last_seen_segments:e.lastSeenSegments};try{await(0,c.G_)(this.hass,this.params.entityId,{options_domain:"vacuum",options:t}),this._dirty=!1,(0,o.r)(this,"close-child-view")}catch(e){this._error=e.message}finally{this._submitting=!1}}render(){return this._areaMapping?r.qy` <div class="content"> ${this._error?r.qy`<ha-alert alert-type="error">${this._error}</ha-alert>`:r.s6} <ha-vacuum-segment-area-mapper .hass="${this.hass}" .entityId="${this.params.entityId}" .value="${this._areaMapping}" @value-changed="${this._valueChanged}"></ha-vacuum-segment-area-mapper> <div class="footer"> <ha-button @click="${this._save}" .disabled="${!this._dirty||this._submitting}"> ${this.hass.localize("ui.common.save")} </ha-button> </div> </div> `:r.qy`<ha-spinner active></ha-spinner>`}constructor(...e){super(...e),this._submitting=!1,this._dirty=!1}}u.styles=r.AH`:host{display:block}.content{display:flex;flex-direction:column}ha-spinner{margin:var(--ha-space-8);display:flex;justify-self:center}ha-vacuum-segment-area-mapper{flex:1;padding-inline-start:var(--ha-space-2)}.footer{display:flex;justify-content:flex-end;padding:var(--ha-space-4);border-top:1px solid var(--divider-color);background:var(--ha-dialog-surface-background,var(--mdc-theme-surface,#fff));position:sticky;bottom:0;z-index:10}`,(0,i.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,i.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"params",void 0),(0,i.Cg)([(0,n.wk)()],u.prototype,"_areaMapping",void 0),(0,i.Cg)([(0,n.wk)()],u.prototype,"_submitting",void 0),(0,i.Cg)([(0,n.wk)()],u.prototype,"_dirty",void 0),(0,i.Cg)([(0,n.wk)()],u.prototype,"_error",void 0),u=(0,i.Cg)([(0,n.EM)("ha-more-info-view-vacuum-segment-mapping")],u),s()}catch(e){s(e)}})},34023(e,t,a){a.d(t,{E:()=>i,J:()=>r});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(42209),a.e(26092),a.e(8851),a.e(66201),a.e(26295),a.e(52808),a.e(93e3),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})}}};