UNPKG

iobroker.lovelace

Version:

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

1 lines 15.5 kB
export const __rspack_esm_id=71483;export const __rspack_esm_ids=[71483];export const __webpack_modules__={54706(e,t,s){s.d(t,{E:()=>o});s(74423),s(18111),s(13579);var i=s(62826),a=s(22441);const o=e=>{class t extends e{connectedCallback(){super.connectedCallback(),this._checkSubscribed()}disconnectedCallback(){if(super.disconnectedCallback(),this.__unsubs){for(;this.__unsubs.length;){const e=this.__unsubs.pop();e instanceof Promise?e.then(e=>e()):e()}this.__unsubs=void 0}}updated(e){if(super.updated(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()}hassSubscribe(){return[]}_checkSubscribed(){void 0===this.__unsubs&&this.isConnected&&void 0!==this.hass&&!this.hassSubscribeRequiredHostProps?.some(e=>void 0===this[e])&&(this.__unsubs=this.hassSubscribe())}}return(0,i.Cg)([(0,a.MZ)({attribute:!1})],t.prototype,"hass",void 0),t}},56342(e,t,s){s.a(e,async function(e,i){try{s.r(t),s.d(t,{HuiEnergyDateSelectionCard:()=>d});var a=s(62826),o=s(5124),n=s(22441),h=(s(76776),s(784)),r=s(73887),c=s(38114),l=e([r,c]);[r,c]=l.then?(await l)():l;class d extends o.WF{static async getConfigElement(){return await s.e(42577).then(s.bind(s,92840)),document.createElement("hui-energy-date-selection-card-editor")}static getStubConfig(e,t,s){return{type:"energy-date-selection",vertical_opening_direction:"auto",opening_direction:"auto"}}getCardSize(){return 1}getGridOptions(){return{rows:1,columns:12}}setConfig(e){e.collection_key&&(0,c.s8)(e.collection_key),this._config=e}shouldUpdate(e){return(0,h.xP)(this,e)||e.size>1||!e.has("hass")}render(){if(!this.hass||!this._config)return o.s6;const e="auto"===this._config.vertical_opening_direction?void 0:this._config.vertical_opening_direction,t="auto"===this._config.opening_direction?void 0:this._config.opening_direction;return o.qy` <ha-card> <div class="card-content"> <hui-energy-period-selector .hass="${this.hass}" .collectionKey="${this._config.collection_key}" .verticalOpeningDirection="${e}" .openingDirection="${t}" .allowCompare="${!this._config.disable_compare}"></hui-energy-period-selector> </div> </ha-card> `}}d.styles=o.AH`ha-card{height:100%;display:flex;flex-direction:column;justify-content:center}`,(0,a.Cg)([(0,n.MZ)({attribute:!1})],d.prototype,"hass",void 0),(0,a.Cg)([(0,n.wk)()],d.prototype,"_config",void 0),d=(0,a.Cg)([(0,n.EM)("hui-energy-date-selection-card")],d),i()}catch(e){i(e)}})},73887(e,t,s){s.a(e,async function(e,t){try{var i=s(62826),a=s(80605),o=s(35932),n=s(73983),h=s(29224),r=s(35660),c=s(21828),l=s(36307),d=s(52640),p=s(69137),_=s(6946),g=s(55144),u=s(40600),f=s(78016),b=s(31810),m=s(87950),y=s(5124),v=s(22441),w=s(6412),k=s(22786),D=s(91069),C=s(46223),$=s(380),x=s(72487),O=s(63091),z=s(57237),M=s(9899),P=s(58987),L=s(18350),q=s(29823),H=(s(70947),s(54276),s(65829)),S=(s(67094),s(38114)),A=s(54706),E=e([P,L,q,H,x,C,S,D]);[P,L,q,H,x,C,S,D]=E.then?(await E)():E;const V="M19,3H5C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5C21,3.89 20.1,3 19,3M19,5V19H5V5H19Z",Z="M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M19,5V19H5V5H19M10,17L6,13L7.41,11.58L10,14.17L16.59,7.58L18,9",T="M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z",R="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z",B="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",U="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",W="M16.5 16.25L19.36 17.94L18.61 19.16L15 17V12H16.5V16.25M23 16C23 19.87 19.87 23 16 23C13.62 23 11.53 21.81 10.26 20H4V12H1L11 3L18 9.29C20.89 10.15 23 12.83 23 16M21 16C21 13.24 18.76 11 16 11S11 13.24 11 16 13.24 21 16 21 21 18.76 21 16Z",I=["today","yesterday","this_week","this_month","this_quarter","this_year","now-7d","now-30d","now-365d","now-12m"];class K extends((0,A.E)(y.WF)){hassSubscribe(){return[(0,S.tb)(this.hass,{key:this.collectionKey}).subscribe(e=>this._updateDates(e))]}_measure(){this.narrow=this.offsetWidth<425,this._collapseButtons=this.offsetWidth<275}async _attachObserver(){this._resizeObserver||(this._resizeObserver=new ResizeObserver((0,M.s)(()=>this._measure(),250,!1))),this._resizeObserver.observe(this)}firstUpdated(){this._attachObserver()}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this._attachObserver())}disconnectedCallback(){super.disconnectedCallback(),this._resizeObserver&&this._resizeObserver.disconnect()}willUpdate(e){super.willUpdate(e),this.hasUpdated||this._measure(),(!this.hasUpdated||e.has("hass")&&this.hass?.localize!==e.get("hass")?.localize)&&(this._ranges={},I.forEach(e=>{this._ranges[this.hass.localize(`ui.components.date-range-picker.ranges.${e}`)]=(0,C.b)(this.hass.locale,this.hass.config,e)}))}render(){if(!this.hass||!this._startDate)return y.s6;const e=this._simpleRange(this._startDate,this._endDate,this.hass.locale,this.hass.config),t=new Date,s=0!==(0,D.EO)(t,this._startDate,a.n,this.hass.locale,this.hass.config),i=this._endDate&&0!==(0,D.EO)(this._endDate,this._startDate,a.n,this.hass.locale,this.hass.config),o="year"!==e&&(s||i),n=[{path:"rtl"===O.G.document.dir?R:T,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.previous"),action:()=>this._pickPrevious()},{path:"rtl"===O.G.document.dir?T:R,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.next"),action:()=>this._pickNext()},{path:W,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.now"),alwaysCollapse:!0,hidden:!this.narrow,action:()=>this._pickNow()},{path:this._compare?Z:V,disabled:!this.allowCompare,alwaysCollapse:!0,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.compare"),action:()=>this._toggleCompare()},{path:U,alwaysCollapse:!0,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.download_data"),action:()=>(0,S.h_)(this.hass,this.collectionKey)}];return y.qy` <div class="${(0,w.H)({row:!0,"datepicker-open":this._datepickerOpen})}"> <div class="backdrop"></div> <div class="content"> <section class="date-picker-icon"> <ha-date-range-picker .startDate="${this._startDate}" .endDate="${this._endDate||new Date}" .ranges="${this._ranges}" @value-changed="${this._dateRangeChanged}" @preset-selected="${this._presetSelected}" @toggle="${this._handleDatepickerToggle}" minimal backdrop .popoverPlacement="${this._getDatePickerPlacement(this.verticalOpeningDirection,this.openingDirection)}"></ha-date-range-picker> </section> <section class="date-range" @click="${this._openDatePicker}"> <ha-ripple></ha-ripple> <div class="header-title"> ${"year"===e?y.qy`${(0,x.Pm)(this._startDate,this.hass.locale,this.hass.config)}`:y.qy`${"12month"===e||"months"===e||"quarter"===e?y.qy`${(0,x.c2)(this._startDate,this.hass.locale,this.hass.config)}–${(0,x.c2)(this._endDate||new Date,this.hass.locale,this.hass.config)}`:y.qy`${"month"===e?y.qy`${(0,x.Wq)(this._startDate,this.hass.locale,this.hass.config)}`:"day"===e?y.qy`${(0,x.sl)(this._startDate,this.hass.locale,this.hass.config)}`:y.qy`${(0,x.sl)(this._startDate,this.hass.locale,this.hass.config)}–${(0,x.sl)(this._endDate||new Date,this.hass.locale,this.hass.config)}`}`}`} </div> ${o?y.qy`<div class="header-subtitle"> ${(0,x.Pm)(this._startDate,this.hass.locale,this.hass.config)}${i?y.qy`–${(0,x.Pm)(this._endDate||new Date,this.hass.locale,this.hass.config)}`:""} </div>`:y.s6} <ha-spinner class="${(0,w.H)({"loading-indicator":!0,"is-loading":this._loading})}" size="small"></ha-spinner> </section> <section class="date-actions"> <div class="overflow"> ${this.narrow?y.s6:y.qy`<ha-button appearance="filled" size="small" @click="${this._pickNow}"> ${this.hass.localize("ui.panel.lovelace.components.energy_period_selector.now")} </ha-button>`} ${n.map(e=>this._collapseButtons||e.alwaysCollapse?y.s6:y.qy`<ha-icon-button @click="${e.action}" .label="${e.label}" .path="${e.path}" ?disabled="${e.disabled}"></ha-icon-button>`)} ${this._collapseButtons||n.some(e=>e.alwaysCollapse)?y.qy`<ha-dropdown @wa-show="${this._handleIconOverflowMenuOpened}" @click="${z.d}"> <ha-icon-button .label="${this.hass.localize("ui.common.overflow_menu")}" .path="${B}" slot="trigger"></ha-icon-button> ${n.map(e=>!this._collapseButtons&&!e.alwaysCollapse||e.hidden?y.s6:y.qy`<ha-dropdown-item ?disabled="${e.disabled}" @click="${e.disabled?void 0:e.action}"> <ha-svg-icon slot="icon" .path="${e.path}"></ha-svg-icon> ${e.label} </ha-dropdown-item>`)} </ha-dropdown>`:y.s6} </div> </section> </div> </div> `}get _datePicker(){return this.shadowRoot.querySelector("ha-date-range-picker")??void 0}_handleIconOverflowMenuOpened(e){e.stopPropagation()}_openDatePicker(e){const t=this._datePicker;t&&t.open(),e.stopPropagation()}_updateCollectionPeriod(){const e=(0,S.tb)(this.hass,{key:this.collectionKey});e.setPeriod(this._startDate,this._endDate),e.refresh(),this._scheduleLoadingIndicator()}_dateRangeChanged(e){this._startDate=(0,D.ol)(e.detail.value.startDate,o.o,this.hass.locale,this.hass.config),this._endDate=(0,D.ol)(e.detail.value.endDate,n.D,this.hass.locale,this.hass.config),this._updateCollectionPeriod()}_presetSelected(e){localStorage.setItem(`energy-default-period-_${this.collectionKey||"energy"}`,I[e.detail.index])}_pickNow(){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.b)(this.hass.locale,this.hass.config,"this_month");else if("quarter"===e)[this._startDate,this._endDate]=(0,C.b)(this.hass.locale,this.hass.config,"this_quarter");else if("year"===e)[this._startDate,this._endDate]=(0,C.b)(this.hass.locale,this.hass.config,"this_year");else if("12month"===e)[this._startDate,this._endDate]=(0,C.b)(this.hass.locale,this.hass.config,"now-12m");else if("months"===e){const e=(0,D.EO)(this._endDate,this._startDate,h.U,this.hass.locale,this.hass.config);this._startDate=(0,D.ol)((0,D.ol)(t,r.w,this.hass.locale,this.hass.config),c.a,this.hass.locale,this.hass.config,e),this._endDate=(0,D.ol)(t,l.p,this.hass.locale,this.hass.config)}else{const e=(0,$.P)(this.hass.locale),s=(0,D.ol)(this._endDate,d.k,this.hass.locale,this.hass.config,{weekStartsOn:e}),i=(0,D.ol)(this._endDate,p.$,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.b)(this.hass.locale,this.hass.config,"this_week");else{const s=(0,D.EO)(this._endDate,this._startDate,_.c,this.hass.locale,this.hass.config);this._startDate=(0,D.ol)((0,D.ol)(t,g.e,this.hass.locale,this.hass.config,s),o.o,this.hass.locale,this.hass.config,{weekStartsOn:e}),this._endDate=(0,D.ol)(t,n.D,this.hass.locale,this.hass.config,{weekStartsOn:e})}}this._updateCollectionPeriod()}_pickPrevious(){this._shift(!1)}_pickNext(){this._shift(!0)}_shift(e){if(!this._startDate)return;const{start:t,end:s}=(0,D.eE)(this._startDate,this._endDate,e,this.hass.locale,this.hass.config);this._startDate=t,this._endDate=s,this._updateCollectionPeriod()}_updateDates(e){clearTimeout(this._loadingTimer),this._loading=!1,this._compare=void 0!==e.startCompare,this._startDate=e.start,this._endDate=e.end||(0,u.o)()}_handleDatepickerToggle(e){this._datepickerOpen=e.detail.open}_toggleCompare(){this._compare=!this._compare;const e=(0,S.tb)(this.hass,{key:this.collectionKey});e.setCompare(this._compare?S.lh.PREVIOUS:S.lh.NONE),e.refresh(),this._scheduleLoadingIndicator()}_scheduleLoadingIndicator(){clearTimeout(this._loadingTimer),this._loadingTimer=setTimeout(()=>{this._loading=!0},200)}constructor(...e){super(...e),this.allowCompare=!0,this._datepickerOpen=!1,this._ranges={},this._compare=!1,this._collapseButtons=!1,this._loading=!1,this._simpleRange=(0,k.A)((e,t,s,i)=>0===(0,_.c)(t,e)?"day":(0,D.xo)(e,f.e,s,i)&&(0,D.xo)(t,b.c,s,i)?0===(0,D.EO)(t,e,m.W,s,i)?"month":2===(0,D.EO)(t,e,m.W,s,i)&&e.getMonth()%3==0?"quarter":11===(0,D.EO)(t,e,m.W,s,i)?0===(0,D.EO)(t,e,a.n,s,i)?"year":"12month":"months":"other"),this._getDatePickerPlacement=(0,k.A)((e,t)=>{const s="up"===e?"top":"bottom";if("center"===t||"inline"===t)return s;return`${s}-${"left"===t?"end":"start"}`})}}K.styles=y.AH`:host{display:block}.row{justify-content:space-between;container-type:inline-size}.content{display:flex;flex-direction:row;align-items:center;box-sizing:border-box}.date-picker-icon{flex:none;min-width:var(--ha-space-2);height:100%;display:flex;flex-direction:row}.date-range{flex:1;padding:2px var(--ha-space-2) 2px 0px;display:flex;flex-direction:column;justify-content:center;min-height:var(--ha-space-10);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;position:relative}.header-title{font-size:var(--ha-font-size-xl);line-height:var(--ha-line-height-condensed);font-weight:var(--ha-font-weight-medium);color:var(--primary-text-color)}.header-subtitle{font-size:var(--ha-font-size-m);line-height:var(--ha-line-height-condensed);color:var(--secondary-text-color)}:host([narrow]) .header-title{font-size:var(--ha-font-size-m)}:host([narrow]) .header-subtitle{font-size:var(--ha-font-size-s)}.date-actions{flex:none;min-width:var(--ha-space-2);height:100%;display:flex;flex-direction:row;align-items:center}.loading-indicator{display:flex;position:absolute;right:var(--ha-space-2);align-items:center;opacity:0;transition:opacity var(--ha-animation-duration-normal) ease-in-out}.loading-indicator.is-loading{opacity:1}.date-actions .overflow{display:flex;align-items:center}ha-button{margin-left:var(--ha-space-2);margin-inline-start:var(--ha-space-2);margin-inline-end:initial;flex-shrink:0;--ha-button-theme-color:currentColor}ha-ripple{border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg))}:host([narrow]) ha-date-range-picker{--ha-icon-button-size:24px;--mdc-icon-size:16px}.backdrop{position:fixed;top:0;left:0;right:0;bottom:0;z-index:var(--dialog-z-index,8);-webkit-backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter));backdrop-filter:var(--ha-dialog-scrim-backdrop-filter,var(--dialog-backdrop-filter));pointer-events:none;opacity:0;transition:opacity var(--ha-animation-duration-slow) ease-in-out}.datepicker-open .backdrop{opacity:1;pointer-events:auto}`,(0,i.Cg)([(0,v.MZ)({attribute:!1})],K.prototype,"hass",void 0),(0,i.Cg)([(0,v.MZ)({attribute:"collection-key"})],K.prototype,"collectionKey",void 0),(0,i.Cg)([(0,v.MZ)({type:Boolean,reflect:!0})],K.prototype,"narrow",void 0),(0,i.Cg)([(0,v.MZ)({type:Boolean,reflect:!0})],K.prototype,"fixed",void 0),(0,i.Cg)([(0,v.MZ)({type:Boolean,attribute:"allow-compare"})],K.prototype,"allowCompare",void 0),(0,i.Cg)([(0,v.MZ)({attribute:"vertical-opening-direction"})],K.prototype,"verticalOpeningDirection",void 0),(0,i.Cg)([(0,v.MZ)({attribute:"opening-direction"})],K.prototype,"openingDirection",void 0),(0,i.Cg)([(0,v.wk)()],K.prototype,"_datepickerOpen",void 0),(0,i.Cg)([(0,v.wk)()],K.prototype,"_startDate",void 0),(0,i.Cg)([(0,v.wk)()],K.prototype,"_endDate",void 0),(0,i.Cg)([(0,v.wk)()],K.prototype,"_ranges",void 0),(0,i.Cg)([(0,v.wk)()],K.prototype,"_compare",void 0),(0,i.Cg)([(0,v.wk)()],K.prototype,"_collapseButtons",void 0),(0,i.Cg)([(0,v.wk)()],K.prototype,"_loading",void 0),K=(0,i.Cg)([(0,v.EM)("hui-energy-period-selector")],K),t()}catch(e){t(e)}})}};