UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 8.88 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[43881],{90433:function(t,e,s){s.d(e,{Vy:function(){return n},fI:function(){return o},ux:function(){return c}});var r=s(22786),a=s(79468);const i=54;function n(t,e){const s=t%i+1;return e.getPropertyValue(`--color-${s}`)}function o(t,e){const s=e.getPropertyValue(`--graph-color-${t+1}`)||n(t,e);return(0,a.RQ)(s)}const c=(0,r.A)(t=>Array.from({length:i},(e,s)=>o(s,t)),(t,e)=>t[0].getPropertyValue("--graph-color-1")===e[0].getPropertyValue("--graph-color-1")&&t[0].getPropertyValue("--color-1")===e[0].getPropertyValue("--color-1"))},89938:function(t,e,s){function r(t,e){const s=e-t;return!Number.isFinite(s)||s<=0?1:Math.max(0,Math.ceil(-Math.log10(s/10)))}s.d(e,{G:function(){return r}})},54706:function(t,e,s){s.d(e,{E:function(){return i}});s(74423),s(18111),s(13579),s(3362),s(62953);var r=s(40445),a=s(67576);const i=t=>{class e 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 e of t.keys())if(this.hassSubscribeRequiredHostProps.includes(e))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,r.Cg)([(0,a.MZ)({attribute:!1})],e.prototype,"hass",void 0),e}},18427:function(t,e,s){s.d(e,{g:function(){return i}});s(42762);var r=s(79468),a=s(39274);function i(t,e,s,i,n,o){const c=t.getPropertyValue(n+"-"+o).trim(),h=c.length>0?c:t.getPropertyValue(n).trim();let u=(0,r.RQ)(h);return 0===c.length&&o&&(u=(0,r.v2)((0,r.BE)(e?(0,a.T)((0,r.Nc)((0,r.xp)(u)),o):(0,a.d)((0,r.Nc)((0,r.xp)(u)),o)))),i?u+=s?"32":"7F":s&&(u+="7F"),u}},40345:function(t,e,s){s.a(t,async function(t,e){try{var r=s(40445),a=s(5124),i=s(67576),n=s(34127),o=t([n]);n=(o.then?(await o)():o)[0];let c,h,u=t=>t;class d extends a.WF{render(){const t=`energy-graph-chip-${Date.now()}`;return(0,a.qy)(c||(c=u` <div class="chip" id="${0}"> <slot></slot> </div> <ha-tooltip for="${0}" placement="top">${0}</ha-tooltip> `),t,t,this.tooltip)}}d.styles=(0,a.AH)(h||(h=u`.chip{font-size:var(--ha-font-size-m);font-weight:var(--ha-font-weight-medium);padding:var(--ha-space-1) var(--ha-space-2);border-radius:var(--ha-border-radius-md);border:1px solid var(--divider-color)}`)),(0,r.Cg)([(0,i.MZ)({type:String})],d.prototype,"tooltip",void 0),d=(0,r.Cg)([(0,i.EM)("hui-energy-graph-chip")],d),e()}catch(c){e(c)}})},99389:function(t,e,s){s.a(t,async function(t,r){try{s.r(e),s.d(e,{HuiEnergyGasGraphCard:function(){return E}});s(44114),s(72712),s(18111),s(22489),s(7588),s(18237),s(3362),s(62953);var a=s(40445),i=s(73684),n=s(40600),o=s(81859),c=s(5124),h=s(67576),u=s(6412),d=s(22786),l=s(18427),p=s(20058),g=s(44439),_=s(89938),f=(s(76776),s(38114)),y=s(23528),v=s(54706),b=s(784),m=s(97372),C=s(40345),k=s(34127),S=t([g,C,k,f,y,p,m]);[g,C,k,f,y,p,m]=S.then?(await S)():S;let x,w,$,D,M,P=t=>t;class E extends((0,v.E)(c.WF)){static async getConfigElement(){return await s.e(79062).then(s.bind(s,54197)),document.createElement("hui-energy-graph-card-editor")}static getStubConfig(t,e,s){return{type:"energy-gas-graph"}}hassSubscribe(){var t;return[(0,f.tb)(this.hass,{key:null===(t=this._config)||void 0===t?void 0:t.collection_key}).subscribe(t=>this._getStatistics(t))]}getCardSize(){return 3}setConfig(t){t.collection_key&&(0,f.s8)(t.collection_key),this._config=t}shouldUpdate(t){return(0,b.xP)(this,t)||t.size>1||!t.has("hass")}render(){return this.hass&&this._config?(0,c.qy)(x||(x=P` <ha-card> ${0} <div class="content ${0}"> <ha-chart-base .hass="${0}" .data="${0}" .options="${0}" chart-type="bar"></ha-chart-base> ${0} </div> </ha-card> `),this._config.title?(0,c.qy)(w||(w=P` <div class="card-header"> <span>${0}</span> ${0} </div>`),this._config.title,this._total?(0,c.qy)($||($=P`<hui-energy-graph-chip .tooltip="${0}"> ${0} ${0} </hui-energy-graph-chip>`),this._formatTotal(this._total),(0,p.ZV)(this._total,this.hass.locale),this._unit):c.s6):c.s6,(0,u.H)({"has-header":!!this._config.title}),this.hass,this._chartData,this._createOptions(this._start,this._end,this.hass.locale,this.hass.config,this._unit,this._compareStart,this._compareEnd,this._yAxisFractionDigits),this._chartData.length?"":(0,c.qy)(D||(D=P`<div class="no-data"> ${0} </div>`),(0,i.c)(this._start)?this.hass.localize("ui.panel.lovelace.cards.energy.no_data"):this.hass.localize("ui.panel.lovelace.cards.energy.no_data_period"))):c.s6}async _getStatistics(t){this._start=t.start,this._end=t.end||(0,n.o)(),this._compareStart=t.startCompare,this._compareEnd=t.endCompare;const e=t.prefs.energy_sources.filter(t=>"gas"===t.type);this._unit=t.gasUnit;const s=[],r=getComputedStyle(this);let a=1/0,i=-1/0;const o=t=>{t<a&&(a=t),t>i&&(i=t)};if(t.statsCompare)s.push(...this._processDataSet(t.statsCompare,t.statsMetadata,e,r,o,!0));else{var c,h;const t=null!==(c=null===(h=e[0])||void 0===h?void 0:h.stat_energy_from)&&void 0!==c?c:"placeholder";s.push({id:"compare-"+t,type:"bar",stack:"gas",data:[]})}s.push(...this._processDataSet(t.stats,t.statsMetadata,e,r,o)),(0,m.RR)(s),this._yAxisFractionDigits=(0,_.G)(a,i),this._chartData=s,this._total=this._processTotal(t.stats,e)}_processTotal(t,e){return e.reduce((e,s)=>e+(s.stat_energy_from in t?t[s.stat_energy_from].reduce((t,e)=>t+(e.change||0),0):0),0)}_processDataSet(t,e,s,r,a,i=!1){const n=[],o=(0,m.ok)(this._start,this._compareStart),c=(0,f.TI)(this._start,this._end);return s.forEach((s,h)=>{let u=null;const d=[];if(s.stat_energy_from in t){const e=t[s.stat_energy_from];for(const t of e){if(null===t.change||void 0===t.change||0===t.change)continue;if(u===t.start)continue;const e=[(0,m.IJ)(t.start,t.end,c,i?o:void 0),t.change,t.start];d.push(e),a(t.change),u=t.start}}n.push({type:"bar",cursor:"default",id:i?"compare-"+s.stat_energy_from:s.stat_energy_from,name:s.name||(0,y.$O)(this.hass,s.stat_energy_from,e[s.stat_energy_from]),barMaxWidth:50,itemStyle:{borderColor:(0,l.g)(r,this.hass.themes.darkMode,!1,i,"--energy-gas-color",h)},color:(0,l.g)(r,this.hass.themes.darkMode,!0,i,"--energy-gas-color",h),data:d,stack:i?"compare-gas":"gas"})}),n}constructor(...t){super(...t),this._chartData=[],this._yAxisFractionDigits=1,this._start=(0,o.R)(),this._end=(0,n.o)(),this.hassSubscribeRequiredHostProps=["_config"],this._formatTotal=t=>this.hass.localize("ui.panel.lovelace.cards.energy.energy_gas_graph.total_consumed",{num:(0,p.ZV)(t,this.hass.locale),unit:this._unit}),this._createOptions=(0,d.A)((t,e,s,r,a,i,n,o)=>(0,m.od)(t,e,s,r,a,i,n,this._formatTotal,!1,o))}}E.styles=(0,c.AH)(M||(M=P`ha-card{height:100%}.card-header{display:flex;justify-content:space-between;align-items:center;padding-bottom:0}.content{padding:16px}.has-header{padding-top:0}.no-data{position:absolute;height:100%;top:0;left:0;right:0;display:flex;justify-content:center;align-items:center;padding:20%;margin-left:32px;margin-inline-start:32px;margin-inline-end:initial;box-sizing:border-box}`)),(0,a.Cg)([(0,h.MZ)({attribute:!1})],E.prototype,"hass",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_config",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_chartData",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_yAxisFractionDigits",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_start",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_end",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_compareStart",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_compareEnd",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_unit",void 0),(0,a.Cg)([(0,h.wk)()],E.prototype,"_total",void 0),E=(0,a.Cg)([(0,h.EM)("hui-energy-gas-graph-card")],E),r()}catch(x){r(x)}})},43382:function(t,e,s){s.d(e,{A:function(){return a}});var r=s(73420);function a(t){return(0,r.w)(t,Date.now())}},6116:function(t,e,s){s.d(e,{o:function(){return i}});var r=s(6439),a=s(83339);function i(t,e,s){const i=(0,a.b)(t,e)/6e4;return(0,r.u)(null==s?void 0:s.roundingMethod)(i)}},40600:function(t,e,s){s.d(e,{o:function(){return a}});var r=s(73983);function a(t){return(0,r.D)(Date.now(),t)}},83309:function(t,e,s){s.d(e,{r:function(){return i}});s(62953);var r=s(74816),a=s(35932);function i(t,e,s){const[i,n]=(0,r.x)(null==s?void 0:s.in,t,e);return+(0,a.o)(i)===+(0,a.o)(n)}},73684:function(t,e,s){s.d(e,{c:function(){return n}});var r=s(73420),a=s(43382),i=s(83309);function n(t,e){return(0,i.r)((0,r.w)((null==e?void 0:e.in)||t,t),(0,a.A)((null==e?void 0:e.in)||t))}},81859:function(t,e,s){s.d(e,{R:function(){return a}});var r=s(35932);function a(t){return(0,r.o)(Date.now(),t)}}}]);