iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 17.9 kB
JavaScript
export const __webpack_ids__=["45097"];export const __webpack_modules__={85366:function(e,t,s){var i=s(44249),a=s(82238),n=s(66575),o=s(57243),r=s(15093);(0,i.Z)([(0,r.Mo)("ha-top-app-bar-fixed")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",static:!0,key:"styles",value:()=>[n.W,o.iv`.mdc-top-app-bar__row{height:var(--header-height);border-bottom:var(--app-header-border-bottom)}.mdc-top-app-bar--fixed-adjust{padding-top:var(--header-height)}.mdc-top-app-bar{--mdc-typography-headline6-font-weight:400;color:var(--app-header-text-color,var(--mdc-theme-on-primary,#fff));background-color:var(--app-header-background-color,var(--mdc-theme-primary))}.mdc-top-app-bar__title{font-size:20px;padding-inline-start:24px;padding-inline-end:initial}`]}]}}),a.s)},6736:function(e,t,s){s.d(t,{f:()=>o});var i=s(44249),a=s(72621),n=(s(9359),s(52924),s(15093));const o=e=>(0,i.Z)(null,(function(e,t){class s extends t{constructor(...t){super(...t),e(this)}}return{F:s,d:[{kind:"field",decorators:[(0,n.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",key:"hassSubscribeRequiredHostProps",value:void 0},{kind:"field",key:"__unsubs",value:void 0},{kind:"method",key:"connectedCallback",value:function(){(0,a.Z)(s,"connectedCallback",this,3)([]),this._checkSubscribed()}},{kind:"method",key:"disconnectedCallback",value:function(){if((0,a.Z)(s,"disconnectedCallback",this,3)([]),this.__unsubs){for(;this.__unsubs.length;){const e=this.__unsubs.pop();e instanceof Promise?e.then((e=>e())):e()}this.__unsubs=void 0}}},{kind:"method",key:"updated",value:function(e){if((0,a.Z)(s,"updated",this,3)([e]),e.has("hass"))this._checkSubscribed();else if(this.hassSubscribeRequiredHostProps)for(const t of e.keys())if(this.hassSubscribeRequiredHostProps.includes(t))return void this._checkSubscribed()}},{kind:"method",key:"hassSubscribe",value:function(){return[]}},{kind:"method",key:"_checkSubscribed",value:function(){void 0===this.__unsubs&&this.isConnected&&void 0!==this.hass&&!this.hassSubscribeRequiredHostProps?.some((e=>void 0===this[e]))&&(this.__unsubs=this.hassSubscribe())}}]}}),e)},55742:function(e,t,s){s.a(e,(async function(e,i){try{s.r(t);var a=s(44249),n=(s(92745),s(9359),s(56475),s(31526),s(70104),s(92519),s(42179),s(89256),s(24931),s(88463),s(57449),s(19814),s(75656),s(50100),s(18084),s(57243)),o=s(15093),r=(s(43344),s(7285),s(85366),s(28008)),h=s(3983),c=s(3166),d=(s(33679),s(83523)),l=s(1118),u=s(58014),p=e([h,c,l]);[h,c,l]=p.then?(await p)():p;const f="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",_="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",g={views:[{strategy:{type:"energy"}}]};(0,a.Z)([(0,o.Mo)("ha-panel-energy")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.Cb)({type:Boolean,reflect:!0})],key:"narrow",value:()=>!1},{kind:"field",decorators:[(0,o.SB)()],key:"_viewIndex",value:()=>0},{kind:"field",decorators:[(0,o.SB)()],key:"_lovelace",value:void 0},{kind:"method",key:"willUpdate",value:function(e){if(this.hasUpdated||this.hass.loadFragmentTranslation("lovelace"),!e.has("hass"))return;const t=e.get("hass");t?.locale!==this.hass.locale&&this._setLovelace(),t&&t.localize!==this.hass.localize&&this._reloadView()}},{kind:"method",key:"render",value:function(){return n.dy` <div class="header"> <div class="toolbar"> <ha-menu-button slot="navigationIcon" .hass="${this.hass}" .narrow="${this.narrow}"></ha-menu-button> ${this.narrow?n.Ld:n.dy`<div class="main-title"> ${this.hass.localize("panel.energy")} </div>`} <hui-energy-period-selector .hass="${this.hass}" collection-key="energy_dashboard"> ${this.hass.user?.is_admin?n.dy` <ha-list-item slot="overflow-menu" graphic="icon" -selected="${this._navigateConfig}"> <ha-svg-icon slot="graphic" .path="${f}"> </ha-svg-icon> ${this.hass.localize("ui.panel.energy.configure")} </ha-list-item>`:n.Ld} <ha-list-item slot="overflow-menu" graphic="icon" -selected="${this._dumpCSV}"> <ha-svg-icon slot="graphic" .path="${_}"> </ha-svg-icon> ${this.hass.localize("ui.panel.energy.download_data")} </ha-list-item> </hui-energy-period-selector> </div> </div> <hui-view-container .hass="${this.hass}" -energy-panel="${this._reloadView}"> <hui-view .hass="${this.hass}" .narrow="${this.narrow}" .lovelace="${this._lovelace}" .index="${this._viewIndex}"></hui-view> </hui-view-container> `}},{kind:"method",key:"_setLovelace",value:function(){this._lovelace={config:g,rawConfig:g,editMode:!1,urlPath:"energy",mode:"generated",locale:this.hass.locale,enableFullEditMode:()=>{},saveConfig:async()=>{},deleteConfig:async()=>{},setEditMode:()=>{},showToast:()=>{}}}},{kind:"method",key:"_navigateConfig",value:function(e){e.stopPropagation(),(0,d.c)("/config/energy?historyBack=1")}},{kind:"method",key:"_dumpCSV",value:async function(e){e.stopPropagation();const t=(0,l.UB)(this.hass,{key:"energy_dashboard"});if(!t.prefs||!t.state.stats)return;const s=(0,l.vE)(this.hass,t.prefs,t.state.statsMetadata),i=(0,l.b)(this.hass),a="kWh",n=t.prefs.energy_sources,o=t.prefs.device_consumption,r=t.state.stats,h=new Set;Object.values(r).forEach((e=>{e.forEach((e=>{h.add(e.start)}))}));const c=Array.from(h).sort(),d="entity_id,type,unit,"+c.map((e=>new Date(e).toISOString())).join(",")+"\n",p=[];p[0]=d;const f=function(e,t,s){let i=0;const a=[];r[e]&&(a.push(e),a.push(t),a.push(s.normalize("NFKD")),c.forEach((t=>{i<r[e].length&&r[e][i].start===t?(a.push((r[e][i].change??"").toString()),i++):a.push("")})),p.push(a.join(",")+"\n"))},_=this.hass.config.currency,g=function(e,t,s,i,a){t.length&&(t.forEach((t=>f(t,e,s))),i&&a&&a.forEach((e=>f(e,i,_))))},v=[],m=[],k=[],y=[];n.filter((e=>"grid"===e.type)).forEach((e=>{e.flow_from.forEach((e=>{const s=e.stat_energy_from;v.push(s);const i=e.stat_cost||t.state.info.cost_sensors[s];i&&k.push(i)})),e.flow_to.forEach((e=>{const s=e.stat_energy_to;m.push(s);const i=e.stat_compensation||t.state.info.cost_sensors[s];i&&y.push(i)}))})),g("grid_consumption",v,a,"grid_consumption_cost",k),g("grid_return",m,a,"grid_return_compensation",y);const b=[],w=[];n.filter((e=>"battery"===e.type)).forEach((e=>{b.push(e.stat_energy_to),w.push(e.stat_energy_from)})),g("battery_in",b,a),g("battery_out",w,a);const x=[];n.filter((e=>"solar"===e.type)).forEach((e=>{x.push(e.stat_energy_from)})),g("solar_production",x,a);const D=[],C=[];n.filter((e=>"gas"===e.type)).forEach((e=>{const s=e.stat_energy_from;D.push(s);const i=e.stat_cost||t.state.info.cost_sensors[s];i&&C.push(i)})),g("gas_consumption",D,s,"gas_consumption_cost",C);const $=[],S=[];n.filter((e=>"water"===e.type)).forEach((e=>{const s=e.stat_energy_from;$.push(s);const i=e.stat_cost||t.state.info.cost_sensors[s];i&&S.push(i)})),g("water_consumption",$,i,"water_consumption_cost",S);const A=[];o.forEach((e=>{A.push(e.stat_consumption)})),g("device_consumption",A,a);const z=new Blob(p,{type:"text/csv"}),E=window.URL.createObjectURL(z);(0,u.N)(E,"energy.csv")}},{kind:"method",key:"_reloadView",value:function(){const e=this._lovelace.config;this._lovelace={...this._lovelace,config:{...e,views:[{...e.views[0]}]}}}},{kind:"get",static:!0,key:"styles",value:function(){return[r.Qx,n.iv`:host hui-energy-period-selector{flex-grow:1;padding-left:32px;padding-inline-start:32px;padding-inline-end:initial;--disabled-text-color:rgba(var(--rgb-text-primary-color), 0.5);direction:var(--direction);--date-range-picker-max-height:calc(100vh - 80px)}:host([narrow]) hui-energy-period-selector{padding-left:0px;padding-inline-start:0px;padding-inline-end:initial}:host{-ms-user-select:none;-webkit-user-select:none;-moz-user-select:none}.header{background-color:var(--app-header-background-color);color:var(--app-header-text-color,#fff);border-bottom:var(--app-header-border-bottom,none);position:fixed;top:0;width:var(--mdc-top-app-bar-width,100%);padding-top:env(safe-area-inset-top);z-index:4;transition:box-shadow .2s linear;display:flex;flex-direction:row;-webkit-backdrop-filter:var(--app-header-backdrop-filter,none);backdrop-filter:var(--app-header-backdrop-filter,none)}:host([scrolled]) .header{box-shadow:var(--mdc-top-app-bar-fixed-box-shadow,0px 2px 4px -1px rgba(0,0,0,.2),0px 4px 5px 0px rgba(0,0,0,.14),0px 1px 10px 0px rgba(0,0,0,.12))}.toolbar{height:var(--header-height);display:flex;flex:1;align-items:center;font-size:20px;padding:0px 12px;font-weight:400;box-sizing:border-box} (max-width:599px){.toolbar{padding:0 4px}}.main-title{margin:var(--margin-title);line-height:20px;flex-grow:1}hui-view-container{position:relative;display:flex;min-height:100vh;box-sizing:border-box;padding-top:calc(var(--header-height) + env(safe-area-inset-top));padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right);padding-inline-start:env(safe-area-inset-left);padding-inline-end:env(safe-area-inset-right);padding-bottom:env(safe-area-inset-bottom)}hui-view{flex:1 1 100%;max-width:100%}`]}}]}}),n.oi);i()}catch(e){i(e)}}))},3983:function(e,t,s){s.a(e,(async function(e,t){try{var i=s(44249),a=s(72621),n=(s(31622),s(13809)),o=s(86319),r=s(3938),h=s(6542),c=s(7591),d=s(96500),l=s(29558),u=s(30921),p=s(40228),f=s(83389),_=s(57243),g=s(15093),v=s(27486),m=s(97674),k=s(19631),y=s(46467),b=s(22381),w=(s(34273),s(48103),s(12667)),x=(s(4635),s(5828),s(1118)),D=s(6736),C=s(48719),$=e([w,y,C,m,x]);[w,y,C,m,x]=$.then?(await $)():$;const S="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",A=["today","yesterday","this_week","this_month","this_quarter","this_year","now-7d","now-30d","now-12m"];(0,i.Z)([(0,g.Mo)("hui-energy-period-selector")],(function(e,t){class s extends t{constructor(...t){super(...t),e(this)}}return{F:s,d:[{kind:"field",decorators:[(0,g.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,g.Cb)({attribute:"collection-key"})],key:"collectionKey",value:void 0},{kind:"field",decorators:[(0,g.Cb)({type:Boolean,reflect:!0})],key:"narrow",value:void 0},{kind:"field",decorators:[(0,g.SB)()],key:"_startDate",value:void 0},{kind:"field",decorators:[(0,g.SB)()],key:"_endDate",value:void 0},{kind:"field",decorators:[(0,g.SB)()],key:"_ranges",value:()=>({})},{kind:"field",decorators:[(0,g.SB)()],key:"_compare",value:()=>!1},{kind:"field",key:"_resizeObserver",value:void 0},{kind:"method",key:"hassSubscribe",value:function(){return[(0,x.UB)(this.hass,{key:this.collectionKey}).subscribe((e=>this._updateDates(e)))]}},{kind:"method",key:"_measure",value:function(){this.narrow=this.offsetWidth<450}},{kind:"method",key:"_attachObserver",value:async function(){this._resizeObserver||(this._resizeObserver=new ResizeObserver((0,b.D)((()=>this._measure()),250,!1))),this._resizeObserver.observe(this)}},{kind:"method",key:"firstUpdated",value:function(){this._attachObserver()}},{kind:"method",key:"connectedCallback",value:function(){(0,a.Z)(s,"connectedCallback",this,3)([]),this.updateComplete.then((()=>this._attachObserver()))}},{kind:"method",key:"disconnectedCallback",value:function(){(0,a.Z)(s,"disconnectedCallback",this,3)([]),this._resizeObserver&&this._resizeObserver.disconnect()}},{kind:"method",key:"willUpdate",value:function(e){(0,a.Z)(s,"willUpdate",this,3)([e]),this.hasUpdated||this._measure(),(!this.hasUpdated||e.has("hass")&&this.hass?.localize!==e.get("hass")?.localize)&&(this._ranges={},A.forEach((e=>{this._ranges[this.hass.localize(`ui.components.date-range-picker.ranges.${e}`)]=(0,C.p)(this.hass,e)})))}},{kind:"method",key:"render",value:function(){if(!this.hass||!this._startDate)return _.Ld;const e=this._simpleRange(this._startDate,this._endDate,this.hass.locale,this.hass.config);return _.dy` <div class="row"> <div class="label"> ${"day"===e?this.narrow?(0,y.mn)(this._startDate,this.hass.locale,this.hass.config):(0,y.p6)(this._startDate,this.hass.locale,this.hass.config):"month"===e?(0,y.NC)(this._startDate,this.hass.locale,this.hass.config):"year"===e?(0,y.yQ)(this._startDate,this.hass.locale,this.hass.config):`${(0,y.ud)(this._startDate,this.hass.locale,this.hass.config)} – ${(0,y.ud)(this._endDate||new Date,this.hass.locale,this.hass.config)}`} </div> <div class="time-handle"> <ha-icon-button-prev .label="${this.hass.localize("ui.panel.lovelace.components.energy_period_selector.previous")}" ="${this._pickPrevious}"></ha-icon-button-prev> <ha-icon-button-next .label="${this.hass.localize("ui.panel.lovelace.components.energy_period_selector.next")}" ="${this._pickNext}"></ha-icon-button-next> <ha-date-range-picker .hass="${this.hass}" .startDate="${this._startDate}" .endDate="${this._endDate||new Date}" .ranges="${this._ranges}" -changed="${this._dateRangeChanged}" -selected="${this._presetSelected}" minimal header-position></ha-date-range-picker> </div> ${this.narrow?_.Ld:_.dy`<mwc-button dense outlined ="${this._pickNow}"> ${this.hass.localize("ui.panel.lovelace.components.energy_period_selector.now")} </mwc-button>`} <ha-button-menu> <ha-icon-button slot="trigger" .label="${this.hass.localize("ui.common.menu")}" .path="${S}"></ha-icon-button> <ha-check-list-item left -selected="${this._toggleCompare}" .selected="${this._compare}"> ${this.hass.localize("ui.panel.lovelace.components.energy_period_selector.compare")} </ha-check-list-item> <slot name="overflow-menu"></slot> </ha-button-menu> </div> `}},{kind:"field",key:"_simpleRange",value:()=>(0,v.Z)(((e,t,s,i)=>{if(0===(0,n.j)(t,e))return"day";if((0,m.vA)(e,o.b,s,i)&&(0,m.vA)(t,r.h,s,i)){if(0===(0,m.Ai)(t,e,h.d,s,i))return"month";if(2===(0,m.Ai)(t,e,h.d,s,i)&&e.getMonth()%3==0)return"quarter"}return(0,m.vA)(e,o.b,s,i)&&(0,m.vA)(t,r.h,s,i)&&11===(0,m.Ai)(t,e,h.d,s,i)?"year":"other"}))},{kind:"method",key:"_updateCollectionPeriod",value:function(){const e=(0,x.UB)(this.hass,{key:this.collectionKey});e.setPeriod(this._startDate,this._endDate),e.refresh()}},{kind:"method",key:"_dateRangeChanged",value:function(e){const t=(0,k.Bt)(this.hass.locale);this._startDate=(0,m.AH)(e.detail.value.startDate,c.b,this.hass.locale,this.hass.config,{weekStartsOn:t}),this._endDate=(0,m.AH)(e.detail.value.endDate,d.i,this.hass.locale,this.hass.config,{weekStartsOn:t}),this._updateCollectionPeriod()}},{kind:"method",key:"_presetSelected",value:function(e){localStorage.setItem(`energy-default-period-_${this.collectionKey||"energy"}`,A[e.detail.index])}},{kind:"method",key:"_pickNow",value:function(){if(!this._startDate)return;const e=this._simpleRange(this._startDate,this._endDate,this.hass.locale,this.hass.config),t=new Date;if("month"===e)[this._startDate,this._endDate]=(0,C.p)(this.hass,"this_month");else if("quarter"===e)[this._startDate,this._endDate]=(0,C.p)(this.hass,"this_quarter");else if("year"===e)[this._startDate,this._endDate]=(0,C.p)(this.hass,"this_year");else{const e=(0,k.Bt)(this.hass.locale),s=(0,m.AH)(this._endDate,l.z,this.hass.locale,this.hass.config,{weekStartsOn:e}),i=(0,m.AH)(this._endDate,u.v,this.hass.locale,this.hass.config,{weekStartsOn:e});if(this._startDate.getTime()===s.getTime()&&this._endDate.getTime()===i.getTime())[this._startDate,this._endDate]=(0,C.p)(this.hass,"this_week");else{const s=(0,m.Ai)(this._endDate,this._startDate,n.j,this.hass.locale,this.hass.config);this._startDate=(0,m.AH)((0,m.AH)(t,p.k,this.hass.locale,this.hass.config,s),c.b,this.hass.locale,this.hass.config,{weekStartsOn:e}),this._endDate=(0,m.AH)(t,d.i,this.hass.locale,this.hass.config,{weekStartsOn:e})}}this._updateCollectionPeriod()}},{kind:"method",key:"_pickPrevious",value:function(){this._shift(!1)}},{kind:"method",key:"_pickNext",value:function(){this._shift(!0)}},{kind:"method",key:"_shift",value:function(e){if(!this._startDate)return;const{start:t,end:s}=(0,m.Al)(this._startDate,this._endDate,e,this.hass.locale,this.hass.config);this._startDate=t,this._endDate=s,this._updateCollectionPeriod()}},{kind:"method",key:"_updateDates",value:function(e){this._compare=void 0!==e.startCompare,this._startDate=e.start,this._endDate=e.end||(0,f.p)()}},{kind:"method",key:"_toggleCompare",value:function(e){if("interaction"!==e.detail.source)return;this._compare=e.detail.selected;const t=(0,x.UB)(this.hass,{key:this.collectionKey});t.setCompare(this._compare),t.refresh()}},{kind:"field",static:!0,key:"styles",value:()=>_.iv`.row{display:flex;align-items:center}:host .time-handle{display:flex;justify-content:flex-end;align-items:center}:host([narrow]) .time-handle{margin-left:auto;margin-inline-start:auto;margin-inline-end:initial}.label{display:flex;align-items:center;justify-content:flex-end;font-size:20px;margin-left:auto;margin-inline-start:auto;margin-inline-end:initial}:host([narrow]) .label{margin-left:unset;margin-inline-start:unset;margin-inline-end:initial}mwc-button{margin-left:8px;margin-inline-start:8px;margin-inline-end:initial;flex-shrink:0;--mdc-button-outline-color:currentColor;--primary-color:currentColor;--mdc-theme-primary:currentColor;--mdc-theme-on-primary:currentColor;--mdc-button-disabled-outline-color:var(--disabled-text-color);--mdc-button-disabled-ink-color:var(--disabled-text-color)}`}]}}),(0,D.f)(_.oi));t()}catch(e){t(e)}}))},58014:function(e,t,s){s.d(t,{N:()=>a,G:()=>n});var i=s(18117);const a=(e,t="")=>{const s=document.createElement("a");s.target="_blank",s.href=e,s.download=t,s.style.display="none",document.body.appendChild(s),s.dispatchEvent(new MouseEvent("click")),document.body.removeChild(s)},n=e=>!(e=>!!e.auth.external&&i.G)(e)||!!e.auth.external?.config.downloadFileSupported},18117:function(e,t,s){s.d(t,{G:()=>i});const i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}};
//# sourceMappingURL=45097.390bacd7c279c4d9.js.map