UNPKG

iobroker.lovelace

Version:

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

5 lines 17.5 kB
export const __webpack_ids__=["87593"];export const __webpack_modules__={57982:function(e,t,i){i.a(e,(async function(e,o){try{i.d(t,{t:()=>n});var a=i(46467),r=i(33570),s=e([a,r]);function n(e,t,i,o){const s=o/60/24,n=new Date(e);if(s>88)return 0===n.getMonth()?`{bold|${(0,a.NC)(n,t,i)}}`:(0,a.Nh)(n,t,i);if(s>35)return 1===n.getDate()?`{bold|${(0,a.ud)(n,t,i)}}`:(0,a.ud)(n,t,i);if(s>7){const e=(0,a.ud)(n,t,i);return 1===n.getDate()?`{bold|${e}}`:e}return s>2?(0,a.U8)(n,t,i):o&&o<5?(0,r.Vu)(n,t,i):0===n.getHours()&&0===n.getMinutes()&&0===n.getSeconds()?`{bold|${(0,a.ud)(n,t,i)}}`:(0,r.mr)(n,t,i)}[a,r]=s.then?(await s)():s,o()}catch(l){o(l)}}))},25179:function(e,t,i){i.a(e,(async function(e,o){try{i.d(t,{Q:()=>C});var a=i(44249),r=i(72621),s=(i(92745),i(9359),i(56475),i(1331),i(31526),i(70104),i(48136),i(92519),i(42179),i(89256),i(24931),i(88463),i(57449),i(19814),i(60738)),n=i(18672),l=i(5376),d=i(57243),c=i(15093),h=i(35359),u=i(69634),p=i(50875),y=i(36522),g=i(62201),m=i(30635),v=i(94134),f=(i(23334),i(57982)),k=i(95262),x=(i(60370),e([f]));f=(x.then?(await x)():x)[0];const _="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",b="M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z",w="M12,4C14.1,4 16.1,4.8 17.6,6.3C20.7,9.4 20.7,14.5 17.6,17.6C15.8,19.5 13.3,20.2 10.9,19.9L11.4,17.9C13.1,18.1 14.9,17.5 16.2,16.2C18.5,13.9 18.5,10.1 16.2,7.7C15.1,6.6 13.5,6 12,6V10.6L7,5.6L12,0.6V4M6.3,17.6C3.7,15 3.3,11 5.1,7.9L6.6,9.4C5.5,11.6 5.9,14.4 7.8,16.2C8.3,16.7 8.9,17.1 9.6,17.4L9,19.4C8,19 7.1,18.4 6.3,17.6Z",C=3e5,L=10,Z=6,S=300;(0,a.Z)([(0,c.Mo)("ha-chart-base")],(function(e,t){class o extends t{constructor(...t){super(...t),e(this)}}return{F:o,d:[{kind:"field",key:"chart",value:void 0},{kind:"field",decorators:[(0,c.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,c.Cb)({attribute:!1})],key:"data",value:()=>[]},{kind:"field",decorators:[(0,c.Cb)({attribute:!1})],key:"options",value:void 0},{kind:"field",decorators:[(0,c.Cb)({type:String})],key:"height",value:void 0},{kind:"field",decorators:[(0,c.Cb)({attribute:"expand-legend",type:Boolean})],key:"expandLegend",value:void 0},{kind:"field",decorators:[(0,c.Cb)({attribute:!1})],key:"extraComponents",value:void 0},{kind:"field",decorators:[(0,c.SB)(),(0,s.F_)({context:m.LW,subscribe:!0})],key:"_themes",value:void 0},{kind:"field",decorators:[(0,c.SB)()],key:"_isZoomed",value:()=>!1},{kind:"field",decorators:[(0,c.SB)()],key:"_zoomRatio",value:()=>1},{kind:"field",decorators:[(0,c.SB)()],key:"_minutesDifference",value:()=>1440},{kind:"field",decorators:[(0,c.SB)()],key:"_hiddenDatasets",value:()=>new Set},{kind:"field",key:"_modifierPressed",value:()=>!1},{kind:"field",key:"_isTouchDevice",value:()=>"ontouchstart"in window},{kind:"field",key:"_lastTapTime",value:void 0},{kind:"field",key:"_resizeController",value(){return new n.Z(this,{callback:()=>this.chart?.resize()})}},{kind:"field",key:"_loading",value:()=>!1},{kind:"field",key:"_reducedMotion",value:()=>!1},{kind:"field",key:"_listeners",value:()=>[]},{kind:"field",key:"_originalZrFlush",value:void 0},{kind:"method",key:"disconnectedCallback",value:function(){for((0,r.Z)(o,"disconnectedCallback",this,3)([]);this._listeners.length;)this._listeners.pop()();this.chart?.dispose(),this.chart=void 0,this._originalZrFlush=void 0}},{kind:"method",key:"connectedCallback",value:function(){(0,r.Z)(o,"connectedCallback",this,3)([]),this.hasUpdated&&this._setupChart(),this._listeners.push((0,g.K)("(prefers-reduced-motion)",(e=>{this._reducedMotion!==e&&(this._reducedMotion=e,this._setChartOptions({animation:!this._reducedMotion}))})));const e=e=>{!this._modifierPressed&&(v.V&&"Meta"===e.key||!v.V&&"Control"===e.key)&&(this._modifierPressed=!0,this.options?.dataZoom||this._setChartOptions({dataZoom:this._getDataZoomConfig()}),this.chart?.dispatchAction({type:"takeGlobalCursor",key:"dataZoomSelect",dataZoomSelectActive:!0}))},t=e=>{this._modifierPressed&&(v.V&&"Meta"===e.key||!v.V&&"Control"===e.key)&&(this._modifierPressed=!1,this.options?.dataZoom||this._setChartOptions({dataZoom:this._getDataZoomConfig()}),this.chart?.dispatchAction({type:"takeGlobalCursor",key:"dataZoomSelect",dataZoomSelectActive:!1}))};window.addEventListener("keydown",e),window.addEventListener("keyup",t),this._listeners.push((()=>window.removeEventListener("keydown",e)),(()=>window.removeEventListener("keyup",t)))}},{kind:"method",key:"firstUpdated",value:function(){this._setupChart()}},{kind:"method",key:"willUpdate",value:function(e){if(!this.chart)return;if(e.has("_themes"))return void this._setupChart();let t={};(e.has("data")||e.has("_hiddenDatasets"))&&(t.series=this._getSeries()),e.has("options")?t={...t,...this._createOptions()}:this._isTouchDevice&&e.has("_isZoomed")&&(t.dataZoom=this._getDataZoomConfig()),Object.keys(t).length>0&&this._setChartOptions(t)}},{kind:"method",key:"render",value:function(){return d.dy` <div class="container ${(0,h.$)({"has-height":!!this.height})}" style="${(0,u.V)({height:this.height})}"> <div class="chart-container" style="${(0,u.V)({height:this.height?void 0:`${this._getDefaultHeight()}px`})}"> <div class="chart"></div> </div> ${this._renderLegend()} ${this._isZoomed?d.dy`<ha-icon-button class="zoom-reset" .path="${w}" @click="${this._handleZoomReset}" title="${this.hass.localize("ui.components.history_charts.zoom_reset")}"></ha-icon-button>`:d.Ld} </div> `}},{kind:"method",key:"_renderLegend",value:function(){if(!this.options?.legend||!this.data)return d.Ld;const e=(0,k.r)(this.options.legend)[0];if(!e.show)return d.Ld;const t=(0,k.r)(this.data),i=e.data||t.filter((e=>e.data?.length&&(e.id||e.name))).map((e=>e.name??e.id))||[],o=window.matchMedia("all and (max-width: 450px), all and (max-height: 500px)").matches?Z:L;return d.dy`<div class="${(0,h.$)({"chart-legend":!0,"multiple-items":i.length>1})}"> <ul> ${i.map(((e,i)=>{if(!this.expandLegend&&i>=o)return d.Ld;const a=t.find((t=>t.id===e||t.name===e)),r=a?.color,s=a?.itemStyle?.borderColor;return d.dy`<li .name="${e}" @click="${this._legendClick}" class="${(0,h.$)({hidden:this._hiddenDatasets.has(e)})}" .title="${e}"> <div class="bullet" style="${(0,u.V)({backgroundColor:r,borderColor:s||r})}"></div> <div class="label">${e}</div> </li>`}))} ${i.length>o?d.dy`<li> <ha-assist-chip @click="${this._toggleExpandedLegend}" filled label="${this.expandLegend?this.hass.localize("ui.components.history_charts.collapse_legend"):`${this.hass.localize("ui.components.history_charts.expand_legend")} (${i.length-o})`}"> <ha-svg-icon slot="trailing-icon" .path="${this.expandLegend?b:_}"></ha-svg-icon> </ha-assist-chip> </li>`:d.Ld} </ul> </div>`}},{kind:"field",key:"_formatTimeLabel",value(){return e=>(0,f.t)(e,this.hass.locale,this.hass.config,this._minutesDifference*this._zoomRatio)}},{kind:"method",key:"_setupChart",value:async function(){if(this._loading)return;const e=this.renderRoot.querySelector(".chart");this._loading=!0;try{this.chart&&this.chart.dispose();const t=(await Promise.all([i.e("83895"),i.e("50382"),i.e("77535"),i.e("57848")]).then(i.bind(i,85803))).default;this.extraComponents?.length&&t.use(this.extraComponents),t.registerTheme("custom",this._createTheme()),this.chart=t.init(e,"custom"),this.chart.on("datazoom",(e=>{const{start:t,end:i}=e.batch?.[0]??e;this._isZoomed=0!==t||100!==i,this._zoomRatio=(i-t)/100})),this.chart.on("click",(e=>{(0,y.B)(this,"chart-click",e)})),this.chart.getZr().on("dblclick",this._handleClickZoom),this._isTouchDevice&&this.chart.getZr().on("click",(e=>{e.zrByTouch&&(this._lastTapTime&&Date.now()-this._lastTapTime<S?this._handleClickZoom(e):this._lastTapTime=Date.now())}));const o=(0,k.r)(this.options?.legend||[])[0];Object.entries(o?.selected||{}).forEach((([e,t])=>{!1===t&&this._hiddenDatasets.add(e)})),this.chart.setOption({...this._createOptions(),series:this._getSeries()})}finally{this._loading=!1}}},{kind:"method",key:"_getDataZoomConfig",value:function(){const e=this.options?.xAxis?.[0]??this.options?.xAxis,t=this.options?.yAxis?.[0]??this.options?.yAxis;if("value"!==e?.type||"category"!==t?.type)return{id:"dataZoom",type:"inside",orient:"horizontal",filterMode:"none",moveOnMouseMove:!this._isTouchDevice||this._isZoomed,preventDefaultMouseMove:!this._isTouchDevice||this._isZoomed,zoomLock:!this._isTouchDevice&&!this._modifierPressed}}},{kind:"method",key:"_createOptions",value:function(){let e=this.options?.xAxis;e&&(e=Array.isArray(e)?e:[e],e=e.map((e=>{if("time"!==e.type||!1===e.show)return e;e.max&&e.min&&(this._minutesDifference=(0,l.X)(e.max,e.min));const t=this._minutesDifference/60/24;let i;return t&&(i=t>=89?24192e5:t>2?864e5:void 0),{axisLine:{show:!1},splitLine:{show:!0},...e,axisLabel:{formatter:this._formatTimeLabel,rich:{bold:{fontWeight:"bold"}},hideOverlap:!0,...e.axisLabel},minInterval:i}})));const t={animation:!this._reducedMotion,darkMode:this._themes.darkMode??!1,aria:{show:!0},dataZoom:this._getDataZoomConfig(),toolbox:{top:1/0,left:1/0,feature:{dataZoom:{show:!0,yAxisIndex:!1,filterMode:"none"}},iconStyle:{opacity:0}},...this.options,legend:{show:!1},xAxis:e};if(window.matchMedia("all and (max-width: 450px), all and (max-height: 500px)").matches&&t.tooltip){const e=Array.isArray(t.tooltip)?t.tooltip:[t.tooltip];e.forEach((e=>{e.confine=!0,e.appendTo=void 0,e.triggerOn="click"})),t.tooltip=e}return t}},{kind:"method",key:"_createTheme",value:function(){const e=getComputedStyle(this);return{color:(0,p.o9)(e),backgroundColor:"transparent",textStyle:{color:e.getPropertyValue("--primary-text-color"),fontFamily:"Roboto, Noto, sans-serif"},title:{textStyle:{color:e.getPropertyValue("--primary-text-color")},subtextStyle:{color:e.getPropertyValue("--secondary-text-color")}},line:{lineStyle:{width:1.5},symbolSize:1,symbol:"circle",smooth:!1},bar:{itemStyle:{barBorderWidth:1.5}},categoryAxis:{axisLine:{show:!1},axisTick:{show:!1},axisLabel:{show:!0,color:e.getPropertyValue("--primary-text-color")},splitLine:{show:!1,lineStyle:{color:e.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[e.getPropertyValue("--divider-color")+"3F",e.getPropertyValue("--divider-color")+"7F"]}}},valueAxis:{axisLine:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:e.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[e.getPropertyValue("--divider-color")+"3F",e.getPropertyValue("--divider-color")+"7F"]}}},logAxis:{axisLine:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:e.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[e.getPropertyValue("--divider-color")+"3F",e.getPropertyValue("--divider-color")+"7F"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:e.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:e.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[e.getPropertyValue("--divider-color")+"3F",e.getPropertyValue("--divider-color")+"7F"]}}},legend:{textStyle:{color:e.getPropertyValue("--primary-text-color")},inactiveColor:e.getPropertyValue("--disabled-text-color"),pageIconColor:e.getPropertyValue("--primary-text-color"),pageIconInactiveColor:e.getPropertyValue("--disabled-text-color"),pageTextStyle:{color:e.getPropertyValue("--secondary-text-color")}},tooltip:{backgroundColor:e.getPropertyValue("--card-background-color"),borderColor:e.getPropertyValue("--divider-color"),textStyle:{color:e.getPropertyValue("--primary-text-color"),fontSize:12},axisPointer:{lineStyle:{color:e.getPropertyValue("--info-color")},crossStyle:{color:e.getPropertyValue("--info-color")}}},timeline:{}}}},{kind:"method",key:"_getSeries",value:function(){return Array.isArray(this.data)?this.data.filter((e=>!this._hiddenDatasets.has(String(e.name??e.id)))):this.data}},{kind:"method",key:"_getDefaultHeight",value:function(){return Math.max(this.clientWidth/2,200)}},{kind:"method",key:"_setChartOptions",value:function(e){if(!this.chart)return;if(!this._originalZrFlush){if((0,k.r)(this.data).reduce(((e,t)=>e+(t.data||[]).length),0)>1e4){const e=this.chart.getZr();this._originalZrFlush=e.flush,e.flush=()=>{setTimeout((()=>{this._originalZrFlush?.call(e)}),5)}}}const t=e.series?["series"]:[];this.chart.setOption(e,{replaceMerge:t})}},{kind:"field",key:"_handleClickZoom",value(){return e=>{if(!this.chart)return;const t=this._isZoomed?[0,100]:[e.offsetX/this.chart.getWidth()*100-15,e.offsetX/this.chart.getWidth()*100+15];this.chart.dispatchAction({type:"dataZoom",start:t[0],end:t[1]})}}},{kind:"method",key:"_handleZoomReset",value:function(){this.chart?.dispatchAction({type:"dataZoom",start:0,end:100})}},{kind:"method",key:"_legendClick",value:function(e){if(!this.chart)return;const t=e.currentTarget?.name;this._hiddenDatasets.has(t)?(this._hiddenDatasets.delete(t),(0,y.B)(this,"dataset-unhidden",{name:t})):(this._hiddenDatasets.add(t),(0,y.B)(this,"dataset-hidden",{name:t})),this.requestUpdate("_hiddenDatasets")}},{kind:"method",key:"_toggleExpandedLegend",value:function(){this.expandLegend=!this.expandLegend,setTimeout((()=>{this.chart?.resize()}))}},{kind:"field",static:!0,key:"styles",value:()=>d.iv`:host{display:block;position:relative;letter-spacing:normal}.container{display:flex;flex-direction:column;position:relative}.container.has-height{max-height:var(--chart-max-height,350px)}.chart-container{width:100%;max-height:var(--chart-max-height,350px)}.has-height .chart-container{flex:1}.chart{height:100%;width:100%}.zoom-reset{position:absolute;top:16px;right:4px;background:var(--card-background-color);border-radius:4px;--mdc-icon-button-size:32px;color:var(--primary-color);border:1px solid var(--divider-color)}.chart-legend{max-height:60%;overflow-y:auto;padding:12px 0 0;font-size:12px;color:var(--primary-text-color)}.chart-legend ul{margin:0;padding:0;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px}.chart-legend li{height:24px;cursor:pointer;display:inline-flex;align-items:center;padding:0 2px;box-sizing:border-box;overflow:hidden}.chart-legend.multiple-items li{max-width:220px}.chart-legend .hidden{color:var(--secondary-text-color)}.chart-legend .label{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.chart-legend .bullet{border-width:1px;border-style:solid;border-radius:50%;display:block;height:16px;width:16px;margin-right:4px;flex-shrink:0;box-sizing:border-box;margin-inline-end:4px;margin-inline-start:initial;direction:var(--direction)}.chart-legend .hidden .bullet{border-color:var(--secondary-text-color)!important;background-color:transparent!important}ha-assist-chip{height:100%;--_label-text-weight:500;--_leading-space:8px;--_trailing-space:8px;--_icon-label-space:4px}`}]}}),d.oi);o()}catch(e){o(e)}}))},60370:function(e,t,i){var o=i(44249),a=i(72621),r=i(10445),s=i(57243),n=i(15093);(0,o.Z)([(0,n.Mo)("ha-assist-chip")],(function(e,t){class i extends t{constructor(...t){super(...t),e(this)}}return{F:i,d:[{kind:"field",decorators:[(0,n.Cb)({type:Boolean,reflect:!0})],key:"filled",value:()=>!1},{kind:"field",decorators:[(0,n.Cb)({type:Boolean})],key:"active",value:()=>!1},{kind:"field",static:!0,key:"styles",value(){return[...(0,a.Z)(i,"styles",this),s.iv`:host{--md-sys-color-primary:var(--primary-text-color);--md-sys-color-on-surface:var(--primary-text-color);--md-assist-chip-container-shape:var( --ha-assist-chip-container-shape, 16px );--md-assist-chip-outline-color:var(--outline-color);--md-assist-chip-label-text-weight:400}.filled{display:flex;pointer-events:none;border-radius:inherit;inset:0;position:absolute;background-color:var(--ha-assist-chip-filled-container-color)}::slotted([slot=icon]),::slotted([slot=trailing-icon]){display:flex;--mdc-icon-size:var(--md-input-chip-icon-size, 18px);font-size:var(--_label-text-size)!important}.trailing.icon ::slotted(*),.trailing.icon svg{margin-inline-end:unset;margin-inline-start:var(--_icon-label-space)}::before{background:var(--ha-assist-chip-container-color,transparent);opacity:var(--ha-assist-chip-container-opacity, 1)}:where(.active)::before{background:var(--ha-assist-chip-active-container-color);opacity:var(--ha-assist-chip-active-container-opacity)}.label{font-family:Roboto,sans-serif}`]}},{kind:"method",key:"renderOutline",value:function(){return this.filled?s.dy`<span class="filled"></span>`:(0,a.Z)(i,"renderOutline",this,3)([])}},{kind:"method",key:"getContainerClasses",value:function(){return{...(0,a.Z)(i,"getContainerClasses",this,3)([]),active:this.active}}},{kind:"method",key:"renderPrimaryContent",value:function(){return s.dy` <span class="leading icon" aria-hidden="true"> ${this.renderLeadingIcon()} </span> <span class="label">${this.label}</span> <span class="touch"></span> <span class="trailing leading icon" aria-hidden="true"> ${this.renderTrailingIcon()} </span> `}},{kind:"method",key:"renderTrailingIcon",value:function(){return s.dy`<slot name="trailing-icon"></slot>`}}]}}),r.X)},94134:function(e,t,i){i.d(t,{V:()=>o});const o=/Mac/i.test(navigator.userAgent)}}; //# sourceMappingURL=87593.a965ecdfca268a46.js.map