iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 4.57 kB
JavaScript
export const __rspack_esm_id=73618;export const __rspack_esm_ids=[73618];export const __webpack_modules__={54706(e,s,t){t.d(s,{E:()=>a});t(74423),t(18111),t(13579);var i=t(62826),r=t(22441);const a=e=>{class s extends e{connectedCallback(){super.connectedCallback(),this._checkSubscribed()}disconnectedCallback(){if(super.disconnectedCallback(),this.__unsubs){for(;this.__unsubs.length;){const e=this.__unsubs.pop();e instanceof Promise?e.then(e=>e()):e()}this.__unsubs=void 0}}updated(e){if(super.updated(e),e.has("hass"))this._checkSubscribed();else if(this.hassSubscribeRequiredHostProps)for(const s of e.keys())if(this.hassSubscribeRequiredHostProps.includes(s))return void this._checkSubscribed()}hassSubscribe(){return[]}_checkSubscribed(){void 0===this.__unsubs&&this.isConnected&&void 0!==this.hass&&!this.hassSubscribeRequiredHostProps?.some(e=>void 0===this[e])&&(this.__unsubs=this.hassSubscribe())}}return(0,i.Cg)([(0,r.MZ)({attribute:!1})],s.prototype,"hass",void 0),s}},62284(e,s,t){t.a(e,async function(e,i){try{t.r(s),t.d(s,{HuiEnergyCompareCard:()=>g});var r=t(62826),a=t(6946),o=t(73983),h=t(5124),c=t(22441),n=t(72487),d=t(38114),p=t(54706),l=t(784),_=t(38962),u=t(1087),b=t(14503),y=e([_,n,d]);[_,n,d]=y.then?(await y)():y;class g extends((0,p.E)(h.WF)){static async getConfigElement(){return await t.e(79062).then(t.bind(t,54197)),document.createElement("hui-energy-graph-card-editor")}static getStubConfig(e,s,t){return{type:"energy-compare"}}getCardSize(){return 1}setConfig(e){e.collection_key&&(0,d.s8)(e.collection_key),this._config=e}hassSubscribe(){return[(0,d.tb)(this.hass,{key:this._config.collection_key}).subscribe(e=>this._update(e))]}shouldUpdate(e){return(0,l.xP)(this,e)||e.has("preview")||e.size>1||!e.has("hass")}update(e){super.update(e),e.has("preview")&&this._checkVisibility()}render(){if(this.preview)return h.qy` <ha-alert> ${this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.info",{start:h.qy`<b>${(0,n.Yq)(new Date,this.hass.locale,this.hass.config)}</b>`,end:h.qy`<b>${(0,n.Yq)(new Date,this.hass.locale,this.hass.config)}</b> <span>(${this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_preview")})</span>`})} </ha-alert> `;if(!this._startCompare||!this._endCompare)return h.s6;const e=(0,a.c)(this._endCompare,this._startCompare);return h.qy` <ha-alert dismissable -dismissed-clicked="${this._stopCompare}"> ${this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.info",{start:h.qy`<b>${(0,n.Yq)(this._start,this.hass.locale,this.hass.config)}${e>0?` -\n ${(0,n.Yq)(this._end||(0,o.D)(new Date),this.hass.locale,this.hass.config)}`:""}</b>`,end:h.qy`<b>${(0,n.Yq)(this._startCompare,this.hass.locale,this.hass.config)}${e>0?` -\n ${(0,n.Yq)(this._endCompare,this.hass.locale,this.hass.config)}`:""}</b> <button class="link" ="${this._changeCompareMode}"> (${this._compareMode===d.lh.PREVIOUS?this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_previous_year"):this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_previous_period")}) </button>`})} </ha-alert> `}_changeCompareMode(){const e=(0,d.tb)(this.hass,{key:this._config.collection_key});e.setCompare(this._compareMode===d.lh.PREVIOUS?d.lh.YOY:d.lh.PREVIOUS),e.refresh()}_update(e){this._start=e.start,this._end=e.end,this._startCompare=e.startCompare,this._endCompare=e.endCompare,this._compareMode=e.compareMode,this._checkVisibility()}_checkVisibility(){const e=this.hidden;this.hidden=!this._startCompare&&!this.preview,e!==this.hidden&&(0,u.r)(this,"card-visibility-changed")}_stopCompare(){const e=(0,d.tb)(this.hass,{key:this._config.collection_key});e.setCompare(d.lh.NONE),e.refresh()}constructor(...e){super(...e),this.hidden=!0,this.preview=!1,this.connectedWhileHidden=!0,this.hassSubscribeRequiredHostProps=["_config"]}}g.styles=[b.og],(0,r.Cg)([(0,c.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,r.Cg)([(0,c.wk)()],g.prototype,"_config",void 0),(0,r.Cg)([(0,c.wk)()],g.prototype,"_start",void 0),(0,r.Cg)([(0,c.wk)()],g.prototype,"_end",void 0),(0,r.Cg)([(0,c.wk)()],g.prototype,"_startCompare",void 0),(0,r.Cg)([(0,c.wk)()],g.prototype,"_endCompare",void 0),(0,r.Cg)([(0,c.wk)()],g.prototype,"_compareMode",void 0),(0,r.Cg)([(0,c.MZ)({type:Boolean,reflect:!0})],g.prototype,"hidden",void 0),(0,r.Cg)([(0,c.MZ)({attribute:!1})],g.prototype,"preview",void 0),g=(0,r.Cg)([(0,c.EM)("hui-energy-compare-card")],g),i()}catch(e){i(e)}})},56434(e,s,t){t.d(s,{e:()=>r});var i=t(81977);function r(e,s,t){return(0,i.P)(e,12*s,t)}}};