UNPKG

iobroker.lovelace

Version:

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

1 lines 16.6 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[79352],{54706:function(e,t,s){s.d(t,{E:function(){return o}});s(74423),s(18111),s(13579),s(3362),s(62953);var i=s(40445),a=s(67576);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(){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())}}return(0,i.Cg)([(0,a.MZ)({attribute:!1})],t.prototype,"hass",void 0),t}},56342:function(e,t,s){s.a(e,async function(e,i){try{s.r(t),s.d(t,{HuiEnergyDateSelectionCard:function(){return g}});s(3362),s(62953);var a=s(40445),o=s(5124),n=s(67576),r=(s(76776),s(784)),h=s(73887),l=s(38114),c=e([h,l]);[h,l]=c.then?(await c)():c;let d,p,_=e=>e;class g 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,l.s8)(e.collection_key),this._config=e}shouldUpdate(e){return(0,r.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(0,o.qy)(d||(d=_` <ha-card> <div class="card-content"> <hui-energy-period-selector .hass="${0}" .collectionKey="${0}" .verticalOpeningDirection="${0}" .openingDirection="${0}" .allowCompare="${0}"></hui-energy-period-selector> </div> </ha-card> `),this.hass,this._config.collection_key,e,t,!this._config.disable_compare)}}g.styles=(0,o.AH)(p||(p=_`ha-card{height:100%;display:flex;flex-direction:column;justify-content:center}`)),(0,a.Cg)([(0,n.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,a.Cg)([(0,n.wk)()],g.prototype,"_config",void 0),g=(0,a.Cg)([(0,n.EM)("hui-energy-date-selection-card")],g),i()}catch(d){i(d)}})},73887:function(e,t,s){s.a(e,async function(e,t){try{var i=s(69235),a=(s(3362),s(62953),s(40445)),o=s(80605),n=s(35932),r=s(73983),h=s(29224),l=s(35660),c=s(21828),d=s(36307),p=s(52640),_=s(69137),g=s(6946),u=s(55144),f=s(40600),v=s(78016),b=s(31810),y=s(87950),m=s(5124),w=s(67576),k=s(6412),D=s(22786),C=s(91069),$=s(46223),x=s(380),O=s(72487),z=s(63091),M=s(57237),P=s(9899),L=s(58987),q=s(18350),H=s(29823),S=(s(70947),s(54276),s(65829)),A=(s(67094),s(38114)),E=s(54706),V=e([i,L,q,H,S,O,x,$,A,C]);[i,L,q,H,S,O,x,$,A,C]=V.then?(await V)():V;let Z,T,R,B,U,W,I,K,N,F,j,G,Y,J,Q,X=e=>e;const ee="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",te="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",se="M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z",ie="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z",ae="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",oe="M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z",ne="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",re=["today","yesterday","this_week","this_month","this_quarter","this_year","now-7d","now-30d","now-365d","now-12m"];class he extends((0,E.E)(m.WF)){hassSubscribe(){return[(0,A.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,P.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){var t,s;super.willUpdate(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={},re.forEach(e=>{this._ranges[this.hass.localize(`ui.components.date-range-picker.ranges.${e}`)]=(0,$.b)(this.hass.locale,this.hass.config,e)}))}render(){if(!this.hass||!this._startDate)return m.s6;const e=this._simpleRange(this._startDate,this._endDate,this.hass.locale,this.hass.config),t=new Date,s=0!==(0,C.EO)(t,this._startDate,o.n,this.hass.locale,this.hass.config),i=this._endDate&&0!==(0,C.EO)(this._endDate,this._startDate,o.n,this.hass.locale,this.hass.config),a="year"!==e&&(s||i),n=[{path:"rtl"===z.G.document.dir?ie:se,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.previous"),action:()=>this._pickPrevious()},{path:"rtl"===z.G.document.dir?se:ie,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.next"),action:()=>this._pickNext()},{path:ne,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.now"),alwaysCollapse:!0,hidden:!this.narrow,action:()=>this._pickNow()},{path:this._compare?te:ee,disabled:!this.allowCompare,alwaysCollapse:!0,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.compare"),action:()=>this._toggleCompare()},{path:oe,alwaysCollapse:!0,label:this.hass.localize("ui.panel.lovelace.components.energy_period_selector.download_data"),action:()=>(0,A.h_)(this.hass,this.collectionKey)}];return(0,m.qy)(Z||(Z=X` <div class="${0}"> <div class="backdrop"></div> <div class="content"> <section class="date-picker-icon"> <ha-date-range-picker .startDate="${0}" .endDate="${0}" .ranges="${0}" @value-changed="${0}" @preset-selected="${0}" @toggle="${0}" minimal backdrop .popoverPlacement="${0}"></ha-date-range-picker> </section> <section class="date-range" @click="${0}"> <ha-ripple></ha-ripple> <div class="header-title"> ${0} </div> ${0} <ha-spinner class="${0}" size="small"></ha-spinner> </section> <section class="date-actions"> <div class="overflow"> ${0} ${0} ${0} </div> </section> </div> </div> `),(0,k.H)({row:!0,"datepicker-open":this._datepickerOpen}),this._startDate,this._endDate||new Date,this._ranges,this._dateRangeChanged,this._presetSelected,this._handleDatepickerToggle,this._getDatePickerPlacement(this.verticalOpeningDirection,this.openingDirection),this._openDatePicker,"year"===e?(0,m.qy)(T||(T=X`${0}`),(0,O.Pm)(this._startDate,this.hass.locale,this.hass.config)):(0,m.qy)(R||(R=X`${0}`),"12month"===e||"months"===e||"quarter"===e?(0,m.qy)(B||(B=X`${0}–${0}`),(0,O.c2)(this._startDate,this.hass.locale,this.hass.config),(0,O.c2)(this._endDate||new Date,this.hass.locale,this.hass.config)):(0,m.qy)(U||(U=X`${0}`),"month"===e?(0,m.qy)(W||(W=X`${0}`),(0,O.Wq)(this._startDate,this.hass.locale,this.hass.config)):"day"===e?(0,m.qy)(I||(I=X`${0}`),(0,O.sl)(this._startDate,this.hass.locale,this.hass.config)):(0,m.qy)(K||(K=X`${0}–${0}`),(0,O.sl)(this._startDate,this.hass.locale,this.hass.config),(0,O.sl)(this._endDate||new Date,this.hass.locale,this.hass.config)))),a?(0,m.qy)(N||(N=X`<div class="header-subtitle"> ${0}${0} </div>`),(0,O.Pm)(this._startDate,this.hass.locale,this.hass.config),i?(0,m.qy)(F||(F=X`–${0}`),(0,O.Pm)(this._endDate||new Date,this.hass.locale,this.hass.config)):""):m.s6,(0,k.H)({"loading-indicator":!0,"is-loading":this._loading}),this.narrow?m.s6:(0,m.qy)(j||(j=X`<ha-button appearance="filled" size="small" @click="${0}"> ${0} </ha-button>`),this._pickNow,this.hass.localize("ui.panel.lovelace.components.energy_period_selector.now")),n.map(e=>this._collapseButtons||e.alwaysCollapse?m.s6:(0,m.qy)(G||(G=X`<ha-icon-button @click="${0}" .label="${0}" .path="${0}" ?disabled="${0}"></ha-icon-button>`),e.action,e.label,e.path,e.disabled)),this._collapseButtons||n.some(e=>e.alwaysCollapse)?(0,m.qy)(Y||(Y=X`<ha-dropdown @wa-show="${0}" @click="${0}"> <ha-icon-button .label="${0}" .path="${0}" slot="trigger"></ha-icon-button> ${0} </ha-dropdown>`),this._handleIconOverflowMenuOpened,M.d,this.hass.localize("ui.common.overflow_menu"),ae,n.map(e=>!this._collapseButtons&&!e.alwaysCollapse||e.hidden?m.s6:(0,m.qy)(J||(J=X`<ha-dropdown-item ?disabled="${0}" @click="${0}"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> ${0} </ha-dropdown-item>`),e.disabled,e.disabled?void 0:e.action,e.path,e.label))):m.s6)}get _datePicker(){var e;return null!==(e=this.shadowRoot.querySelector("ha-date-range-picker"))&&void 0!==e?e:void 0}_handleIconOverflowMenuOpened(e){e.stopPropagation()}_openDatePicker(e){const t=this._datePicker;t&&t.open(),e.stopPropagation()}_updateCollectionPeriod(){const e=(0,A.tb)(this.hass,{key:this.collectionKey});e.setPeriod(this._startDate,this._endDate),e.refresh(),this._scheduleLoadingIndicator()}_dateRangeChanged(e){this._startDate=(0,C.ol)(e.detail.value.startDate,n.o,this.hass.locale,this.hass.config),this._endDate=(0,C.ol)(e.detail.value.endDate,r.D,this.hass.locale,this.hass.config),this._updateCollectionPeriod()}_presetSelected(e){localStorage.setItem(`energy-default-period-_${this.collectionKey||"energy"}`,re[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,$.b)(this.hass.locale,this.hass.config,"this_month");else if("quarter"===e)[this._startDate,this._endDate]=(0,$.b)(this.hass.locale,this.hass.config,"this_quarter");else if("year"===e)[this._startDate,this._endDate]=(0,$.b)(this.hass.locale,this.hass.config,"this_year");else if("12month"===e)[this._startDate,this._endDate]=(0,$.b)(this.hass.locale,this.hass.config,"now-12m");else if("months"===e){const e=(0,C.EO)(this._endDate,this._startDate,h.U,this.hass.locale,this.hass.config);this._startDate=(0,C.ol)((0,C.ol)(t,l.w,this.hass.locale,this.hass.config),c.a,this.hass.locale,this.hass.config,e),this._endDate=(0,C.ol)(t,d.p,this.hass.locale,this.hass.config)}else{const e=(0,x.P)(this.hass.locale),s=(0,C.ol)(this._endDate,p.k,this.hass.locale,this.hass.config,{weekStartsOn:e}),i=(0,C.ol)(this._endDate,_.$,this.hass.locale,this.hass.config,{weekStartsOn:e});if(this._startDate.getTime()===s.getTime()&&this._endDate.getTime()===i.getTime())[this._startDate,this._endDate]=(0,$.b)(this.hass.locale,this.hass.config,"this_week");else{const s=(0,C.EO)(this._endDate,this._startDate,g.c,this.hass.locale,this.hass.config);this._startDate=(0,C.ol)((0,C.ol)(t,u.e,this.hass.locale,this.hass.config,s),n.o,this.hass.locale,this.hass.config,{weekStartsOn:e}),this._endDate=(0,C.ol)(t,r.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,C.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,f.o)()}_handleDatepickerToggle(e){this._datepickerOpen=e.detail.open}_toggleCompare(){this._compare=!this._compare;const e=(0,A.tb)(this.hass,{key:this.collectionKey});e.setCompare(this._compare?A.lh.PREVIOUS:A.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,D.A)((e,t,s,i)=>0===(0,g.c)(t,e)?"day":(0,C.xo)(e,v.e,s,i)&&(0,C.xo)(t,b.c,s,i)?0===(0,C.EO)(t,e,y.W,s,i)?"month":2===(0,C.EO)(t,e,y.W,s,i)&&e.getMonth()%3==0?"quarter":11===(0,C.EO)(t,e,y.W,s,i)?0===(0,C.EO)(t,e,o.n,s,i)?"year":"12month":"months":"other"),this._getDatePickerPlacement=(0,D.A)((e,t)=>{const s="up"===e?"top":"bottom";if("center"===t||"inline"===t)return s;return`${s}-${"left"===t?"end":"start"}`})}}he.styles=(0,m.AH)(Q||(Q=X`: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,a.Cg)([(0,w.MZ)({attribute:!1})],he.prototype,"hass",void 0),(0,a.Cg)([(0,w.MZ)({attribute:"collection-key"})],he.prototype,"collectionKey",void 0),(0,a.Cg)([(0,w.MZ)({type:Boolean,reflect:!0})],he.prototype,"narrow",void 0),(0,a.Cg)([(0,w.MZ)({type:Boolean,reflect:!0})],he.prototype,"fixed",void 0),(0,a.Cg)([(0,w.MZ)({type:Boolean,attribute:"allow-compare"})],he.prototype,"allowCompare",void 0),(0,a.Cg)([(0,w.MZ)({attribute:"vertical-opening-direction"})],he.prototype,"verticalOpeningDirection",void 0),(0,a.Cg)([(0,w.MZ)({attribute:"opening-direction"})],he.prototype,"openingDirection",void 0),(0,a.Cg)([(0,w.wk)()],he.prototype,"_datepickerOpen",void 0),(0,a.Cg)([(0,w.wk)()],he.prototype,"_startDate",void 0),(0,a.Cg)([(0,w.wk)()],he.prototype,"_endDate",void 0),(0,a.Cg)([(0,w.wk)()],he.prototype,"_ranges",void 0),(0,a.Cg)([(0,w.wk)()],he.prototype,"_compare",void 0),(0,a.Cg)([(0,w.wk)()],he.prototype,"_collapseButtons",void 0),(0,a.Cg)([(0,w.wk)()],he.prototype,"_loading",void 0),he=(0,a.Cg)([(0,w.EM)("hui-energy-period-selector")],he),t()}catch(Z){t(Z)}})},56434:function(e,t,s){s.d(t,{e:function(){return a}});var i=s(81977);function a(e,t,s){return(0,i.P)(e,12*t,s)}},80605:function(e,t,s){s.d(t,{n:function(){return a}});s(62953);var i=s(74816);function a(e,t,s){const[a,o]=(0,i.x)(null==s?void 0:s.in,e,t);return a.getFullYear()-o.getFullYear()}},40600:function(e,t,s){s.d(t,{o:function(){return a}});var i=s(73983);function a(e){return(0,i.D)(Date.now(),e)}}}]);