iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 14.2 kB
JavaScript
export const __rspack_esm_id=11868;export const __rspack_esm_ids=[11868];export const __webpack_modules__={81816(t,e,i){i.d(e,{aH:()=>o,cx:()=>r,es:()=>l});var a=i(37981),s=i(28978),n=i(79461);const o=(t,e,i)=>{const a=e[t.entity_id];return a?r(a,i):(0,s.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,s.u)(i):void 0);const l=(0,a.xn)(r);return l!==o?l&&o&&(0,n.p)(o,l)||o:void 0},l=(t,e,i)=>!o(t,e,i)},74705(t,e,i){i.d(e,{Bj:()=>u,Cf:()=>p,uU:()=>c});i(18111),i(81148),i(22489),i(61701),i(13579);if(66649!=i.j)var a=i(44537);var s=i(15638),n=i(65522),o=i(37981),r=i(81816),l=i(55931);if(66649!=i.j)var d=i(28978);var h=i(28455);const c=(t,e,i,s,n,o,l)=>{if("string"==typeof e)return e;if(!e)return(0,d.u)(t);let h=(0,a.e)(e);const c=l?.separator??" ";if(h.every(t=>"text"===t.type))return h.map(t=>t.text).join(c);if((0,r.es)(t,i,s)){h.some(t=>"device"===t.type)||(h=h.map(t=>"entity"===t.type?{type:"device"}:t))}const u=p(t,h,i,s,n,o);return 1===u.length?u[0]||"":u.filter(t=>t).join(c)},p=(t,e,i,a,s,d)=>{const{device:c,area:p,floor:u}=(0,h.ln)(t,i,a,s,d);return e.map(e=>{switch(e.type){case"entity":return(0,r.aH)(t,i,a);case"device":return c?(0,o.xn)(c):void 0;case"area":return p?(0,n.A)(p):void 0;case"floor":return u?(0,l.X)(u):void 0;case"text":return e.text;default:return""}})},u=(t,e)=>{const[i,a,n]=p(e,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),o=(0,s.qC)(t.language,t.translationMetadata.translations);return{primary:i||a||e.entity_id,secondary:[n,i?a:void 0].filter(Boolean).join(o?" ◂ ":" ▸ ")||void 0}}},82474(t,e,i){i.a(t,async function(t,e){try{i(18111),i(20116),i(61701);var a=i(62826),s=i(5124),n=i(22441),o=i(22786),r=i(1087),l=i(74705),d=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)),_=t([y,g]);[y,g]=_.then?(await _)():_;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",f="___create-new-entity___";class b extends s.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?s.qy` <state-badge slot="start" .stateObj="${e}" .hass="${this.hass}"></state-badge> `:t.icon_path?s.qy` <ha-svg-icon slot="start" .path="${t.icon_path}" style="margin:0 4px"></ha-svg-icon> `:t.icon?s.qy`<ha-icon slot="start" .icon="${t.icon}"></ha-icon>`:s.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 s.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")}" -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(f)){const t=e.substring(f.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,d.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 s.qy` ${this._renderExtraOptionStart(i)} <span slot="headline">${i.primary}</span> ${i.secondary?s.qy`<span slot="supporting-text">${i.secondary}</span>`:s.s6} `;const a=this.hass.states[e];if(!a)return s.qy` <ha-svg-icon slot="start" .path="${v}" style="margin:0 4px"></ha-svg-icon> <span slot="headline">${e}</span> `;const{primary:n,secondary:o}=(0,l.Bj)(this.hass,a);return s.qy` <state-badge .hass="${this.hass}" .stateObj="${a}" slot="start"></state-badge> <span slot="headline">${n}</span> <span slot="supporting-text">${o}</span> `},this._rowRenderer=(t,e)=>{const i=this._showEntityId;return s.qy` <ha-combo-box-item type="button" compact="compact" .borderTop="${0!==e}"> ${t.icon_path?s.qy` <ha-svg-icon slot="start" style="margin:0 4px" .path="${t.icon_path}"></ha-svg-icon> `:s.qy` <state-badge slot="start" .stateObj="${t.stateObj}" .hass="${this.hass}"></state-badge> `} <span slot="headline">${t.primary}</span> ${t.secondary?s.qy`<span slot="supporting-text">${t.secondary}</span>`:s.s6} ${t.stateObj&&i?s.qy` <span slot="supporting-text" class="code"> ${t.stateObj.entity_id} </span> `:s.s6} ${t.domain_name&&!i?s.qy` <div slot="trailing-supporting-text" class="domain"> ${t.domain_name} </div> `:s.s6} </ha-combo-box-item> `},this._getAdditionalItems=()=>this._getCreateItems(this.hass.localize,this.createDomains),this._getCreateItems=(0,o.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:f+e,primary:i,secondary:t("ui.components.entity.entity-picker.new_entity"),icon_path:m}})):[]),this._getEntitiesMemoized=(0,o.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[a]=e.splice(i,1);return e.unshift(a),e},this._notFoundLabel=t=>this.hass.localize("ui.components.entity.entity-picker.no_match",{term:s.qy`<b>‘${t}’</b>`})}}(0,a.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],b.prototype,"autofocus",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],b.prototype,"disabled",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],b.prototype,"required",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean,attribute:"allow-custom-entity"})],b.prototype,"allowCustomEntity",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean,attribute:"show-entity-id"})],b.prototype,"showEntityId",void 0),(0,a.Cg)([(0,n.MZ)()],b.prototype,"label",void 0),(0,a.Cg)([(0,n.MZ)()],b.prototype,"value",void 0),(0,a.Cg)([(0,n.MZ)()],b.prototype,"helper",void 0),(0,a.Cg)([(0,n.MZ)()],b.prototype,"placeholder",void 0),(0,a.Cg)([(0,n.MZ)({type:String,attribute:"search-label"})],b.prototype,"searchLabel",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"createDomains",void 0),(0,a.Cg)([(0,n.MZ)({type:Array,attribute:"include-domains"})],b.prototype,"includeDomains",void 0),(0,a.Cg)([(0,n.MZ)({type:Array,attribute:"exclude-domains"})],b.prototype,"excludeDomains",void 0),(0,a.Cg)([(0,n.MZ)({type:Array,attribute:"include-device-classes"})],b.prototype,"includeDeviceClasses",void 0),(0,a.Cg)([(0,n.MZ)({type:Array,attribute:"include-unit-of-measurement"})],b.prototype,"includeUnitOfMeasurement",void 0),(0,a.Cg)([(0,n.MZ)({type:Array,attribute:"include-entities"})],b.prototype,"includeEntities",void 0),(0,a.Cg)([(0,n.MZ)({type:Array,attribute:"exclude-entities"})],b.prototype,"excludeEntities",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"entityFilter",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],b.prototype,"extraOptions",void 0),(0,a.Cg)([(0,n.MZ)({attribute:"hide-clear-icon",type:Boolean})],b.prototype,"hideClearIcon",void 0),(0,a.Cg)([(0,n.MZ)({attribute:"add-button",type:Boolean})],b.prototype,"addButton",void 0),(0,a.Cg)([(0,n.MZ)({attribute:"add-button-label"})],b.prototype,"addButtonLabel",void 0),(0,a.Cg)([(0,n.P)("ha-generic-picker")],b.prototype,"_picker",void 0),(0,a.Cg)([(0,n.wk)()],b.prototype,"_pendingEntityId",void 0),b=(0,a.Cg)([(0,n.EM)("ha-entity-picker")],b),e()}catch(t){e(t)}})},53756(t,e,i){i.d(e,{t:()=>l,w:()=>d});i(74423),i(18111),i(22489),i(61701);var a=i(71727),s=i(74705),n=i(28978),o=i(15638),r=i(95350);const l=[{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}],d=(t,e,i,l,d,h,c,p,u,y="")=>{let g,_=Object.keys(t.states);return c&&(_=_.filter(t=>c.includes(t))),p&&(_=_.filter(t=>!p.includes(t))),e&&(_=_.filter(t=>e.includes((0,a.m)(t)))),i&&(_=_.filter(t=>!i.includes((0,a.m)(t)))),g=_.map(e=>{const i=t.states[e],l=(0,n.u)(i),[d,h,c]=(0,s.Cf)(i,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),p=(0,r.p$)(t.localize,(0,a.m)(e)),u=(0,o.qC)(t.language,t.translationMetadata.translations),g=d||h||e,_=[c,d?h:void 0].filter(Boolean).join(u?" ◂ ":" ▸ ");return{id:`${y}${e}`,primary:g,secondary:_,domain_name:p,sorting_label:[g,_].filter(Boolean).join("_"),search_labels:{entityName:d||null,deviceName:h||null,areaName:c||null,domainName:p||null,friendlyName:l||null,entityId:e},stateObj:i}}),d&&(g=g.filter(t=>t.id===u||t.stateObj?.attributes.device_class&&d.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))),l&&(g=g.filter(t=>t.id===u||t.stateObj&&l(t.stateObj))),g}},19711(t,e,i){i.d(e,{$:()=>n});var a=i(1087);const s=()=>Promise.all([i.e(80131),i.e(70183),i.e(47677)]).then(i.bind(i,79029)),n=(t,e)=>{(0,a.r)(t,"show-dialog",{dialogTag:"dialog-helper-detail",dialogImport:s,dialogParams:e})}},87031(t,e,i){i.a(t,async function(t,a){try{i.r(e),i.d(e,{HuiGraphFooterEditor:()=>_});var s=i(62826),n=i(5124),o=i(22441),r=i(63533),l=i(1087),d=i(82474),h=(i(6),i(59646)),c=i(91485),p=i(30345),u=i(7382),y=t([d,h,c]);[d,h,c]=y.then?(await y)():y;const g=["sensor"];class _ extends n.WF{setConfig(t){(0,r.vA)(t,p.oe),this._config=t}get _entity(){return this._config.entity||""}get _detail(){return this._config.detail??1}get _hours_to_show(){return this._config.hours_to_show||24}render(){return this.hass&&this._config?n.qy` <div class="card-config"> <ha-entity-picker .label="${this.hass.localize("ui.panel.lovelace.editor.card.generic.entity")}" .hass="${this.hass}" .value="${this._entity}" .configValue="${"entity"}" .includeDomains="${g}" .required="${!0}" -changed="${this._valueChanged}"></ha-entity-picker> <div class="side-by-side"> <ha-formfield label="${this.hass.localize("ui.panel.lovelace.editor.card.sensor.show_more_detail")}"> <ha-switch .checked="${2===this._detail}" .configValue="${"detail"}" ="${this._change}"></ha-switch> </ha-formfield> <ha-input type="number" .label="${this.hass.localize("ui.panel.lovelace.editor.card.generic.hours_to_show")} (${this.hass.localize("ui.panel.lovelace.editor.card.config.optional")})" .value="${String(this._hours_to_show)}" min="1" .configValue="${"hours_to_show"}" ="${this._valueChanged}"></ha-input> </div> </div> `:n.s6}_change(t){if(!this._config||!this.hass)return;const e=t.target.checked?2:1;this._detail!==e&&(this._config={...this._config,detail:e},(0,l.r)(this,"config-changed",{config:this._config}))}_valueChanged(t){if(!this._config||!this.hass)return;const e=t.target;if(this[`_${e.configValue}`]!==e.value){if(e.configValue)if(""===e.value||"number"===e.type&&isNaN(Number(e.value)))this._config={...this._config},delete this._config[e.configValue];else{let t=e.value;"number"===e.type&&(t=Number(t)),this._config={...this._config,[e.configValue]:t}}(0,l.r)(this,"config-changed",{config:this._config})}}static get styles(){return[u.U,n.AH`.card-config ha-switch{margin:1px 0}`]}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,s.Cg)([(0,o.wk)()],_.prototype,"_config",void 0),_=(0,s.Cg)([(0,o.EM)("hui-graph-footer-editor")],_),a()}catch(t){a(t)}})},55904(t,e,i){i.d(e,{J:()=>n});var a=i(63533),s=i(91408);const n=(0,a.Ik)({entity:(0,a.Yj)(),name:(0,a.lq)((0,a.Yj)()),icon:(0,a.lq)((0,a.Yj)()),image:(0,a.lq)((0,a.Yj)()),show_name:(0,a.lq)((0,a.zM)()),show_icon:(0,a.lq)((0,a.zM)()),tap_action:(0,a.lq)(s.kn),hold_action:(0,a.lq)(s.kn),double_tap_action:(0,a.lq)(s.kn)})},30345(t,e,i){i.d(e,{oe:()=>l,zb:()=>d});var a=i(63533),s=i(91408),n=i(55904);const o=(0,a.Ik)({type:(0,a.Yj)(),image:(0,a.Yj)(),tap_action:(0,a.lq)(s.kn),hold_action:(0,a.lq)(s.kn),double_tap_action:(0,a.lq)(s.kn),alt_text:(0,a.lq)((0,a.Yj)())}),r=(0,a.Ik)({type:(0,a.Yj)(),entities:(0,a.YO)(n.J)}),l=(0,a.Ik)({type:(0,a.Yj)(),entity:(0,a.Yj)(),detail:(0,a.lq)((0,a.ai)()),hours_to_show:(0,a.lq)((0,a.ai)())}),d=(0,a.OR)(t=>{if(t&&"object"==typeof t&&"type"in t)switch(t.type){case"buttons":return r;case"graph":return l;case"picture":return o}return(0,a.KC)([r,l,o])})}};