UNPKG

iobroker.lovelace

Version:

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

1 lines 17 kB
export const __rspack_esm_id=1535;export const __rspack_esm_ids=[1535];export const __webpack_modules__={77122(t,e,i){i.a(t,async function(t,e){try{i(74423),i(18111),i(22489),i(61701);var s=i(62826),a=i(5124),o=i(22441),n=i(22786),r=i(1087),d=i(78649),l=(i(85938),i(82474)),h=t([l]);l=(h.then?(await h)():h)[0];const c="M21 11H3V9H21V11M21 13H3V15H21V13Z";class p extends a.WF{render(){if(!this.hass)return a.s6;const t=this._currentEntities;return a.qy` ${this.label?a.qy`<label>${this.label}</label>`:a.s6} <ha-sortable .disabled="${!this.reorder||this.disabled}" handle-selector=".entity-handle" @item-moved="${this._entityMoved}"> <div class="list"> ${t.map(t=>a.qy` <div class="entity"> <ha-entity-picker .curValue="${t}" .hass="${this.hass}" .includeDomains="${this.includeDomains}" .excludeDomains="${this.excludeDomains}" .includeEntities="${this.includeEntities}" .excludeEntities="${this.excludeEntities}" .includeDeviceClasses="${this.includeDeviceClasses}" .includeUnitOfMeasurement="${this.includeUnitOfMeasurement}" .entityFilter="${this.entityFilter}" .value="${t}" .disabled="${this.disabled}" .createDomains="${this.createDomains}" @value-changed="${this._entityChanged}"></ha-entity-picker> ${this.reorder?a.qy` <ha-svg-icon class="entity-handle" .path="${c}"></ha-svg-icon> `:a.s6} </div> `)} </div> </ha-sortable> <div> <ha-entity-picker .hass="${this.hass}" .includeDomains="${this.includeDomains}" .excludeDomains="${this.excludeDomains}" .includeEntities="${this.includeEntities}" .excludeEntities="${this._excludeEntities(this.value,this.excludeEntities)}" .includeDeviceClasses="${this.includeDeviceClasses}" .includeUnitOfMeasurement="${this.includeUnitOfMeasurement}" .entityFilter="${this.entityFilter}" .placeholder="${this.placeholder}" .helper="${this.helper}" .disabled="${this.disabled}" .createDomains="${this.createDomains}" .required="${this.required&&!t.length}" @value-changed="${this._addEntity}" .addButton="${t.length>0}"></ha-entity-picker> </div> `}_entityMoved(t){t.stopPropagation();const{oldIndex:e,newIndex:i}=t.detail,s=this._currentEntities,a=s[e],o=[...s];o.splice(e,1),o.splice(i,0,a),this._updateEntities(o)}get _currentEntities(){return this.value||[]}async _updateEntities(t){this.value=t,(0,r.r)(this,"value-changed",{value:t})}_entityChanged(t){t.stopPropagation();const e=t.currentTarget.curValue,i=t.detail.value;if(i===e||void 0!==i&&!(0,d.n)(i))return;const s=this._currentEntities;i&&!s.includes(i)?this._updateEntities(s.map(t=>t===e?i:t)):this._updateEntities(s.filter(t=>t!==e))}async _addEntity(t){t.stopPropagation();const e=t.detail.value;if(!e)return;if(t.currentTarget.value="",!e)return;const i=this._currentEntities;i.includes(e)||this._updateEntities([...i,e])}constructor(...t){super(...t),this.disabled=!1,this.required=!1,this.reorder=!1,this._excludeEntities=(0,n.A)((t,e)=>void 0===t?e:[...e||[],...t])}}p.styles=a.AH`div{margin-top:8px}label{display:block;margin:0 0 8px}.entity{display:flex;flex-direction:row;align-items:center}.entity ha-entity-picker{flex:1}.entity-handle{padding:8px;cursor:move;cursor:grab}`,(0,s.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Array})],p.prototype,"value",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],p.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],p.prototype,"required",void 0),(0,s.Cg)([(0,o.MZ)()],p.prototype,"label",void 0),(0,s.Cg)([(0,o.MZ)()],p.prototype,"placeholder",void 0),(0,s.Cg)([(0,o.MZ)()],p.prototype,"helper",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-domains"})],p.prototype,"includeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-domains"})],p.prototype,"excludeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-device-classes"})],p.prototype,"includeDeviceClasses",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-unit-of-measurement"})],p.prototype,"includeUnitOfMeasurement",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-entities"})],p.prototype,"includeEntities",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-entities"})],p.prototype,"excludeEntities",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"entityFilter",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"createDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],p.prototype,"reorder",void 0),p=(0,s.Cg)([(0,o.EM)("ha-entities-picker")],p),e()}catch(t){e(t)}})},82474(t,e,i){i.a(t,async function(t,e){try{i(18111),i(20116),i(61701);var s=i(62826),a=i(5124),o=i(22441),n=i(22786),r=i(1087),d=i(74705),l=i(78649),h=i(53756),c=i(95350),p=i(24367),u=i(19711),y=(i(75064),i(38508)),g=(i(47680),i(67094),i(74281)),b=t([y,g]);[y,g]=b.then?(await b)():b;const m="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",v="M11,13.5V21.5H3V13.5H11M12,2L17.5,11H6.5L12,2M17.5,13C20,13 22,15 22,17.5C22,20 20,22 17.5,22C15,22 13,20 13,17.5C13,15 15,13 17.5,13Z",_="___create-new-entity___";class C extends a.WF{willUpdate(t){this._pendingEntityId&&t.has("hass")&&this.hass.states!==t.get("hass")?.states&&this.hass.states[this._pendingEntityId]&&(this._setValue(this._pendingEntityId),this._pendingEntityId=void 0)}firstUpdated(t){super.firstUpdated(t),this.hass.loadBackendTranslation("title")}_findExtraOption(t){return t?this.extraOptions?.find(e=>e.id===t):void 0}_renderExtraOptionStart(t){const e=t.entity_id?this.hass.states[t.entity_id]:void 0;return e?a.qy` <state-badge slot="start" .stateObj="${e}" .hass="${this.hass}"></state-badge> `:t.icon_path?a.qy` <ha-svg-icon slot="start" .path="${t.icon_path}" style="margin:0 4px"></ha-svg-icon> `:t.icon?a.qy`<ha-icon slot="start" .icon="${t.icon}"></ha-icon>`:a.s6}get _showEntityId(){return this.showEntityId||this.hass.userData?.showEntityIdPicker}_shouldHideClearIcon(){return!!this._findExtraOption(this.value)?.hide_clear}render(){const t=this.placeholder??this.hass.localize("ui.components.entity.entity-picker.placeholder");return a.qy` <ha-generic-picker .hass="${this.hass}" .disabled="${this.disabled}" .autofocus="${this.autofocus}" .allowCustomValue="${this.allowCustomEntity}" .required="${this.required}" .label="${this.label}" .placeholder="${t}" .helper="${this.helper}" .value="${this.addButton?void 0:this.value}" .searchLabel="${this.searchLabel}" .notFoundLabel="${this._notFoundLabel}" .rowRenderer="${this._rowRenderer}" .getItems="${this._getItems}" .getAdditionalItems="${this._getAdditionalItems}" .hideClearIcon="${this.hideClearIcon||this._shouldHideClearIcon()}" .searchFn="${this._searchFn}" .valueRenderer="${this._valueRenderer}" .searchKeys="${h.t}" use-top-label .addButtonLabel="${this.addButton?this.addButtonLabel??this.hass.localize("ui.components.entity.entity-picker.add"):void 0}" .unknownItemText="${this.hass.localize("ui.components.entity.entity-picker.unknown")}" @value-changed="${this._valueChanged}"> </ha-generic-picker> `}async open(){await this.updateComplete,await(this._picker?.open())}_valueChanged(t){t.stopPropagation();const e=t.detail.value;if(e){if(e.startsWith(_)){const t=e.substring(_.length);return void(0,u.$)(this,{domain:t,dialogClosedCallback:t=>{t.entityId&&(this.hass.states[t.entityId]?this._setValue(t.entityId):this._pendingEntityId=t.entityId)}})}((0,l.n)(e)||this._findExtraOption(e))&&this._setValue(e)}else this._setValue(void 0)}_setValue(t){this.value=t,(0,r.r)(this,"value-changed",{value:t}),(0,r.r)(this,"change")}constructor(...t){super(...t),this.autofocus=!1,this.disabled=!1,this.required=!1,this.showEntityId=!1,this.hideClearIcon=!1,this.addButton=!1,this._valueRenderer=t=>{const e=t||"",i=this._findExtraOption(e);if(i)return a.qy` ${this._renderExtraOptionStart(i)} <span slot="headline">${i.primary}</span> ${i.secondary?a.qy`<span slot="supporting-text">${i.secondary}</span>`:a.s6} `;const s=this.hass.states[e];if(!s)return a.qy` <ha-svg-icon slot="start" .path="${v}" style="margin:0 4px"></ha-svg-icon> <span slot="headline">${e}</span> `;const{primary:o,secondary:n}=(0,d.Bj)(this.hass,s);return a.qy` <state-badge .hass="${this.hass}" .stateObj="${s}" slot="start"></state-badge> <span slot="headline">${o}</span> <span slot="supporting-text">${n}</span> `},this._rowRenderer=(t,e)=>{const i=this._showEntityId;return a.qy` <ha-combo-box-item type="button" compact="compact" .borderTop="${0!==e}"> ${t.icon_path?a.qy` <ha-svg-icon slot="start" style="margin:0 4px" .path="${t.icon_path}"></ha-svg-icon> `:a.qy` <state-badge slot="start" .stateObj="${t.stateObj}" .hass="${this.hass}"></state-badge> `} <span slot="headline">${t.primary}</span> ${t.secondary?a.qy`<span slot="supporting-text">${t.secondary}</span>`:a.s6} ${t.stateObj&&i?a.qy` <span slot="supporting-text" class="code"> ${t.stateObj.entity_id} </span> `:a.s6} ${t.domain_name&&!i?a.qy` <div slot="trailing-supporting-text" class="domain"> ${t.domain_name} </div> `:a.s6} </ha-combo-box-item> `},this._getAdditionalItems=()=>this._getCreateItems(this.hass.localize,this.createDomains),this._getCreateItems=(0,n.A)((t,e)=>e?.length?(this.hass.loadFragmentTranslation("config"),e.map(e=>{const i=t("ui.components.entity.entity-picker.create_helper",{domain:(0,p.z)(e)?t(`ui.panel.config.helpers.types.${e}`)||e:(0,c.p$)(t,e)});return{id:_+e,primary:i,secondary:t("ui.components.entity.entity-picker.new_entity"),icon_path:m}})):[]),this._getEntitiesMemoized=(0,n.A)(h.w),this._getItems=()=>{const t=this._getEntitiesMemoized(this.hass,this.includeDomains,this.excludeDomains,this.entityFilter,this.includeDeviceClasses,this.includeUnitOfMeasurement,this.includeEntities,this.excludeEntities,this.value);if(this.extraOptions?.length){return[...this.extraOptions.map(t=>({...t,stateObj:t.entity_id?this.hass.states[t.entity_id]:void 0})),...t]}return t},this._searchFn=(t,e)=>{const i=e.findIndex(e=>e.stateObj?.entity_id===t);if(-1===i)return e;const[s]=e.splice(i,1);return e.unshift(s),e},this._notFoundLabel=t=>this.hass.localize("ui.components.entity.entity-picker.no_match",{term:a.qy`<b>‘${t}’</b>`})}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],C.prototype,"autofocus",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],C.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],C.prototype,"required",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"allow-custom-entity"})],C.prototype,"allowCustomEntity",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"show-entity-id"})],C.prototype,"showEntityId",void 0),(0,s.Cg)([(0,o.MZ)()],C.prototype,"label",void 0),(0,s.Cg)([(0,o.MZ)()],C.prototype,"value",void 0),(0,s.Cg)([(0,o.MZ)()],C.prototype,"helper",void 0),(0,s.Cg)([(0,o.MZ)()],C.prototype,"placeholder",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"search-label"})],C.prototype,"searchLabel",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"createDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-domains"})],C.prototype,"includeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-domains"})],C.prototype,"excludeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-device-classes"})],C.prototype,"includeDeviceClasses",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-unit-of-measurement"})],C.prototype,"includeUnitOfMeasurement",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-entities"})],C.prototype,"includeEntities",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-entities"})],C.prototype,"excludeEntities",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"entityFilter",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"extraOptions",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"hide-clear-icon",type:Boolean})],C.prototype,"hideClearIcon",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"add-button",type:Boolean})],C.prototype,"addButton",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"add-button-label"})],C.prototype,"addButtonLabel",void 0),(0,s.Cg)([(0,o.P)("ha-generic-picker")],C.prototype,"_picker",void 0),(0,s.Cg)([(0,o.wk)()],C.prototype,"_pendingEntityId",void 0),C=(0,s.Cg)([(0,o.EM)("ha-entity-picker")],C),e()}catch(t){e(t)}})},85938(t,e,i){i(18111),i(22489),i(46058);var s=i(62826),a=i(5124),o=i(22441),n=i(1087);class r extends a.WF{updated(t){t.has("disabled")&&(this.disabled?this._destroySortable():this._createSortable())}disconnectedCallback(){super.disconnectedCallback(),this._shouldBeDestroy=!0,setTimeout(()=>{this._shouldBeDestroy&&(this._destroySortable(),this._shouldBeDestroy=!1)},1)}connectedCallback(){super.connectedCallback(),this._shouldBeDestroy=!1,this.hasUpdated&&!this.disabled&&this._createSortable()}createRenderRoot(){return this}render(){return this.noStyle?a.s6:a.qy` <style>.sortable-fallback{display:none!important}.sortable-ghost{box-shadow:0 0 0 2px var(--primary-color);background:rgba(var(--rgb-primary-color),.25);border-radius:var(--ha-border-radius-sm);opacity:.4}.sortable-drag{border-radius:var(--ha-border-radius-sm);opacity:1;background:var(--card-background-color);box-shadow:0px 4px 8px 3px #00000026;cursor:grabbing}</style> `}async _createSortable(){if(this._sortable)return;const t=this.children[0];if(!t)return;const e=(await Promise.all([i.e(85283),i.e(70322)]).then(i.bind(i,80745))).default,s={scroll:!0,forceAutoScrollFallback:!0,scrollSpeed:20,animation:150,...this.options,onChoose:this._handleChoose,onStart:this._handleStart,onEnd:this._handleEnd,onUpdate:this._handleUpdate,onAdd:this._handleAdd,onRemove:this._handleRemove};this.draggableSelector&&(s.draggable=this.draggableSelector),this.handleSelector&&(s.handle=this.handleSelector),void 0!==this.invertSwap&&(s.invertSwap=this.invertSwap),this.group&&(s.group=this.group),this.filter&&(s.filter=this.filter),this._sortable=new e(t,s)}_destroySortable(){this._sortable&&(this._sortable.destroy(),this._sortable=void 0)}constructor(...t){super(...t),this.disabled=!1,this.noStyle=!1,this.invertSwap=!1,this.rollback=!0,this._shouldBeDestroy=!1,this._handleUpdate=t=>{(0,n.r)(this,"item-moved",{newIndex:t.newIndex,oldIndex:t.oldIndex})},this._handleAdd=t=>{(0,n.r)(this,"item-added",{index:t.newIndex,data:t.item.sortableData,item:t.item})},this._handleRemove=t=>{(0,n.r)(this,"item-removed",{index:t.oldIndex})},this._handleEnd=async t=>{(0,n.r)(this,"drag-end"),this.rollback&&t.item.placeholder&&(t.item.placeholder.replaceWith(t.item),delete t.item.placeholder)},this._handleStart=()=>{(0,n.r)(this,"drag-start")},this._handleChoose=t=>{this.rollback&&(t.item.placeholder=document.createComment("sort-placeholder"),t.item.after(t.item.placeholder))}}}(0,s.Cg)([(0,o.MZ)({type:Boolean})],r.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"no-style"})],r.prototype,"noStyle",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"draggable-selector"})],r.prototype,"draggableSelector",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"handle-selector"})],r.prototype,"handleSelector",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"filter"})],r.prototype,"filter",void 0),(0,s.Cg)([(0,o.MZ)({type:String})],r.prototype,"group",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"invert-swap"})],r.prototype,"invertSwap",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],r.prototype,"options",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],r.prototype,"rollback",void 0),r=(0,s.Cg)([(0,o.EM)("ha-sortable")],r)},53756(t,e,i){i.d(e,{t:()=>d,w:()=>l});i(74423),i(18111),i(22489),i(61701);var s=i(71727),a=i(74705),o=i(28978),n=i(15638),r=i(95350);const d=[{name:"search_labels.entityName",weight:10},{name:"search_labels.friendlyName",weight:8},{name:"search_labels.deviceName",weight:7},{name:"search_labels.areaName",weight:6},{name:"search_labels.domainName",weight:6},{name:"search_labels.entityId",weight:3}],l=(t,e,i,d,l,h,c,p,u,y="")=>{let g,b=Object.keys(t.states);return c&&(b=b.filter(t=>c.includes(t))),p&&(b=b.filter(t=>!p.includes(t))),e&&(b=b.filter(t=>e.includes((0,s.m)(t)))),i&&(b=b.filter(t=>!i.includes((0,s.m)(t)))),g=b.map(e=>{const i=t.states[e],d=(0,o.u)(i),[l,h,c]=(0,a.Cf)(i,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),p=(0,r.p$)(t.localize,(0,s.m)(e)),u=(0,n.qC)(t.language,t.translationMetadata.translations),g=l||h||e,b=[c,l?h:void 0].filter(Boolean).join(u?" ◂ ":" ▸ ");return{id:`${y}${e}`,primary:g,secondary:b,domain_name:p,sorting_label:[g,b].filter(Boolean).join("_"),search_labels:{entityName:l||null,deviceName:h||null,areaName:c||null,domainName:p||null,friendlyName:d||null,entityId:e},stateObj:i}}),l&&(g=g.filter(t=>t.id===u||t.stateObj?.attributes.device_class&&l.includes(t.stateObj.attributes.device_class))),h&&(g=g.filter(t=>t.id===u||t.stateObj?.attributes.unit_of_measurement&&h.includes(t.stateObj.attributes.unit_of_measurement))),d&&(g=g.filter(t=>t.id===u||t.stateObj&&d(t.stateObj))),g}},19711(t,e,i){i.d(e,{$:()=>o});var s=i(1087);const a=()=>Promise.all([i.e(80131),i.e(70183),i.e(47677)]).then(i.bind(i,79029)),o=(t,e)=>{(0,s.r)(t,"show-dialog",{dialogTag:"dialog-helper-detail",dialogImport:a,dialogParams:e})}}};