UNPKG

iobroker.lovelace

Version:

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

1 lines 11.3 kB
export const __rspack_esm_id=54884;export const __rspack_esm_ids=[54884];export const __webpack_modules__={81816(t,e,i){i.d(e,{aH:()=>o,cx:()=>r,es:()=>c});var s=i(37981),a=i(28978),n=i(79461);const o=(t,e,i)=>{const s=e[t.entity_id];return s?r(s,i):(0,a.u)(t)},r=(t,e,i)=>{const o=t.name||("original_name"in t&&null!=t.original_name?String(t.original_name):void 0),r=t.device_id?e[t.device_id]:void 0;if(!r)return o||(i?(0,a.u)(i):void 0);const c=(0,s.xn)(r);return c!==o?c&&o&&(0,n.p)(o,c)||o:void 0},c=(t,e,i)=>!o(t,e,i)},74705(t,e,i){i.d(e,{Bj:()=>u,Cf:()=>p,uU:()=>h});i(18111),i(81148),i(22489),i(61701),i(13579);if(66649!=i.j)var s=i(44537);var a=i(15638),n=i(65522),o=i(37981),r=i(81816),c=i(55931);if(66649!=i.j)var l=i(28978);var d=i(28455);const h=(t,e,i,a,n,o,c)=>{if("string"==typeof e)return e;if(!e)return(0,l.u)(t);let d=(0,s.e)(e);const h=c?.separator??" ";if(d.every(t=>"text"===t.type))return d.map(t=>t.text).join(h);if((0,r.es)(t,i,a)){d.some(t=>"device"===t.type)||(d=d.map(t=>"entity"===t.type?{type:"device"}:t))}const u=p(t,d,i,a,n,o);return 1===u.length?u[0]||"":u.filter(t=>t).join(h)},p=(t,e,i,s,a,l)=>{const{device:h,area:p,floor:u}=(0,d.ln)(t,i,s,a,l);return e.map(e=>{switch(e.type){case"entity":return(0,r.aH)(t,i,s);case"device":return h?(0,o.xn)(h):void 0;case"area":return p?(0,n.A)(p):void 0;case"floor":return u?(0,c.X)(u):void 0;case"text":return e.text;default:return""}})},u=(t,e)=>{const[i,s,n]=p(e,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),o=(0,a.qC)(t.language,t.translationMetadata.translations);return{primary:i||s||e.entity_id,secondary:[n,i?s:void 0].filter(Boolean).join(o?" ◂ ":" ▸ ")||void 0}}},81423(t,e,i){i.a(t,async function(t,e){try{i(74423),i(44114),i(18111),i(22489),i(20116),i(7588);var s=i(62826),a=i(5124),n=i(22441),o=i(22786),r=i(44537),c=i(1087),l=i(74705),d=i(28978),h=i(15638),p=i(95350),u=i(23528),y=i(36918),_=(i(75064),i(38508)),m=i(26300),g=(i(67094),i(74281)),v=t([_,m,g]);[_,m,g]=v.then?(await v)():v;const b="M16,11.78L20.24,4.45L21.97,5.45L16.74,14.5L10.23,10.75L5.46,19H22V21H2V3H4V17.54L9.5,8L16,11.78Z",f="M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z",C="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",$="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",M=["entity","external","no_state"],x="___missing-entity___",I=[{name:"label",weight:10},{name:"search_labels.entityName",weight:10},{name:"search_labels.friendlyName",weight:9},{name:"search_labels.deviceName",weight:8},{name:"search_labels.areaName",weight:6},{name:"search_labels.domainName",weight:4},{name:"statisticId",weight:3},{name:"id",weight:2}];class w extends a.WF{willUpdate(t){(!this.hasUpdated&&!this.statisticIds||t.has("statisticTypes"))&&this._getStatisticIds()}async _getStatisticIds(){this.statisticIds=await(0,u.p3)(this.hass,this.statisticTypes),this._picker?.requestUpdate(),this._valueRenderer=this._makeValueRenderer()}_renderValue(t){const e=t,i=this._computeItem(e);return a.qy` ${i.stateObj?a.qy` <state-badge .hass="${this.hass}" .stateObj="${i.stateObj}" slot="start"></state-badge> `:i.icon_path?a.qy` <ha-svg-icon slot="start" .path="${i.icon_path}"></ha-svg-icon> `:a.s6} <span slot="headline">${i.primary}</span> ${i.secondary?a.qy`<span slot="supporting-text">${i.secondary}</span>`:a.s6} ${this.canEdit?a.qy`<ha-icon-button slot="end" .value="${e}" .label="${this.hass.localize("ui.common.edit")}" .path="${C}" @click="${this._editItem}"></ha-icon-button>`:a.s6} `}_makeValueRenderer(){return t=>this._renderValue(t)}_editItem(t){t.stopPropagation();const e=t.currentTarget.value;(0,c.r)(this,"edit-statistics-element",{statisticId:e})}_computeItem(t){const e=this.hass.states[t];if(e){const[i,s,a]=(0,l.Cf)(e,[{type:"entity"},{type:"device"},{type:"area"}],this.hass.entities,this.hass.devices,this.hass.areas,this.hass.floors),n=(0,h.qC)(this.hass.language,this.hass.translationMetadata.translations),o=i||s||t,r=[a,i?s:void 0].filter(Boolean).join(n?" ◂ ":" ▸ "),c=(0,d.u)(e);return{id:t,statistic_id:t,primary:o,secondary:r,stateObj:e,type:"entity",sorting_label:[`${M.indexOf("entity")}`,s,i].join("_"),search_labels:{entityName:i||null,deviceName:s||null,areaName:a||null,friendlyName:c,statisticId:t}}}const i=this.statisticIds?this._statisticMetaData(t,this.statisticIds):void 0;if(i){if("external"===(t.includes(":")&&!t.includes(".")?"external":"no_state")){const e=`${M.indexOf("external")}`,s=(0,u.$O)(this.hass,t,i),a=t.split(":")[0],n=(0,p.p$)(this.hass.localize,a);return{id:t,statistic_id:t,primary:s,secondary:n,type:"external",sorting_label:[e,s].join("_"),search_labels:{label:s,domainName:n,statisticId:t},icon_path:b}}}const s=`${M.indexOf("external")}`,a=(0,u.$O)(this.hass,t,i);return{id:t,primary:a,secondary:this.hass.localize("ui.components.statistic-picker.no_state"),type:"no_state",sorting_label:[s,a].join("_"),search_labels:{label:a,statisticId:t},icon_path:$}}render(){const t=this.placeholder??this.hass.localize("ui.components.statistic-picker.placeholder");return a.qy` <ha-generic-picker .hass="${this.hass}" .autofocus="${this.autofocus}" .allowCustomValue="${this.allowCustomEntity}" .disabled="${this.disabled}" .label="${this.label}" use-top-label .placeholder="${t}" .value="${this.value}" .notFoundLabel="${this._notFoundLabel}" .emptyLabel="${this.hass.localize("ui.components.statistic-picker.no_statistics")}" .rowRenderer="${this._rowRenderer}" .getItems="${this._getItems}" .getAdditionalItems="${this._getAdditionalItems}" .hideClearIcon="${this.hideClearIcon}" .searchFn="${this._searchFn}" .valueRenderer="${this._valueRenderer}" .helper="${this.helper}" .searchKeys="${I}" .unknownItemText="${this.hass.localize("ui.components.statistic-picker.unknown")}" @value-changed="${this._valueChanged}"> </ha-generic-picker> `}_valueChanged(t){t.stopPropagation();const e=t.detail.value;e!==x?(this.value=e,(0,c.r)(this,"value-changed",{value:e})):window.open((0,y.o)(this.hass,this.helpMissingEntityUrl),"_blank")}async open(){await this.updateComplete,await(this._picker?.open())}constructor(...t){super(...t),this.autofocus=!1,this.disabled=!1,this.required=!1,this.helpMissingEntityUrl="/more-info/statistics/",this.entitiesOnly=!1,this.hideClearIcon=!1,this._getItems=()=>this._getStatisticsItems(this.hass,this.statisticIds,this.includeStatisticsUnitOfMeasurement,this.includeUnitClass,this.includeDeviceClass,this.entitiesOnly,this.excludeStatistics,this.value),this._getAdditionalItems=()=>[{id:x,primary:this.hass.localize("ui.components.statistic-picker.missing_entity"),icon_path:f}],this._getStatisticsItems=(0,o.A)((t,e,i,s,a,n,o,c)=>{if(!e)return;if(i){const t=(0,r.e)(i);e=e.filter(e=>t.includes(e.statistics_unit_of_measurement))}if(s){const t=(0,r.e)(s);e=e.filter(e=>t.includes(e.unit_class))}if(a){const t=(0,r.e)(a);e=e.filter(e=>{const i=this.hass.states[e.statistic_id];return!i||t.includes(i.attributes.device_class||"")})}const y=(0,h.qC)(t.language,t.translationMetadata.translations),_=[];return e.forEach(e=>{if(o&&e.statistic_id!==c&&o.includes(e.statistic_id))return;const i=this.hass.states[e.statistic_id];if(!i){if(!n){const t=e.statistic_id,i=(0,u.$O)(this.hass,e.statistic_id,e),s=e.statistic_id.includes(":")&&!e.statistic_id.includes(".")?"external":"no_state",a=`${M.indexOf(s)}`;if("no_state"===s)_.push({id:t,primary:i,secondary:this.hass.localize("ui.components.statistic-picker.no_state"),type:s,sorting_label:[a,i].join("_"),icon_path:$});else if("external"===s){const e=t.split(":")[0],n=(0,p.p$)(this.hass.localize,e);_.push({id:t,statistic_id:t,primary:i,secondary:n,type:s,sorting_label:[a,i].join("_"),search_labels:{label:i,domainName:n},icon_path:b})}}return}const s=e.statistic_id,a=(0,d.u)(i),[r,h,m]=(0,l.Cf)(i,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),g=r||h||s,v=[m,r?h:void 0].filter(Boolean).join(y?" ◂ ":" ▸ "),f=`${M.indexOf("entity")}`;_.push({id:s,statistic_id:s,primary:g,secondary:v,stateObj:i,type:"entity",sorting_label:[f,h,r].join("_"),search_labels:{entityName:r||null,deviceName:h||null,areaName:m||null,friendlyName:a}})}),_}),this._statisticMetaData=(0,o.A)((t,e)=>{if(e)return e.find(e=>e.statistic_id===t)}),this._valueRenderer=this._makeValueRenderer(),this._rowRenderer=(t,e)=>{const i=this.hass.userData?.showEntityIdPicker;return a.qy` <ha-combo-box-item type="button" compact="compact" .borderTop="${0!==e}"> ${t.icon_path?a.qy` <ha-svg-icon style="margin:0 4px" slot="start" .path="${t.icon_path}"></ha-svg-icon> `:t.stateObj?a.qy` <state-badge slot="start" .stateObj="${t.stateObj}" .hass="${this.hass}"></state-badge> `:a.s6} <span slot="headline">${t.primary} </span> ${t.secondary?a.qy`<span slot="supporting-text">${t.secondary}</span>`:a.s6} ${t.statistic_id&&i?a.qy`<span slot="supporting-text" class="code"> ${t.statistic_id} </span>`:a.s6} </ha-combo-box-item> `},this._searchFn=(t,e)=>{const i=e.findIndex(e=>e.stateObj?.entity_id===t||e.statistic_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.statistic-picker.no_match",{term:a.qy`<b>‘${t}’</b>`})}}(0,s.Cg)([(0,n.MZ)({attribute:!1})],w.prototype,"hass",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean})],w.prototype,"autofocus",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean})],w.prototype,"disabled",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean})],w.prototype,"required",void 0),(0,s.Cg)([(0,n.MZ)()],w.prototype,"label",void 0),(0,s.Cg)([(0,n.MZ)()],w.prototype,"value",void 0),(0,s.Cg)([(0,n.MZ)()],w.prototype,"helper",void 0),(0,s.Cg)([(0,n.MZ)()],w.prototype,"placeholder",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"statistic-types"})],w.prototype,"statisticTypes",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean,attribute:"allow-custom-entity"})],w.prototype,"allowCustomEntity",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],w.prototype,"statisticIds",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],w.prototype,"helpMissingEntityUrl",void 0),(0,s.Cg)([(0,n.MZ)({type:Array,attribute:"include-statistics-unit-of-measurement"})],w.prototype,"includeStatisticsUnitOfMeasurement",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"include-unit-class"})],w.prototype,"includeUnitClass",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"include-device-class"})],w.prototype,"includeDeviceClass",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean,attribute:"entities-only"})],w.prototype,"entitiesOnly",void 0),(0,s.Cg)([(0,n.MZ)({type:Array,attribute:"exclude-statistics"})],w.prototype,"excludeStatistics",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"hide-clear-icon",type:Boolean})],w.prototype,"hideClearIcon",void 0),(0,s.Cg)([(0,n.P)("ha-generic-picker")],w.prototype,"_picker",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"can-edit",type:Boolean})],w.prototype,"canEdit",void 0),w=(0,s.Cg)([(0,n.EM)("ha-statistic-picker")],w),e()}catch(t){e(t)}})}};