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