iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
2 lines • 14.4 kB
JavaScript
"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["38769"],{17705:function(e,t,i){i.d(t,{Cj:()=>u,F7:()=>a,Hs:()=>w,Kd:()=>b,Kj:()=>f,Nw:()=>k,PA:()=>n,Py:()=>l,Qm:()=>S,Z0:()=>y,_Y:()=>c,_m:()=>o,dL:()=>d,dO:()=>D,hN:()=>_,h_:()=>h,j2:()=>g,q6:()=>m,uR:()=>r});i(19083),i(71695),i(9359),i(52924),i(61006),i(47021);var s=i(47194);let a=function(e){return e[e.NONE=0]="NONE",e[e.ARITHMETIC=1]="ARITHMETIC",e[e.CIRCULAR=2]="CIRCULAR",e}({});const n=99387==i.j?["entity_not_recorded","entity_no_longer_recorded","state_class_removed","units_changed","mean_type_changed","no_state"]:null,o=e=>e.sendMessagePromise({type:"recorder/info"}),r=(e,t)=>e.callWS({type:"recorder/list_statistic_ids",statistic_type:t}),l=(e,t)=>e.callWS({type:"recorder/get_statistics_metadata",statistic_ids:t}),d=(e,t,i,s,a="hour",n,o)=>e.callWS({type:"recorder/statistics_during_period",start_time:t.toISOString(),end_time:null==i?void 0:i.toISOString(),statistic_ids:s,period:a,units:n,types:o}),c=(e,t,i,s)=>e.callWS({type:"recorder/statistic_during_period",statistic_id:t,units:s,fixed_period:i.fixed_period?{start_time:i.fixed_period.start instanceof Date?i.fixed_period.start.toISOString():i.fixed_period.start,end_time:i.fixed_period.end instanceof Date?i.fixed_period.end.toISOString():i.fixed_period.end}:void 0,calendar:i.calendar,rolling_window:i.rolling_window}),h=e=>e.callWS({type:"recorder/validate_statistics"}),u=(e,t,i)=>e.callWS({type:"recorder/update_statistics_metadata",statistic_id:t,unit_of_measurement:i}),_=(e,t)=>e.callWS({type:"recorder/clear_statistics",statistic_ids:t}),f=e=>{let t=null;if(!e)return null;for(const i of e)null!==i.change&&void 0!==i.change&&(null===t?t=i.change:t+=i.change);return t},m=(e,t)=>{let i=null;for(const s of t){if(!(s in e))continue;const t=f(e[s]);null!==t&&(null===i?i=t:i+=t)}return i},k=(e,t)=>e.some((e=>void 0!==e[t]&&null!==e[t])),v=["mean","min","max"],p=["sum","state","change"],y=(e,t)=>!(!v.includes(t)||e.mean_type===a.NONE)||!(!p.includes(t)||!e.has_sum),g=(e,t,i,s,a)=>{const n=new Date(i).toISOString();return e.callWS({type:"recorder/adjust_sum_statistics",statistic_id:t,start_time:n,adjustment:s,adjustment_unit_of_measurement:a})},b=(e,t,i)=>{const a=e.states[t];return a?(0,s.C)(a):(null==i?void 0:i.name)||t},D=(e,t,i)=>{let s;var a;t&&(s=null===(a=e.states[t])||void 0===a?void 0:a.attributes.unit_of_measurement);return void 0===s?null==i?void 0:i.statistics_unit_of_measurement:s},w=e=>e.includes(":"),S=e=>e.callWS({type:"recorder/update_statistics_issues"})},6736:function(e,t,i){i.d(t,{f:()=>o});var s=i(61701),a=i(72621),n=(i(19083),i(71695),i(9359),i(52924),i(40251),i(61006),i(47021),i(50778));const o=e=>(0,s.Z)(null,(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,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)(i,"connectedCallback",this,3)([]),this._checkSubscribed()}},{kind:"method",key:"disconnectedCallback",value:function(){if((0,a.Z)(i,"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)(i,"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)},23893:function(e,t,i){i.a(e,(async function(e,s){try{i.r(t),i.d(t,{HuiEnergyDateSelectionCard:()=>_});var a=i(61701),n=(i(71695),i(47021),i(57243)),o=i(50778),r=(i(54977),i(93331)),l=i(3983),d=e([l]);l=(d.then?(await d)():d)[0];let c,h,u=e=>e,_=(0,a.Z)([(0,o.Mo)("hui-energy-date-selection-card")],(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.SB)()],key:"_config",value:void 0},{kind:"method",key:"getCardSize",value:function(){return 1}},{kind:"method",key:"getGridOptions",value:function(){return{rows:1,columns:12}}},{kind:"method",key:"setConfig",value:function(e){this._config=e}},{kind:"method",key:"shouldUpdate",value:function(e){return(0,r.SN)(this,e)||e.size>1||!e.has("hass")}},{kind:"method",key:"render",value:function(){return this.hass&&this._config?(0,n.dy)(c||(c=u` <ha-card> <div class="card-content"> <hui-energy-period-selector .hass="${0}" .collectionKey="${0}"></hui-energy-period-selector> </div> </ha-card> `),this.hass,this._config.collection_key):n.Ld}},{kind:"field",static:!0,key:"styles",value(){return(0,n.iv)(h||(h=u`ha-card{height:100%;display:flex;flex-direction:column;justify-content:center}`))}}]}}),n.oi);s()}catch(c){s(c)}}))},3983:function(e,t,i){i.a(e,(async function(e,t){try{var s=i(61701),a=i(72621),n=i(31948),o=(i(71695),i(40251),i(47021),i(31622),i(13809)),r=i(86319),l=i(3938),d=i(6542),c=i(7591),h=i(96500),u=i(29558),_=i(30921),f=i(40228),m=i(83389),k=i(57243),v=i(50778),p=i(27486),y=i(97674),g=i(19631),b=i(46467),D=i(22381),w=(i(34273),i(48103),i(12667)),S=(i(4635),i(5828),i(1118)),C=i(6736),A=i(48719),x=e([n,w,b,g,A,y,S]);[n,w,b,g,A,y,S]=x.then?(await x)():x;let O,$,z,P=e=>e;const R="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",H=["today","yesterday","this_week","this_month","this_quarter","this_year","now-7d","now-30d","now-12m"];(0,s.Z)([(0,v.Mo)("hui-energy-period-selector")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,v.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,v.Cb)({attribute:"collection-key"})],key:"collectionKey",value:void 0},{kind:"field",decorators:[(0,v.Cb)({type:Boolean,reflect:!0})],key:"narrow",value:void 0},{kind:"field",decorators:[(0,v.SB)()],key:"_startDate",value:void 0},{kind:"field",decorators:[(0,v.SB)()],key:"_endDate",value:void 0},{kind:"field",decorators:[(0,v.SB)()],key:"_ranges",value(){return{}}},{kind:"field",decorators:[(0,v.SB)()],key:"_compare",value(){return!1}},{kind:"field",key:"_resizeObserver",value:void 0},{kind:"method",key:"hassSubscribe",value:function(){return[(0,S.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,D.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)(i,"connectedCallback",this,3)([]),this.updateComplete.then((()=>this._attachObserver()))}},{kind:"method",key:"disconnectedCallback",value:function(){(0,a.Z)(i,"disconnectedCallback",this,3)([]),this._resizeObserver&&this._resizeObserver.disconnect()}},{kind:"method",key:"willUpdate",value:function(e){var t,s;(0,a.Z)(i,"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===(s=e.get("hass"))||void 0===s?void 0:s.localize))&&(this._ranges={},H.forEach((e=>{this._ranges[this.hass.localize(`ui.components.date-range-picker.ranges.${e}`)]=(0,A.p)(this.hass,e)})))}},{kind:"method",key:"render",value:function(){if(!this.hass||!this._startDate)return k.Ld;const e=this._simpleRange(this._startDate,this._endDate,this.hass.locale,this.hass.config);return(0,k.dy)(O||(O=P` <div class="row"> <div class="label"> ${0} </div> <div class="time-handle"> <ha-icon-button-prev .label="${0}" ="${0}"></ha-icon-button-prev> <ha-icon-button-next .label="${0}" ="${0}"></ha-icon-button-next> <ha-date-range-picker .hass="${0}" .startDate="${0}" .endDate="${0}" .ranges="${0}" -changed="${0}" -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 -selected="${0}" .selected="${0}"> ${0} </ha-check-list-item> <slot name="overflow-menu"></slot> </ha-button-menu> </div> `),"day"===e?this.narrow?(0,b.mn)(this._startDate,this.hass.locale,this.hass.config):(0,b.p6)(this._startDate,this.hass.locale,this.hass.config):"month"===e?(0,b.NC)(this._startDate,this.hass.locale,this.hass.config):"year"===e?(0,b.yQ)(this._startDate,this.hass.locale,this.hass.config):`${(0,b.ud)(this._startDate,this.hass.locale,this.hass.config)} – ${(0,b.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?k.Ld:(0,k.dy)($||($=P`<mwc-button dense outlined ="${0}"> ${0} </mwc-button>`),this._pickNow,this.hass.localize("ui.panel.lovelace.components.energy_period_selector.now")),this.hass.localize("ui.common.menu"),R,this._toggleCompare,this._compare,this.hass.localize("ui.panel.lovelace.components.energy_period_selector.compare"))}},{kind:"field",key:"_simpleRange",value(){return(0,p.Z)(((e,t,i,s)=>{if(0===(0,o.j)(t,e))return"day";if((0,y.vA)(e,r.b,i,s)&&(0,y.vA)(t,l.h,i,s)){if(0===(0,y.Ai)(t,e,d.d,i,s))return"month";if(2===(0,y.Ai)(t,e,d.d,i,s)&&e.getMonth()%3==0)return"quarter"}return(0,y.vA)(e,r.b,i,s)&&(0,y.vA)(t,l.h,i,s)&&11===(0,y.Ai)(t,e,d.d,i,s)?"year":"other"}))}},{kind:"method",key:"_updateCollectionPeriod",value:function(){const e=(0,S.UB)(this.hass,{key:this.collectionKey});e.setPeriod(this._startDate,this._endDate),e.refresh()}},{kind:"method",key:"_dateRangeChanged",value:function(e){const t=(0,g.Bt)(this.hass.locale);this._startDate=(0,y.AH)(e.detail.value.startDate,c.b,this.hass.locale,this.hass.config,{weekStartsOn:t}),this._endDate=(0,y.AH)(e.detail.value.endDate,h.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"}`,H[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,A.p)(this.hass,"this_month");else if("quarter"===e)[this._startDate,this._endDate]=(0,A.p)(this.hass,"this_quarter");else if("year"===e)[this._startDate,this._endDate]=(0,A.p)(this.hass,"this_year");else{const e=(0,g.Bt)(this.hass.locale),i=(0,y.AH)(this._endDate,u.z,this.hass.locale,this.hass.config,{weekStartsOn:e}),s=(0,y.AH)(this._endDate,_.v,this.hass.locale,this.hass.config,{weekStartsOn:e});if(this._startDate.getTime()===i.getTime()&&this._endDate.getTime()===s.getTime())[this._startDate,this._endDate]=(0,A.p)(this.hass,"this_week");else{const i=(0,y.Ai)(this._endDate,this._startDate,o.j,this.hass.locale,this.hass.config);this._startDate=(0,y.AH)((0,y.AH)(t,f.k,this.hass.locale,this.hass.config,i),c.b,this.hass.locale,this.hass.config,{weekStartsOn:e}),this._endDate=(0,y.AH)(t,h.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:i}=(0,y.Al)(this._startDate,this._endDate,e,this.hass.locale,this.hass.config);this._startDate=t,this._endDate=i,this._updateCollectionPeriod()}},{kind:"method",key:"_updateDates",value:function(e){this._compare=void 0!==e.startCompare,this._startDate=e.start,this._endDate=e.end||(0,m.p)()}},{kind:"method",key:"_toggleCompare",value:function(e){if("interaction"!==e.detail.source)return;this._compare=e.detail.selected;const t=(0,S.UB)(this.hass,{key:this.collectionKey});t.setCompare(this._compare),t.refresh()}},{kind:"field",static:!0,key:"styles",value(){return(0,k.iv)(z||(z=P`.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)(k.oi));t()}catch(O){t(O)}}))},68289:function(e,t,i){var s=i(40810),a=i(1569),n=i(27803),o=i(85779),r=TypeError,l=Object.defineProperty,d=a.self!==a;try{if(o){var c=Object.getOwnPropertyDescriptor(a,"self");!d&&c&&c.get&&c.enumerable||n(a,"self",{get:function(){return a},set:function(e){if(this!==a)throw new r("Illegal invocation");l(a,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})}else s({global:!0,simple:!0,forced:d},{self:a})}catch(h){}},83389:function(e,t,i){i.d(t,{p:()=>a});var s=i(96500);function a(e){return(0,s.i)(Date.now(),e)}}}]);
//# sourceMappingURL=38769.eddf9a2f22d9e587.js.map