iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.52 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[28696],{54706:function(t,s,e){e.d(s,{E:function(){return a}});e(74423),e(18111),e(13579),e(3362),e(62953);var i=e(40445),r=e(67576);const a=t=>{class s extends t{connectedCallback(){super.connectedCallback(),this._checkSubscribed()}disconnectedCallback(){if(super.disconnectedCallback(),this.__unsubs){for(;this.__unsubs.length;){const t=this.__unsubs.pop();t instanceof Promise?t.then(t=>t()):t()}this.__unsubs=void 0}}updated(t){if(super.updated(t),t.has("hass"))this._checkSubscribed();else if(this.hassSubscribeRequiredHostProps)for(const s of t.keys())if(this.hassSubscribeRequiredHostProps.includes(s))return void this._checkSubscribed()}hassSubscribe(){return[]}_checkSubscribed(){var t;void 0!==this.__unsubs||!this.isConnected||void 0===this.hass||null!==(t=this.hassSubscribeRequiredHostProps)&&void 0!==t&&t.some(t=>void 0===this[t])||(this.__unsubs=this.hassSubscribe())}}return(0,i.Cg)([(0,r.MZ)({attribute:!1})],s.prototype,"hass",void 0),s}},12150:function(t,s,e){e.a(t,async function(t,i){try{e.r(s),e.d(s,{HuiPowerTotalBadge:function(){return f}});e(18111),e(7588),e(17642),e(58004),e(33853),e(45876),e(32475),e(15024),e(31698),e(62953);var r=e(40445),a=e(5124),o=e(67576),n=e(20058),c=(e(24671),e(67094),e(38114)),h=e(54706),u=t([c,n]);[c,n]=u.then?(await u)():u;let d,l,_=t=>t;const b="M12 3L2 12H5V20H19V12H22L12 3M11.5 18V14H9L12.5 7V11H15L11.5 18Z";class f extends((0,h.E)(a.WF)){setConfig(t){this._config=t}hassSubscribe(){var t;return[(0,c.tb)(this.hass,{key:null===(t=this._config)||void 0===t?void 0:t.collection_key}).subscribe(t=>{this._data=t})]}shouldUpdate(t){if(t.has("_config")||t.has("_data"))return!0;if(t.has("hass")){const e=t.get("hass");if(!e||!this._entities.size)return!0;for(const t of this._entities){var s;if(e.states[t]!==(null===(s=this.hass)||void 0===s?void 0:s.states[t]))return!0}}return!1}_getCurrentPower(t){var s;return this._entities.add(t),null!==(s=(0,c.h4)(this.hass.states[t]))&&void 0!==s?s:0}_computeTotalPower(t){this._entities.clear();let s=0,e=0,i=0,r=0,a=0;t.energy_sources.forEach(t=>{if("solar"===t.type&&t.stat_rate){const e=this._getCurrentPower(t.stat_rate);e>0&&(s+=e)}else if("grid"===t.type&&t.stat_rate){const s=this._getCurrentPower(t.stat_rate);s>0?e+=s:s<0&&(i+=Math.abs(s))}else if("battery"===t.type&&t.stat_rate){const s=this._getCurrentPower(t.stat_rate);s>0?r+=s:s<0&&(a+=Math.abs(s))}});const o=e+s+r-i-a;return Math.max(0,o)}render(){if(!this._config||!this._data)return a.s6;const t=this._computeTotalPower(this._data.prefs);let s;s=t>=1e3?`${(0,n.ZV)(t/1e3,this.hass.locale,{maximumFractionDigits:2})} kW`:`${(0,n.ZV)(t,this.hass.locale,{maximumFractionDigits:0})} W`;const e=this._config.title||this.hass.localize("ui.panel.lovelace.cards.energy.power_total_title");return(0,a.qy)(d||(d=_` <ha-badge .label="${0}"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> ${0} </ha-badge> `),e,b,s)}constructor(...t){super(...t),this._entities=new Set,this.hassSubscribeRequiredHostProps=["_config"]}}f.styles=(0,a.AH)(l||(l=_`ha-badge{--badge-color:var(--primary-color)}`)),(0,r.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,r.Cg)([(0,o.wk)()],f.prototype,"_config",void 0),(0,r.Cg)([(0,o.wk)()],f.prototype,"_data",void 0),f=(0,r.Cg)([(0,o.EM)("hui-power-total-badge")],f),i()}catch(d){i(d)}})},56434:function(t,s,e){e.d(s,{e:function(){return r}});var i=e(81977);function r(t,s,e){return(0,i.P)(t,12*s,e)}}}]);