iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 11.9 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[54884],{81816:function(t,e,i){i.d(e,{aH:function(){return o},cx:function(){return r},es:function(){return l}});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 l=(0,s.xn)(r);return l!==o?l&&o&&(0,n.p)(o,l)||o:void 0},l=(t,e,i)=>!o(t,e,i)},74705:function(t,e,i){i.d(e,{Bj:function(){return p},Cf:function(){return u},uU:function(){return h}});i(18111),i(81148),i(22489),i(61701),i(13579),i(62953);if(66649!=i.j)var s=i(44537);var a=i(15638),n=i(65522),o=i(37981),r=i(81816),l=i(55931),c=i(28978),d=i(28455);const h=(t,e,i,a,n,o,l)=>{var d;if("string"==typeof e)return e;if(!e)return(0,c.u)(t);let h=(0,s.e)(e);const p=null!==(d=null==l?void 0:l.separator)&&void 0!==d?d:" ";if(h.every(t=>"text"===t.type))return h.map(t=>t.text).join(p);if((0,r.es)(t,i,a)){h.some(t=>"device"===t.type)||(h=h.map(t=>"entity"===t.type?{type:"device"}:t))}const y=u(t,h,i,a,n,o);return 1===y.length?y[0]||"":y.filter(t=>t).join(p)},u=(t,e,i,s,a,c)=>{const{device:h,area:u,floor:p}=(0,d.ln)(t,i,s,a,c);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 u?(0,n.A)(u):void 0;case"floor":return p?(0,l.X)(p):void 0;case"text":return e.text;default:return""}})},p=(t,e)=>{const[i,s,n]=u(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:function(t,e,i){i.a(t,async function(t,e){try{i(74423),i(44114),i(13609),i(18111),i(22489),i(20116),i(7588),i(3362),i(62953);var s=i(40445),a=i(5124),n=i(67576),o=i(22786),r=i(44537),l=i(1087),c=i(74705),d=i(28978),h=i(15638),u=i(95350),p=i(23528),y=i(36918),_=(i(75064),i(38508)),m=i(26300),v=(i(67094),i(74281)),g=t([_,m,v,p]);[_,m,v,p]=g.then?(await g)():g;let f,b,C,$,M,x,I,k,w,Z,j,O,L=t=>t;const q="M16,11.78L20.24,4.45L21.97,5.45L16.74,14.5L10.23,10.75L5.46,19H22V21H2V3H4V17.54L9.5,8L16,11.78Z",A="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",N="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",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",H=["entity","external","no_state"],B="___missing-entity___",U=[{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 z extends a.WF{willUpdate(t){(!this.hasUpdated&&!this.statisticIds||t.has("statisticTypes"))&&this._getStatisticIds()}async _getStatisticIds(){var t;this.statisticIds=await(0,p.p3)(this.hass,this.statisticTypes),null===(t=this._picker)||void 0===t||t.requestUpdate(),this._valueRenderer=this._makeValueRenderer()}_renderValue(t){const e=t,i=this._computeItem(e);return(0,a.qy)(f||(f=L` ${0} <span slot="headline">${0}</span> ${0} ${0} `),i.stateObj?(0,a.qy)(b||(b=L` <state-badge .hass="${0}" .stateObj="${0}" slot="start"></state-badge> `),this.hass,i.stateObj):i.icon_path?(0,a.qy)(C||(C=L` <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> `),i.icon_path):a.s6,i.primary,i.secondary?(0,a.qy)($||($=L`<span slot="supporting-text">${0}</span>`),i.secondary):a.s6,this.canEdit?(0,a.qy)(M||(M=L`<ha-icon-button slot="end" .value="${0}" .label="${0}" .path="${0}" ="${0}"></ha-icon-button>`),e,this.hass.localize("ui.common.edit"),N,this._editItem):a.s6)}_makeValueRenderer(){return t=>this._renderValue(t)}_editItem(t){t.stopPropagation();const e=t.currentTarget.value;(0,l.r)(this,"edit-statistics-element",{statisticId:e})}_computeItem(t){const e=this.hass.states[t];if(e){const[i,s,a]=(0,c.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?" ◂ ":" ▸ "),l=(0,d.u)(e);return{id:t,statistic_id:t,primary:o,secondary:r,stateObj:e,type:"entity",sorting_label:[`${H.indexOf("entity")}`,s,i].join("_"),search_labels:{entityName:i||null,deviceName:s||null,areaName:a||null,friendlyName:l,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=`${H.indexOf("external")}`,s=(0,p.$O)(this.hass,t,i),a=t.split(":")[0],n=(0,u.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:q}}}const s=`${H.indexOf("external")}`,a=(0,p.$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:V}}render(){var t;const e=null!==(t=this.placeholder)&&void 0!==t?t:this.hass.localize("ui.components.statistic-picker.placeholder");return(0,a.qy)(x||(x=L` <ha-generic-picker .hass="${0}" .autofocus="${0}" .allowCustomValue="${0}" .disabled="${0}" .label="${0}" use-top-label .placeholder="${0}" .value="${0}" .notFoundLabel="${0}" .emptyLabel="${0}" .rowRenderer="${0}" .getItems="${0}" .getAdditionalItems="${0}" .hideClearIcon="${0}" .searchFn="${0}" .valueRenderer="${0}" .helper="${0}" .searchKeys="${0}" .unknownItemText="${0}" -changed="${0}"> </ha-generic-picker> `),this.hass,this.autofocus,this.allowCustomEntity,this.disabled,this.label,e,this.value,this._notFoundLabel,this.hass.localize("ui.components.statistic-picker.no_statistics"),this._rowRenderer,this._getItems,this._getAdditionalItems,this.hideClearIcon,this._searchFn,this._valueRenderer,this.helper,U,this.hass.localize("ui.components.statistic-picker.unknown"),this._valueChanged)}_valueChanged(t){t.stopPropagation();const e=t.detail.value;e!==B?(this.value=e,(0,l.r)(this,"value-changed",{value:e})):window.open((0,y.o)(this.hass,this.helpMissingEntityUrl),"_blank")}async open(){var t;await this.updateComplete,await(null===(t=this._picker)||void 0===t?void 0:t.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:B,primary:this.hass.localize("ui.components.statistic-picker.missing_entity"),icon_path:A}],this._getStatisticsItems=(0,o.A)((t,e,i,s,a,n,o,l)=>{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!==l&&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,p.$O)(this.hass,e.statistic_id,e),s=e.statistic_id.includes(":")&&!e.statistic_id.includes(".")?"external":"no_state",a=`${H.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:V});else if("external"===s){const e=t.split(":")[0],n=(0,u.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:q})}}return}const s=e.statistic_id,a=(0,d.u)(i),[r,h,m]=(0,c.Cf)(i,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),v=r||h||s,g=[m,r?h:void 0].filter(Boolean).join(y?" ◂ ":" ▸ "),f=`${H.indexOf("entity")}`;_.push({id:s,statistic_id:s,primary:v,secondary:g,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)=>{var i;const s=null===(i=this.hass.userData)||void 0===i?void 0:i.showEntityIdPicker;return(0,a.qy)(I||(I=L` <ha-combo-box-item type="button" compact="compact" .borderTop="${0}"> ${0} <span slot="headline">${0} </span> ${0} ${0} </ha-combo-box-item> `),0!==e,t.icon_path?(0,a.qy)(k||(k=L` <ha-svg-icon style="margin:0 4px" slot="start" .path="${0}"></ha-svg-icon> `),t.icon_path):t.stateObj?(0,a.qy)(w||(w=L` <state-badge slot="start" .stateObj="${0}" .hass="${0}"></state-badge> `),t.stateObj,this.hass):a.s6,t.primary,t.secondary?(0,a.qy)(Z||(Z=L`<span slot="supporting-text">${0}</span>`),t.secondary):a.s6,t.statistic_id&&s?(0,a.qy)(j||(j=L`<span slot="supporting-text" class="code"> ${0} </span>`),t.statistic_id):a.s6)},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||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:(0,a.qy)(O||(O=L`<b>‘${0}’</b>`),t)})}}(0,s.Cg)([(0,n.MZ)({attribute:!1})],z.prototype,"hass",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean})],z.prototype,"autofocus",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean})],z.prototype,"disabled",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean})],z.prototype,"required",void 0),(0,s.Cg)([(0,n.MZ)()],z.prototype,"label",void 0),(0,s.Cg)([(0,n.MZ)()],z.prototype,"value",void 0),(0,s.Cg)([(0,n.MZ)()],z.prototype,"helper",void 0),(0,s.Cg)([(0,n.MZ)()],z.prototype,"placeholder",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"statistic-types"})],z.prototype,"statisticTypes",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean,attribute:"allow-custom-entity"})],z.prototype,"allowCustomEntity",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],z.prototype,"statisticIds",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],z.prototype,"helpMissingEntityUrl",void 0),(0,s.Cg)([(0,n.MZ)({type:Array,attribute:"include-statistics-unit-of-measurement"})],z.prototype,"includeStatisticsUnitOfMeasurement",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"include-unit-class"})],z.prototype,"includeUnitClass",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"include-device-class"})],z.prototype,"includeDeviceClass",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean,attribute:"entities-only"})],z.prototype,"entitiesOnly",void 0),(0,s.Cg)([(0,n.MZ)({type:Array,attribute:"exclude-statistics"})],z.prototype,"excludeStatistics",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"hide-clear-icon",type:Boolean})],z.prototype,"hideClearIcon",void 0),(0,s.Cg)([(0,n.P)("ha-generic-picker")],z.prototype,"_picker",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"can-edit",type:Boolean})],z.prototype,"canEdit",void 0),z=(0,s.Cg)([(0,n.EM)("ha-statistic-picker")],z),e()}catch(f){e(f)}})}}]);