iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 9.42 kB
JavaScript
export const __rspack_esm_id=59671;export const __rspack_esm_ids=[59671];export const __webpack_modules__={81816(t,e,i){i.d(e,{aH:()=>n,cx:()=>r,es:()=>d});var s=i(37981),a=i(28978),o=i(79461);const n=(t,e,i)=>{const s=e[t.entity_id];return s?r(s,i):(0,a.u)(t)},r=(t,e,i)=>{const n=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 n||(i?(0,a.u)(i):void 0);const d=(0,s.xn)(r);return d!==n?d&&n&&(0,o.p)(n,d)||n:void 0},d=(t,e,i)=>!n(t,e,i)},74705(t,e,i){i.d(e,{Bj:()=>y,Cf:()=>p,uU:()=>c});i(18111),i(81148),i(22489),i(61701),i(13579);if(66649!=i.j)var s=i(44537);var a=i(15638),o=i(65522),n=i(37981),r=i(81816),d=i(55931);if(66649!=i.j)var h=i(28978);var l=i(28455);const c=(t,e,i,a,o,n,d)=>{if("string"==typeof e)return e;if(!e)return(0,h.u)(t);let l=(0,s.e)(e);const c=d?.separator??" ";if(l.every(t=>"text"===t.type))return l.map(t=>t.text).join(c);if((0,r.es)(t,i,a)){l.some(t=>"device"===t.type)||(l=l.map(t=>"entity"===t.type?{type:"device"}:t))}const y=p(t,l,i,a,o,n);return 1===y.length?y[0]||"":y.filter(t=>t).join(c)},p=(t,e,i,s,a,h)=>{const{device:c,area:p,floor:y}=(0,l.ln)(t,i,s,a,h);return e.map(e=>{switch(e.type){case"entity":return(0,r.aH)(t,i,s);case"device":return c?(0,n.xn)(c):void 0;case"area":return p?(0,o.A)(p):void 0;case"floor":return y?(0,d.X)(y):void 0;case"text":return e.text;default:return""}})},y=(t,e)=>{const[i,s,o]=p(e,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),n=(0,a.qC)(t.language,t.translationMetadata.translations);return{primary:i||s||e.entity_id,secondary:[o,i?s:void 0].filter(Boolean).join(n?" ◂ ":" ▸ ")||void 0}}},93725(t,e,i){i.a(t,async function(t,s){try{i.r(e);i(74423),i(44114),i(18111),i(22489),i(61701);var a=i(62826),o=i(5124),n=i(22441),r=i(1087),d=i(71727),h=i(82286),l=i(47351),c=i(53072),p=i(14503),y=i(38962),g=i(18350),_=(i(93444),i(76538),i(72554)),u=i(36192),m=t([y,g,_,u]);[y,g,_,u]=m.then?(await m)():m;const v="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z";class C extends o.WF{showDialog(t){this._entityId=t.entityId,this._open=!0;const e=this.hass.states[t.entityId];this._groupMembers=e?.attributes.group_members?.filter(e=>e!==t.entityId)||[],this._selectedEntities=this._groupMembers}closeDialog(){this._open=!1}_dialogClosed(){this._open=!1,this._entityId=void 0,this._selectedEntities=[],this._groupMembers=[],this._submitting=!1,this._error=void 0,(0,r.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._entityId)return o.s6;const t=this._entityId;return o.qy` <ha-dialog .open="${this._open}" flexcontent ="${this._dialogClosed}"> <ha-dialog-header show-border slot="header"> <ha-icon-button .label="${this.hass.localize("ui.common.close")}" .path="${v}" data-dialog="close" slot="navigationIcon"></ha-icon-button> <span slot="title">${this.hass.localize("ui.card.media_player.media_players")}</span> <ha-button appearance="plain" slot="actionItems" ="${this._selectAll}"> ${this.hass.localize("ui.card.media_player.select_all")} </ha-button> </ha-dialog-header> ${this._error?o.qy`<ha-alert alert-type="error">${this._error}</ha-alert>`:o.s6} <div class="content"> <ha-media-player-toggle .hass="${this.hass}" .entityId="${t}" checked="checked" disabled="disabled"></ha-media-player-toggle> ${this._mediaPlayerEntities(this.hass.entities).map(t=>o.qy`<ha-media-player-toggle .hass="${this.hass}" .entityId="${t.entity_id}" .checked="${this._selectedEntities.includes(t.entity_id)}" ="${this._handleSelectedChange}"></ha-media-player-toggle>`)} </div> <ha-dialog-footer slot="footer"> <ha-button appearance="plain" slot="secondaryAction" ="${this.closeDialog}"> ${this.hass.localize("ui.common.cancel")} </ha-button> <ha-button .disabled="${!!this._submitting}" slot="primaryAction" ="${this._submit}"> ${this.hass.localize("ui.common.apply")} </ha-button> </ha-dialog-footer> </ha-dialog> `}_selectAll(){this._selectedEntities=this._mediaPlayerEntities(this.hass.entities).map(t=>t.entity_id)}_handleSelectedChange(t){const e=this._selectedEntities.filter(e=>e!==t.target.entityId);t.target.checked&&e.push(t.target.entityId),this._selectedEntities=e}async _submit(){if(this._entityId){this._error=void 0,this._submitting=!0;try{await(0,c.Im)(this.hass,this._entityId,this._selectedEntities),await Promise.all(this._groupMembers.filter(t=>!this._selectedEntities.includes(t)).map(t=>(0,c.fh)(this.hass,t))),this.closeDialog()}catch(t){this._error=(0,l.VR)(t)}this._submitting=!1}}static get styles(){return[p.nA,o.AH`.content{display:flex;flex-direction:column;padding-top:var(--ha-space-6);row-gap:var(--ha-space-4)}ha-dialog-header ha-button{margin:6px;display:block}`]}constructor(...t){super(...t),this._open=!1,this._mediaPlayerEntities=t=>{if(!this._entityId)return[];const e=this.hass.entities[this._entityId]?.platform;return e?Object.values(t).filter(t=>t.entity_id!==this._entityId&&("media_player"===(0,d.m)(t.entity_id)&&(this.hass.entities[t.entity_id]?.platform===e&&!(!this.hass.states[t.entity_id]||!(0,h.$)(this.hass.states[t.entity_id],c.vj.GROUPING))))):[]}}}(0,a.Cg)([(0,n.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,a.Cg)([(0,n.wk)()],C.prototype,"_entityId",void 0),(0,a.Cg)([(0,n.wk)()],C.prototype,"_groupMembers",void 0),(0,a.Cg)([(0,n.wk)()],C.prototype,"_selectedEntities",void 0),(0,a.Cg)([(0,n.wk)()],C.prototype,"_submitting",void 0),(0,a.Cg)([(0,n.wk)()],C.prototype,"_error",void 0),(0,a.Cg)([(0,n.wk)()],C.prototype,"_open",void 0),C=(0,a.Cg)([(0,n.EM)("dialog-join-media-players")],C),s()}catch(t){s(t)}})},36192(t,e,i){i.a(t,async function(t,e){try{var s=i(62826),a=i(5124),o=i(22441),n=i(22786),r=i(74705),d=i(15638),h=i(1087),l=i(59646),c=(i(67094),t([l]));l=(c.then?(await c)():c)[0];const p="M12,12A3,3 0 0,0 9,15A3,3 0 0,0 12,18A3,3 0 0,0 15,15A3,3 0 0,0 12,12M12,20A5,5 0 0,1 7,15A5,5 0 0,1 12,10A5,5 0 0,1 17,15A5,5 0 0,1 12,20M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8C10.89,8 10,7.1 10,6C10,4.89 10.89,4 12,4M17,2H7C5.89,2 5,2.89 5,4V20A2,2 0 0,0 7,22H17A2,2 0 0,0 19,20V4C19,2.89 18.1,2 17,2Z",y="M12.28 19.81C11.87 19.92 11.45 20 11 20C8.24 20 6 17.76 6 15S8.24 10 11 10C12.89 10 14.5 11.06 15.37 12.61C16.16 12.23 17.06 12 18 12V4C18 2.89 17.1 2 16 2H6C4.89 2 4 2.89 4 4V20C4 21.11 4.89 22 6 22H13.54C13 21.37 12.54 20.63 12.28 19.81M11 4C12.11 4 13 4.89 13 6S12.11 8 11 8C9.89 8 9 7.1 9 6C9 4.89 9.89 4 11 4M13.74 13.78C12.7 14.82 12.06 16.24 12 17.81C11.69 17.93 11.36 18 11 18C9.34 18 8 16.66 8 15S9.34 12 11 12C12.22 12 13.27 12.73 13.74 13.78M19 15H21V21H19M15 15H17V21H15V15Z",g="M16 15V21L21 18L16 15M12.28 19.81C11.87 19.92 11.45 20 11 20C8.24 20 6 17.76 6 15S8.24 10 11 10C12.89 10 14.5 11.06 15.37 12.61C16.16 12.23 17.06 12 18 12V4C18 2.89 17.1 2 16 2H6C4.89 2 4 2.89 4 4V20C4 21.11 4.89 22 6 22H13.54C13 21.37 12.54 20.63 12.28 19.81M11 4C12.11 4 13 4.89 13 6S12.11 8 11 8C9.89 8 9 7.1 9 6C9 4.89 9.89 4 11 4M13.74 13.78C12.7 14.82 12.06 16.24 12 17.81C11.69 17.93 11.36 18 11 18C9.34 18 8 16.66 8 15S9.34 12 11 12C12.22 12 13.27 12.73 13.74 13.78Z";class _ extends a.WF{render(){const t=this.hass.states[this.entityId];let e=p;"playing"===t.state?e=g:"paused"===t.state&&(e=y);const i=(0,d.qC)(this.hass.language,this.hass.translationMetadata.translations),{primary:s,secondary:o}=this._computeDisplayData(this.entityId,this.hass.entities,this.hass.devices,this.hass.areas,this.hass.floors,i,t);return a.qy`<div class="list-item"> <ha-svg-icon .path="${e}"></ha-svg-icon> <div class="info"> <div class="main-text">${s}</div> <div class="secondary-text">${o}</div> </div> <ha-switch .disabled="${this.disabled}" .checked="${this.checked}" ="${this._handleChange}"></ha-switch> </div>`}static get styles(){return[a.AH`.list-item{display:grid;grid-template-columns:auto 1fr auto;column-gap:var(--ha-space-4);align-items:center;width:100%}.info{min-width:0}.main-text{color:var(--primary-text-color)}.main-text[take-height]{line-height:40px}.secondary-text{color:var(--secondary-text-color);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}`]}_handleChange(t){t.stopPropagation(),this.checked=t.target.checked,(0,h.r)(this,"change")}constructor(...t){super(...t),this.checked=!1,this.disabled=!1,this._computeDisplayData=(0,n.A)((t,e,i,s,a,o,n)=>{const[d,h,l]=(0,r.Cf)(n,[{type:"entity"},{type:"device"},{type:"area"}],e,i,s,a);return{primary:d||h||t,secondary:[l,d?h:void 0].filter(Boolean).join(o?" ◂ ":" ▸ ")}})}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],_.prototype,"entityId",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],_.prototype,"checked",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],_.prototype,"disabled",void 0),_=(0,s.Cg)([(0,o.EM)("ha-media-player-toggle")],_),e()}catch(t){e(t)}})},47351(t,e,i){i.d(e,{PS:()=>s,Tv:()=>n,VR:()=>a,lE:()=>r});i(74423),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);const s=t=>t.data,a=t=>"object"==typeof t?"object"==typeof t.body?t.body.message||"Unknown error, see supervisor logs":t.body||t.message||"Unknown error, see supervisor logs":t,o=new Set([502,503,504]),n=t=>!!(t&&t.status_code&&o.has(t.status_code))||!(!t||!t.message||!t.message.includes("ERR_CONNECTION_CLOSED")&&!t.message.includes("ERR_CONNECTION_RESET")),r=async(t,e)=>t({type:"supervisor/api",endpoint:`/${e}/stats`,method:"get"})}};