UNPKG

iobroker.lovelace

Version:

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

1 lines 16.3 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[1535],{77122:function(t,e,i){i.a(t,async function(t,e){try{i(74423),i(18111),i(22489),i(61701),i(3362),i(62953);var s=i(40445),a=i(5124),o=i(67576),n=i(22786),r=i(1087),d=i(78649),l=(i(85938),i(82474)),h=t([l]);l=(h.then?(await h)():h)[0];let p,c,u,y,g,v=t=>t;const b="M21 11H3V9H21V11M21 13H3V15H21V13Z";class m extends a.WF{render(){if(!this.hass)return a.s6;const t=this._currentEntities;return(0,a.qy)(p||(p=v` ${0} <ha-sortable .disabled="${0}" handle-selector=".entity-handle" @item-moved="${0}"> <div class="list"> ${0} </div> </ha-sortable> <div> <ha-entity-picker .hass="${0}" .includeDomains="${0}" .excludeDomains="${0}" .includeEntities="${0}" .excludeEntities="${0}" .includeDeviceClasses="${0}" .includeUnitOfMeasurement="${0}" .entityFilter="${0}" .placeholder="${0}" .helper="${0}" .disabled="${0}" .createDomains="${0}" .required="${0}" @value-changed="${0}" .addButton="${0}"></ha-entity-picker> </div> `),this.label?(0,a.qy)(c||(c=v`<label>${0}</label>`),this.label):a.s6,!this.reorder||this.disabled,this._entityMoved,t.map(t=>(0,a.qy)(u||(u=v` <div class="entity"> <ha-entity-picker .curValue="${0}" .hass="${0}" .includeDomains="${0}" .excludeDomains="${0}" .includeEntities="${0}" .excludeEntities="${0}" .includeDeviceClasses="${0}" .includeUnitOfMeasurement="${0}" .entityFilter="${0}" .value="${0}" .disabled="${0}" .createDomains="${0}" @value-changed="${0}"></ha-entity-picker> ${0} </div> `),t,this.hass,this.includeDomains,this.excludeDomains,this.includeEntities,this.excludeEntities,this.includeDeviceClasses,this.includeUnitOfMeasurement,this.entityFilter,t,this.disabled,this.createDomains,this._entityChanged,this.reorder?(0,a.qy)(y||(y=v` <ha-svg-icon class="entity-handle" .path="${0}"></ha-svg-icon> `),b):a.s6)),this.hass,this.includeDomains,this.excludeDomains,this.includeEntities,this._excludeEntities(this.value,this.excludeEntities),this.includeDeviceClasses,this.includeUnitOfMeasurement,this.entityFilter,this.placeholder,this.helper,this.disabled,this.createDomains,this.required&&!t.length,this._addEntity,t.length>0)}_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])}}m.styles=(0,a.AH)(g||(g=v`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})],m.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Array})],m.prototype,"value",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],m.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],m.prototype,"required",void 0),(0,s.Cg)([(0,o.MZ)()],m.prototype,"label",void 0),(0,s.Cg)([(0,o.MZ)()],m.prototype,"placeholder",void 0),(0,s.Cg)([(0,o.MZ)()],m.prototype,"helper",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-domains"})],m.prototype,"includeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-domains"})],m.prototype,"excludeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-device-classes"})],m.prototype,"includeDeviceClasses",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-unit-of-measurement"})],m.prototype,"includeUnitOfMeasurement",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-entities"})],m.prototype,"includeEntities",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-entities"})],m.prototype,"excludeEntities",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"entityFilter",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],m.prototype,"createDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],m.prototype,"reorder",void 0),m=(0,s.Cg)([(0,o.EM)("ha-entities-picker")],m),e()}catch(p){e(p)}})},82474:function(t,e,i){i.a(t,async function(t,e){try{i(13609),i(18111),i(20116),i(61701),i(3362),i(62953);var s=i(40445),a=i(5124),o=i(67576),n=i(22786),r=i(1087),d=i(74705),l=i(78649),h=i(53756),p=i(95350),c=i(24367),u=i(19711),y=(i(75064),i(38508)),g=(i(47680),i(67094),i(74281)),v=t([y,g]);[y,g]=v.then?(await v)():v;let b,m,_,C,$,x,M,f,E,Z,k,w,I,D,S,B=t=>t;const O="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",q="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",A="___create-new-entity___";class V extends a.WF{willUpdate(t){var e;this._pendingEntityId&&t.has("hass")&&this.hass.states!==(null===(e=t.get("hass"))||void 0===e?void 0:e.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){var e;return t?null===(e=this.extraOptions)||void 0===e?void 0:e.find(e=>e.id===t):void 0}_renderExtraOptionStart(t){const e=t.entity_id?this.hass.states[t.entity_id]:void 0;return e?(0,a.qy)(b||(b=B` <state-badge slot="start" .stateObj="${0}" .hass="${0}"></state-badge> `),e,this.hass):t.icon_path?(0,a.qy)(m||(m=B` <ha-svg-icon slot="start" .path="${0}" style="margin:0 4px"></ha-svg-icon> `),t.icon_path):t.icon?(0,a.qy)(_||(_=B`<ha-icon slot="start" .icon="${0}"></ha-icon>`),t.icon):a.s6}get _showEntityId(){var t;return this.showEntityId||(null===(t=this.hass.userData)||void 0===t?void 0:t.showEntityIdPicker)}_shouldHideClearIcon(){var t;return!(null===(t=this._findExtraOption(this.value))||void 0===t||!t.hide_clear)}render(){var t,e;const i=null!==(t=this.placeholder)&&void 0!==t?t:this.hass.localize("ui.components.entity.entity-picker.placeholder");return(0,a.qy)(C||(C=B` <ha-generic-picker .hass="${0}" .disabled="${0}" .autofocus="${0}" .allowCustomValue="${0}" .required="${0}" .label="${0}" .placeholder="${0}" .helper="${0}" .value="${0}" .searchLabel="${0}" .notFoundLabel="${0}" .rowRenderer="${0}" .getItems="${0}" .getAdditionalItems="${0}" .hideClearIcon="${0}" .searchFn="${0}" .valueRenderer="${0}" .searchKeys="${0}" use-top-label .addButtonLabel="${0}" .unknownItemText="${0}" @value-changed="${0}"> </ha-generic-picker> `),this.hass,this.disabled,this.autofocus,this.allowCustomEntity,this.required,this.label,i,this.helper,this.addButton?void 0:this.value,this.searchLabel,this._notFoundLabel,this._rowRenderer,this._getItems,this._getAdditionalItems,this.hideClearIcon||this._shouldHideClearIcon(),this._searchFn,this._valueRenderer,h.t,this.addButton?null!==(e=this.addButtonLabel)&&void 0!==e?e:this.hass.localize("ui.components.entity.entity-picker.add"):void 0,this.hass.localize("ui.components.entity.entity-picker.unknown"),this._valueChanged)}async open(){var t;await this.updateComplete,await(null===(t=this._picker)||void 0===t?void 0:t.open())}_valueChanged(t){t.stopPropagation();const e=t.detail.value;if(e){if(e.startsWith(A)){const t=e.substring(A.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(0,a.qy)($||($=B` ${0} <span slot="headline">${0}</span> ${0} `),this._renderExtraOptionStart(i),i.primary,i.secondary?(0,a.qy)(x||(x=B`<span slot="supporting-text">${0}</span>`),i.secondary):a.s6);const s=this.hass.states[e];if(!s)return(0,a.qy)(M||(M=B` <ha-svg-icon slot="start" .path="${0}" style="margin:0 4px"></ha-svg-icon> <span slot="headline">${0}</span> `),q,e);const{primary:o,secondary:n}=(0,d.Bj)(this.hass,s);return(0,a.qy)(f||(f=B` <state-badge .hass="${0}" .stateObj="${0}" slot="start"></state-badge> <span slot="headline">${0}</span> <span slot="supporting-text">${0}</span> `),this.hass,s,o,n)},this._rowRenderer=(t,e)=>{const i=this._showEntityId;return(0,a.qy)(E||(E=B` <ha-combo-box-item type="button" compact="compact" .borderTop="${0}"> ${0} <span slot="headline">${0}</span> ${0} ${0} ${0} </ha-combo-box-item> `),0!==e,t.icon_path?(0,a.qy)(Z||(Z=B` <ha-svg-icon slot="start" style="margin:0 4px" .path="${0}"></ha-svg-icon> `),t.icon_path):(0,a.qy)(k||(k=B` <state-badge slot="start" .stateObj="${0}" .hass="${0}"></state-badge> `),t.stateObj,this.hass),t.primary,t.secondary?(0,a.qy)(w||(w=B`<span slot="supporting-text">${0}</span>`),t.secondary):a.s6,t.stateObj&&i?(0,a.qy)(I||(I=B` <span slot="supporting-text" class="code"> ${0} </span> `),t.stateObj.entity_id):a.s6,t.domain_name&&!i?(0,a.qy)(D||(D=B` <div slot="trailing-supporting-text" class="domain"> ${0} </div> `),t.domain_name):a.s6)},this._getAdditionalItems=()=>this._getCreateItems(this.hass.localize,this.createDomains),this._getCreateItems=(0,n.A)((t,e)=>null!=e&&e.length?(this.hass.loadFragmentTranslation("config"),e.map(e=>{const i=t("ui.components.entity.entity-picker.create_helper",{domain:(0,c.z)(e)?t(`ui.panel.config.helpers.types.${e}`)||e:(0,p.p$)(t,e)});return{id:A+e,primary:i,secondary:t("ui.components.entity.entity-picker.new_entity"),icon_path:O}})):[]),this._getEntitiesMemoized=(0,n.A)(h.w),this._getItems=()=>{var t;const e=this._getEntitiesMemoized(this.hass,this.includeDomains,this.excludeDomains,this.entityFilter,this.includeDeviceClasses,this.includeUnitOfMeasurement,this.includeEntities,this.excludeEntities,this.value);if(null!==(t=this.extraOptions)&&void 0!==t&&t.length){return[...this.extraOptions.map(t=>Object.assign(Object.assign({},t),{},{stateObj:t.entity_id?this.hass.states[t.entity_id]:void 0})),...e]}return e},this._searchFn=(t,e)=>{const i=e.findIndex(e=>{var i;return(null===(i=e.stateObj)||void 0===i?void 0:i.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:(0,a.qy)(S||(S=B`<b>‘${0}’</b>`),t)})}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],V.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],V.prototype,"autofocus",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],V.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],V.prototype,"required",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"allow-custom-entity"})],V.prototype,"allowCustomEntity",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"show-entity-id"})],V.prototype,"showEntityId",void 0),(0,s.Cg)([(0,o.MZ)()],V.prototype,"label",void 0),(0,s.Cg)([(0,o.MZ)()],V.prototype,"value",void 0),(0,s.Cg)([(0,o.MZ)()],V.prototype,"helper",void 0),(0,s.Cg)([(0,o.MZ)()],V.prototype,"placeholder",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"search-label"})],V.prototype,"searchLabel",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],V.prototype,"createDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-domains"})],V.prototype,"includeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-domains"})],V.prototype,"excludeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-device-classes"})],V.prototype,"includeDeviceClasses",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-unit-of-measurement"})],V.prototype,"includeUnitOfMeasurement",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-entities"})],V.prototype,"includeEntities",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-entities"})],V.prototype,"excludeEntities",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],V.prototype,"entityFilter",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],V.prototype,"extraOptions",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"hide-clear-icon",type:Boolean})],V.prototype,"hideClearIcon",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"add-button",type:Boolean})],V.prototype,"addButton",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"add-button-label"})],V.prototype,"addButtonLabel",void 0),(0,s.Cg)([(0,o.P)("ha-generic-picker")],V.prototype,"_picker",void 0),(0,s.Cg)([(0,o.wk)()],V.prototype,"_pendingEntityId",void 0),V=(0,s.Cg)([(0,o.EM)("ha-entity-picker")],V),e()}catch(b){e(b)}})},85938:function(t,e,i){i(18111),i(22489),i(3362),i(46058),i(62953);var s=i(40445),a=i(5124),o=i(67576),n=i(1087);let r,d=t=>t;class l 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:(0,a.qy)(r||(r=d` <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=Object.assign(Object.assign({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})],l.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"no-style"})],l.prototype,"noStyle",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"draggable-selector"})],l.prototype,"draggableSelector",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"handle-selector"})],l.prototype,"handleSelector",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"filter"})],l.prototype,"filter",void 0),(0,s.Cg)([(0,o.MZ)({type:String})],l.prototype,"group",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"invert-swap"})],l.prototype,"invertSwap",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],l.prototype,"options",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],l.prototype,"rollback",void 0),l=(0,s.Cg)([(0,o.EM)("ha-sortable")],l)}}]);