UNPKG

iobroker.lovelace

Version:

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

2 lines 18.7 kB
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["45097"],{85366:function(e,t,s){var i=s(61701),a=(s(71695),s(47021),s(82238)),n=s(66575),o=s(57243),r=s(50778);let h,l=e=>e;(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(){return[n.W,(0,o.iv)(h||(h=l`.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(61701),a=s(72621),n=(s(19083),s(71695),s(9359),s(52924),s(40251),s(61006),s(47021),s(50778));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(){var e;void 0!==this.__unsubs||!this.isConnected||void 0===this.hass||null!==(e=this.hassSubscribeRequiredHostProps)&&void 0!==e&&e.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(61701),n=(s(71695),s(92745),s(61893),s(9359),s(56475),s(31526),s(70104),s(19423),s(40251),s(11740),s(92519),s(42179),s(89256),s(24931),s(88463),s(57449),s(19814),s(47021),s(72700),s(8038),s(71513),s(75656),s(50100),s(18084),s(57243)),o=s(50778),r=(s(43344),s(7285),s(85366),s(28008)),h=s(3983),l=s(3166),d=(s(33679),s(83523)),c=s(1118),u=s(58014),p=e([h,l,c]);[h,l,c]=p.then?(await p)():p;let f,v,_,g,m=e=>e;const k="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",b="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",y={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(){return!1}},{kind:"field",decorators:[(0,o.SB)()],key:"_viewIndex",value(){return 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");(null==t?void 0:t.locale)!==this.hass.locale&&this._setLovelace(),t&&t.localize!==this.hass.localize&&this._reloadView()}},{kind:"method",key:"render",value:function(){var e;return(0,n.dy)(f||(f=m` <div class="header"> <div class="toolbar"> <ha-menu-button slot="navigationIcon" .hass="${0}" .narrow="${0}"></ha-menu-button> ${0} <hui-energy-period-selector .hass="${0}" collection-key="energy_dashboard"> ${0} <ha-list-item slot="overflow-menu" graphic="icon" @request-selected="${0}"> <ha-svg-icon slot="graphic" .path="${0}"> </ha-svg-icon> ${0} </ha-list-item> </hui-energy-period-selector> </div> </div> <hui-view-container .hass="${0}" @reload-energy-panel="${0}"> <hui-view .hass="${0}" .narrow="${0}" .lovelace="${0}" .index="${0}"></hui-view> </hui-view-container> `),this.hass,this.narrow,this.narrow?n.Ld:(0,n.dy)(v||(v=m`<div class="main-title"> ${0} </div>`),this.hass.localize("panel.energy")),this.hass,null!==(e=this.hass.user)&&void 0!==e&&e.is_admin?(0,n.dy)(_||(_=m` <ha-list-item slot="overflow-menu" graphic="icon" @request-selected="${0}"> <ha-svg-icon slot="graphic" .path="${0}"> </ha-svg-icon> ${0} </ha-list-item>`),this._navigateConfig,k,this.hass.localize("ui.panel.energy.configure")):n.Ld,this._dumpCSV,b,this.hass.localize("ui.panel.energy.download_data"),this.hass,this._reloadView,this.hass,this.narrow,this._lovelace,this._viewIndex)}},{kind:"method",key:"_setLovelace",value:function(){this._lovelace={config:y,rawConfig:y,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,c.UB)(this.hass,{key:"energy_dashboard"});if(!t.prefs||!t.state.stats)return;const s=(0,c.vE)(this.hass,t.prefs,t.state.statsMetadata),i=(0,c.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 l=Array.from(h).sort(),d="entity_id,type,unit,"+l.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")),l.forEach((t=>{var s;i<r[e].length&&r[e][i].start===t?(a.push((null!==(s=r[e][i].change)&&void 0!==s?s:"").toString()),i++):a.push("")})),p.push(a.join(",")+"\n"))},v=this.hass.config.currency,_=function(e,t,s,i,a){t.length&&(t.forEach((t=>f(t,e,s))),i&&a&&a.forEach((e=>f(e,i,v))))},g=[],m=[],k=[],b=[];n.filter((e=>"grid"===e.type)).forEach((e=>{e.flow_from.forEach((e=>{const s=e.stat_energy_from;g.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&&b.push(i)}))})),_("grid_consumption",g,a,"grid_consumption_cost",k),_("grid_return",m,a,"grid_return_compensation",b);const y=[],w=[];n.filter((e=>"battery"===e.type)).forEach((e=>{y.push(e.stat_energy_to),w.push(e.stat_energy_from)})),_("battery_in",y,a),_("battery_out",w,a);const x=[];n.filter((e=>"solar"===e.type)).forEach((e=>{x.push(e.stat_energy_from)})),_("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)})),_("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)})),_("water_consumption",$,i,"water_consumption_cost",S);const A=[];o.forEach((e=>{A.push(e.stat_consumption)})),_("device_consumption",A,a);const z=new Blob(p,{type:"text/csv"}),O=window.URL.createObjectURL(z);(0,u.N)(O,"energy.csv")}},{kind:"method",key:"_reloadView",value:function(){const e=this._lovelace.config;this._lovelace=Object.assign(Object.assign({},this._lovelace),{},{config:Object.assign(Object.assign({},e),{},{views:[Object.assign({},e.views[0])]})})}},{kind:"get",static:!0,key:"styles",value:function(){return[r.Qx,(0,n.iv)(g||(g=m`: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}@media (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(f){i(f)}}))},3983:function(e,t,s){s.a(e,(async function(e,t){try{var i=s(61701),a=s(72621),n=s(31948),o=(s(71695),s(40251),s(47021),s(31622),s(13809)),r=s(86319),h=s(3938),l=s(6542),d=s(7591),c=s(96500),u=s(29558),p=s(30921),f=s(40228),v=s(83389),_=s(57243),g=s(50778),m=s(27486),k=s(97674),b=s(19631),y=s(46467),w=s(22381),x=(s(34273),s(48103),s(12667)),D=(s(4635),s(5828),s(1118)),C=s(6736),$=s(48719),S=e([n,x,y,b,$,k,D]);[n,x,y,b,$,k,D]=S.then?(await S)():S;let A,z,O,E=e=>e;const H="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",B=["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(){return{}}},{kind:"field",decorators:[(0,g.SB)()],key:"_compare",value(){return!1}},{kind:"field",key:"_resizeObserver",value:void 0},{kind:"method",key:"hassSubscribe",value:function(){return[(0,D.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,w.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){var t,i;(0,a.Z)(s,"willUpdate",this,3)([e]),this.hasUpdated||this._measure(),(!this.hasUpdated||e.has("hass")&&(null===(t=this.hass)||void 0===t?void 0:t.localize)!==(null===(i=e.get("hass"))||void 0===i?void 0:i.localize))&&(this._ranges={},B.forEach((e=>{this._ranges[this.hass.localize(`ui.components.date-range-picker.ranges.${e}`)]=(0,$.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(0,_.dy)(A||(A=E` <div class="row"> <div class="label"> ${0} </div> <div class="time-handle"> <ha-icon-button-prev .label="${0}" @click="${0}"></ha-icon-button-prev> <ha-icon-button-next .label="${0}" @click="${0}"></ha-icon-button-next> <ha-date-range-picker .hass="${0}" .startDate="${0}" .endDate="${0}" .ranges="${0}" @value-changed="${0}" @preset-selected="${0}" minimal header-position></ha-date-range-picker> </div> ${0} <ha-button-menu> <ha-icon-button slot="trigger" .label="${0}" .path="${0}"></ha-icon-button> <ha-check-list-item left @request-selected="${0}" .selected="${0}"> ${0} </ha-check-list-item> <slot name="overflow-menu"></slot> </ha-button-menu> </div> `),"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)}`,this.hass.localize("ui.panel.lovelace.components.energy_period_selector.previous"),this._pickPrevious,this.hass.localize("ui.panel.lovelace.components.energy_period_selector.next"),this._pickNext,this.hass,this._startDate,this._endDate||new Date,this._ranges,this._dateRangeChanged,this._presetSelected,this.narrow?_.Ld:(0,_.dy)(z||(z=E`<mwc-button dense outlined @click="${0}"> ${0} </mwc-button>`),this._pickNow,this.hass.localize("ui.panel.lovelace.components.energy_period_selector.now")),this.hass.localize("ui.common.menu"),H,this._toggleCompare,this._compare,this.hass.localize("ui.panel.lovelace.components.energy_period_selector.compare"))}},{kind:"field",key:"_simpleRange",value(){return(0,m.Z)(((e,t,s,i)=>{if(0===(0,o.j)(t,e))return"day";if((0,k.vA)(e,r.b,s,i)&&(0,k.vA)(t,h.h,s,i)){if(0===(0,k.Ai)(t,e,l.d,s,i))return"month";if(2===(0,k.Ai)(t,e,l.d,s,i)&&e.getMonth()%3==0)return"quarter"}return(0,k.vA)(e,r.b,s,i)&&(0,k.vA)(t,h.h,s,i)&&11===(0,k.Ai)(t,e,l.d,s,i)?"year":"other"}))}},{kind:"method",key:"_updateCollectionPeriod",value:function(){const e=(0,D.UB)(this.hass,{key:this.collectionKey});e.setPeriod(this._startDate,this._endDate),e.refresh()}},{kind:"method",key:"_dateRangeChanged",value:function(e){const t=(0,b.Bt)(this.hass.locale);this._startDate=(0,k.AH)(e.detail.value.startDate,d.b,this.hass.locale,this.hass.config,{weekStartsOn:t}),this._endDate=(0,k.AH)(e.detail.value.endDate,c.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"}`,B[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,$.p)(this.hass,"this_month");else if("quarter"===e)[this._startDate,this._endDate]=(0,$.p)(this.hass,"this_quarter");else if("year"===e)[this._startDate,this._endDate]=(0,$.p)(this.hass,"this_year");else{const e=(0,b.Bt)(this.hass.locale),s=(0,k.AH)(this._endDate,u.z,this.hass.locale,this.hass.config,{weekStartsOn:e}),i=(0,k.AH)(this._endDate,p.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,$.p)(this.hass,"this_week");else{const s=(0,k.Ai)(this._endDate,this._startDate,o.j,this.hass.locale,this.hass.config);this._startDate=(0,k.AH)((0,k.AH)(t,f.k,this.hass.locale,this.hass.config,s),d.b,this.hass.locale,this.hass.config,{weekStartsOn:e}),this._endDate=(0,k.AH)(t,c.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,k.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,v.p)()}},{kind:"method",key:"_toggleCompare",value:function(e){if("interaction"!==e.detail.source)return;this._compare=e.detail.selected;const t=(0,D.UB)(this.hass,{key:this.collectionKey});t.setCompare(this._compare),t.refresh()}},{kind:"field",static:!0,key:"styles",value(){return(0,_.iv)(O||(O=E`.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,C.f)(_.oi));t()}catch(A){t(A)}}))},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=>{var t;return!(e=>!!e.auth.external&&i.G)(e)||!(null===(t=e.auth.external)||void 0===t||!t.config.downloadFileSupported)}},18117:function(e,t,s){s.d(t,{G:()=>i});s(19134),s(5740);const i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}]); //# sourceMappingURL=45097.76412c0cbf5ad851.js.map