iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 14.7 kB
JavaScript
export const __rspack_esm_id=51448;export const __rspack_esm_ids=[51448];export const __webpack_modules__={28732(t,s,e){var i=e(62826),a=e(27686),o=e(7731),n=e(5124),r=e(22441);class l extends a.J{renderRipple(){return this.noninteractive?"":super.renderRipple()}static get styles(){return[o.R,n.AH`:host{padding-left:var(--mdc-list-side-padding-left,var(--mdc-list-side-padding,20px));padding-inline-start:var(--mdc-list-side-padding-left,var(--mdc-list-side-padding,20px));padding-right:var(--mdc-list-side-padding-right,var(--mdc-list-side-padding,20px));padding-inline-end:var(--mdc-list-side-padding-right,var(--mdc-list-side-padding,20px))}:host([graphic=avatar]:not([twoLine])),:host([graphic=icon]:not([twoLine])){height:48px}span.material-icons:first-of-type{margin-inline-start:0px!important;margin-inline-end:var(--mdc-list-item-graphic-margin,16px)!important;direction:var(--direction)!important}span.material-icons:last-of-type{margin-inline-start:auto!important;margin-inline-end:0px!important;direction:var(--direction)!important}.mdc-deprecated-list-item__meta{display:var(--mdc-list-item-meta-display);align-items:center;flex-shrink:0}:host([graphic=icon]:not([twoline])) .mdc-deprecated-list-item__graphic{margin-inline-end:var(--mdc-list-item-graphic-margin,20px)!important}:host([multiline-secondary]){height:auto}:host([multiline-secondary]) .mdc-deprecated-list-item__text{padding:8px 0}:host([multiline-secondary]) .mdc-deprecated-list-item__secondary-text{text-overflow:initial;white-space:normal;overflow:auto;display:inline-block;margin-top:10px}:host([multiline-secondary]) .mdc-deprecated-list-item__primary-text{margin-top:10px}:host([multiline-secondary]) .mdc-deprecated-list-item__secondary-text::before{display:none}:host([multiline-secondary]) .mdc-deprecated-list-item__primary-text::before{display:none}:host([disabled]){color:var(--disabled-text-color)}:host([noninteractive]){pointer-events:unset}`,"rtl"===document.dir?n.AH`span.material-icons:first-of-type,span.material-icons:last-of-type{direction:rtl!important;--direction:rtl}`:n.AH``]}}l=(0,i.Cg)([(0,r.EM)("ha-list-item")],l)},31157(t,s,e){e.a(t,async function(t,i){try{e.r(s),e.d(s,{HaNumberSelector:()=>d});var a=e(62826),o=e(5124),n=e(22441),r=e(1087),l=(e(3449),e(70759)),h=e(91485),c=t([l,h]);[l,h]=c.then?(await c)():c;class d extends o.WF{reportValidity(){return this._input?.reportValidity()??!0}willUpdate(t){t.has("value")&&(""!==this._valueStr&&this.value===Number(this._valueStr)||(this._valueStr=null==this.value||isNaN(this.value)?"":this.value.toString()))}render(){const t="box"===this.selector.number?.mode||void 0===this.selector.number?.min||void 0===this.selector.number?.max;let s;if(!t&&(s=this.selector.number.step??1,"any"===s)){s=1;const t=(this.selector.number.max-this.selector.number.min)/100;for(;s>t;)s/=10}const e=this.selector.number?.translation_key;let i=this.selector.number?.unit_of_measurement;return t&&i&&this.localizeValue&&e&&(i=this.localizeValue(`${e}.unit_of_measurement.${i}`)||i),o.qy` ${this.label&&!t?o.qy`${this.label}${this.required?"*":""}`:o.s6} <div class="input"> ${t?o.s6:o.qy` <ha-slider labeled .min="${this.selector.number.min}" .max="${this.selector.number.max}" .value="${this.value}" .step="${s}" .disabled="${this.disabled}" .required="${this.required}" ="${this._handleSliderChange}" .withMarkers="${this.selector.number?.slider_ticks||!1}"> </ha-slider> `} <ha-input .inputMode="${"any"===this.selector.number?.step||(this.selector.number?.step??1)%1!=0?"decimal":"numeric"}" .label="${t?this.label:void 0}" .placeholder="${void 0!==this.placeholder?this.placeholder.toString():""}" class="${t?"single":""}" .min="${this.selector.number?.min}" .max="${this.selector.number?.max}" .value="${this._valueStr??""}" .step="${this.selector.number?.step??1}" .hint="${t?this.helper:void 0}" .disabled="${this.disabled}" .required="${this.required}" type="number" autoValidate .withoutSpinButtons="${!t}" ="${this._handleInputChange}"> ${i?o.qy`<span slot="end">${i}</span>`:o.s6} </ha-input> </div> ${!t&&this.helper?o.qy`<ha-input-helper-text .disabled="${this.disabled}">${this.helper}</ha-input-helper-text>`:o.s6} `}_handleInputChange(t){t.stopPropagation(),this._valueStr=t.target.value;const s=""===t.target.value||isNaN(t.target.value)?void 0:Number(t.target.value);this.value!==s&&(0,r.r)(this,"value-changed",{value:s})}_handleSliderChange(t){t.stopPropagation();const s=Number(t.target.value);this.value!==s&&(0,r.r)(this,"value-changed",{value:s})}constructor(...t){super(...t),this.required=!0,this.disabled=!1,this._valueStr=""}}d.styles=o.AH`.input{display:flex;justify-content:space-between;align-items:center;direction:ltr}ha-slider{flex:1;margin-right:16px;margin-inline-end:16px;margin-inline-start:0}ha-input::part(wa-input){width:40px}ha-input.single{flex:1}`,(0,a.Cg)([(0,n.MZ)({attribute:!1})],d.prototype,"selector",void 0),(0,a.Cg)([(0,n.MZ)({type:Number})],d.prototype,"value",void 0),(0,a.Cg)([(0,n.MZ)({type:Number})],d.prototype,"placeholder",void 0),(0,a.Cg)([(0,n.MZ)()],d.prototype,"label",void 0),(0,a.Cg)([(0,n.MZ)()],d.prototype,"helper",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],d.prototype,"localizeValue",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],d.prototype,"required",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean})],d.prototype,"disabled",void 0),(0,a.Cg)([(0,n.P)("ha-input",!0)],d.prototype,"_input",void 0),d=(0,a.Cg)([(0,n.EM)("ha-selector-number")],d),i()}catch(t){i(t)}})},19691(t,s,e){e.a(t,async function(t,i){try{e.r(s),e.d(s,{DialogStatisticsFixUnsupportedUnitMetadata:()=>x});e(44114),e(18111),e(7588);var a=e(62826),o=e(31569),n=e(5124),r=e(22441),l=e(22786),h=e(95747),c=e(1087),d=e(65829),u=(e(93444),e(72554)),p=e(18350),m=e(52763),_=(e(43661),e(28732),e(39045)),g=e(31157),v=(e(67094),e(23528)),b=e(65063),f=e(14503),y=e(81619),$=t([d,u,p,m,_,g,h]);[d,u,p,m,_,g,h]=$.then?(await $)():$;class x extends n.WF{showDialog(t){this._params=t,this._open=!0;const s=new Date;s.setMinutes(s.getMinutes()-s.getMinutes()%5,0),this._moment=(0,o.s)(s),this._fetchStats();const e=this.hass.entities[t.statistic.statistic_id];this._precision=Math.max(e?.display_precision??0,2)}closeDialog(){this._open=!1}_dialogClosed(){this._open=!1,this._params=void 0,this._moment=void 0,this._stats5min=void 0,this._statsHour=void 0,this._origAmount=void 0,this._amount=void 0,this._chosenStat=void 0,this._busy=!1,(0,c.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._params)return n.s6;let t,s;return this._chosenStat?(t=this._renderAdjustStat(),s=n.qy` <ha-button slot="secondaryAction" .disabled="${this._busy}" ="${this._clearChosenStatistic}" appearance="plain"> ${this.hass.localize("ui.common.back")}</ha-button> <ha-button slot="primaryAction" .disabled="${this._busy}" ="${this._fixIssue}"> ${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.adjust")}</ha-button> `):(t=this._renderPickStatistic(),s=n.qy` <ha-button slot="secondaryAction" appearance="plain" ="${this._fetchOutliers}"> ${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.outliers")} </ha-button> <ha-button slot="primaryAction" data-dialog="close"> ${this.hass.localize("ui.common.close")} </ha-button> `),n.qy` <ha-dialog .open="${this._open}" header-title="${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.title")}" ="${this._dialogClosed}"> ${t} <ha-dialog-footer slot="footer">${s}</ha-dialog-footer> </ha-dialog> `}shouldUpdate(t){if(1!==t.size||!t.has("hass"))return!0;const s=t.get("hass");return!s||s.localize!==this.hass.localize}_renderPickStatistic(){let t;if(this._stats5min&&this._statsHour)if(this._statsHour.length<1&&this._stats5min.length<1)t=n.qy`<p> ${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.no_statistics_found")} </p>`;else{const s=this._stats5min.length>=1?this._stats5min:this._statsHour,e=(0,v.JE)(this.hass,this._params.statistic.statistic_id,this._params.statistic),i=[];for(const t of s){const s=10**this._precision,a=Math.round(t.change*s)/s;i.push(n.qy` <ha-list-item twoline hasMeta .stat="${t}" ="${this._setChosenStatistic}"> <span>${a} ${e}</span> <span slot="secondary"> ${(0,h.r6)(new Date(t.start),this.hass.locale,this.hass.config)} </span> <ha-icon-next slot="meta"></ha-icon-next> </ha-list-item> `)}t=n.qy`${i}`}else t=n.qy`<ha-spinner></ha-spinner>`;return n.qy` <div class="text-content"> ${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.info_text_1")} </div> <div class="text-content"> <b>${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.statistic")}</b> ${this._params.statistic.statistic_id} </div> <ha-selector-datetime .label="${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.pick_a_time")}" .hass="${this.hass}" .selector="${this._dateTimeSelector}" .value="${this._moment}" -changed="${this._dateTimeSelectorChanged}"></ha-selector-datetime> <div class="stat-list">${t}</div> `}_clearChosenStatistic(){this._chosenStat=void 0}_setChosenStatistic(t){const s=t.currentTarget.stat,e=10**this._precision,i=Math.round(s.change*e)/e;this._chosenStat=s,this._origAmount=i,this._amount=i}_dateTimeSelectorChanged(t){this._moment=t.detail.value,this._fetchStats()}_renderAdjustStat(){const t=(0,v.JE)(this.hass,this._params.statistic.statistic_id,this._params.statistic);return n.qy` <div class="text-content"> <b>${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.statistic")}</b> ${this._params.statistic.statistic_id} </div> <div class="table-row"> <span>${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.start")}</span> <span>${(0,h.r6)(new Date(this._chosenStat.start),this.hass.locale,this.hass.config)}</span> </div> <div class="table-row"> <span>${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.end")}</span> <span>${(0,h.r6)(new Date(this._chosenStat.end),this.hass.locale,this.hass.config)}</span> </div> <ha-selector-number .label="${this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.new_value")}" .hass="${this.hass}" .selector="${this._amountSelector(t||void 0,this._precision)}" .value="${this._amount}" .disabled="${this._busy}" -changed="${this._amountChanged}"></ha-selector-number> `}_amountChanged(t){this._amount=t.detail.value}async _fetchStats(){this._stats5min=void 0,this._statsHour=void 0;const t=this._params.statistic.statistic_id,s=new Date(this._moment.replace(" ","T")),e=new Date(s.getTime());e.setTime(e.getTime()-72e5);const i=new Date(s.getTime());i.setTime(i.getTime()+108e5);const a=await(0,v.sz)(this.hass,e,i,[t],"hour");if(this._statsHour=t in a?a[t].slice(0,5):[],0===this._statsHour.length)return void(this._stats5min=[]);const o=new Date(s.getTime());o.setTime(o.getTime()-6e5);const n=new Date(s.getTime());n.setTime(n.getTime()+9e5);const r=await(0,v.sz)(this.hass,o,n,[t],"5minute");this._stats5min=t in r?r[t].slice(0,5):[]}async _fetchOutliers(){this._stats5min=void 0,this._statsHour=void 0;const t=this._params.statistic.statistic_id,s=new Date(0),e=new Date,i=await(0,v.sz)(this.hass,s,e,[t],"hour"),a=t in i?i[t]:[];if(0===a.length)return;const o=await(0,v.sz)(this.hass,s,e,[t],"5minute"),n=t in o?o[t]:[];n.shift();const r=[];a.forEach(t=>{r.push({hour:t,fiveMin:[]})});const l={hour:null,fiveMin:[]};let h=0;n.forEach(t=>{let s=!1;for(;h<r.length;h++){const e=r[h].hour;if(e&&t.start>=e.start&&t.end<=e.end){r[h].fiveMin.push(t),s=!0;break}}s||l.fiveMin.push(t)}),r.push(l);let c=[],d=0;const u=t=>{const s=Math.abs(t.change??0);(c.length<10||s>d)&&(c.push(t),c=c.sort((t,s)=>Math.abs(s.change??0)-Math.abs(t.change??0)),c=c.slice(0,10),d=c[c.length-1].change??0)};r.forEach(t=>{12!==t.fiveMin.length&&t.hour?u(t.hour):t.fiveMin.forEach(t=>{u(t)})}),this._statsHour=c,this._stats5min=[]}async _fixIssue(){const t=(0,v.JE)(this.hass,this._params.statistic.statistic_id,this._params.statistic);this._busy=!0;try{await(0,v.Uf)(this.hass,this._params.statistic.statistic_id,this._chosenStat.start,this._amount-this._origAmount,t||null)}catch(t){return this._busy=!1,void(0,b.showAlertDialog)(this,{text:this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.error_sum_adjusted",{message:t.message||t})})}(0,y.P)(this,{message:this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.sum_adjusted")}),this.closeDialog()}static get styles(){return[f.RF,f.nA,n.AH`.text-content,ha-selector-datetime,ha-selector-number{margin-bottom:var(--ha-space-5)}ha-list-item{margin:0 -24px;--mdc-list-side-padding:24px}.table-row{display:flex;justify-content:space-between;margin-bottom:var(--ha-space-5)}.stat-list{margin-top:var(--ha-space-2);min-height:360px;display:flex;flex-direction:column}.stat-list ha-spinner{margin:0 auto}`]}constructor(...t){super(...t),this._open=!1,this._busy=!1,this._dateTimeSelector={datetime:{}},this._precision=2,this._amountSelector=(0,l.A)((t,s)=>({number:{step:10**-s,unit_of_measurement:t,mode:"box"}}))}}(0,a.Cg)([(0,r.MZ)({attribute:!1})],x.prototype,"hass",void 0),(0,a.Cg)([(0,r.wk)()],x.prototype,"_params",void 0),(0,a.Cg)([(0,r.wk)()],x.prototype,"_open",void 0),(0,a.Cg)([(0,r.wk)()],x.prototype,"_busy",void 0),(0,a.Cg)([(0,r.wk)()],x.prototype,"_moment",void 0),(0,a.Cg)([(0,r.wk)()],x.prototype,"_stats5min",void 0),(0,a.Cg)([(0,r.wk)()],x.prototype,"_statsHour",void 0),(0,a.Cg)([(0,r.wk)()],x.prototype,"_chosenStat",void 0),(0,a.Cg)([(0,r.wk)()],x.prototype,"_amount",void 0),x=(0,a.Cg)([(0,r.EM)("dialog-statistics-adjust-sum")],x),i()}catch(t){i(t)}})},43332(t,s,e){function i(t,s){return(t<0?"-":"")+Math.abs(t).toString().padStart(s,"0")}e.d(s,{F:()=>i})},31569(t,s,e){e.d(s,{s:()=>n});var i=e(43332),a=e(38864),o=e(83504);function n(t,s){const e=(0,o.a)(t,s?.in);if(!(0,a.f)(e))throw new RangeError("Invalid time value");const n=s?.format??"extended",r=s?.representation??"complete";let l="";const h="extended"===n?"-":"",c="extended"===n?":":"";if("time"!==r){const t=(0,i.F)(e.getDate(),2),s=(0,i.F)(e.getMonth()+1,2);l=`${(0,i.F)(e.getFullYear(),4)}${h}${s}${h}${t}`}if("date"!==r){l=`${l}${""===l?"":" "}${(0,i.F)(e.getHours(),2)}${c}${(0,i.F)(e.getMinutes(),2)}${c}${(0,i.F)(e.getSeconds(),2)}`}return l}},38864(t,s,e){function i(t){return t instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)}e.d(s,{f:()=>o});var a=e(83504);function o(t){return!(!i(t)&&"number"!=typeof t||isNaN(+(0,a.a)(t)))}}};