UNPKG

iobroker.lovelace

Version:

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

1 lines 18.4 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[51448],{28732:function(t,i,e){var s=e(40445),a=e(27686),n=e(7731),o=e(5124),l=e(67576);let r,h,d,u=t=>t;class c extends a.J{renderRipple(){return this.noninteractive?"":super.renderRipple()}static get styles(){return[n.R,(0,o.AH)(r||(r=u`: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?(0,o.AH)(h||(h=u`span.material-icons:first-of-type,span.material-icons:last-of-type{direction:rtl!important;--direction:rtl}`)):(0,o.AH)(d||(d=u``))]}}c=(0,s.Cg)([(0,l.EM)("ha-list-item")],c)},39045:function(t,i,e){e.a(t,async function(t,s){try{e.r(i),e.d(i,{HaDateTimeSelector:function(){return v}});e(62953);var a=e(40445),n=e(5124),o=e(67576),l=e(1087),r=e(19463),h=e(50286),d=(e(3449),t([r,h]));[r,h]=d.then?(await d)():d;let u,c,p,m=t=>t;class v extends n.WF{reportValidity(){return this._dateInput.reportValidity()&&this._timeInput.reportValidity()}render(){const t="string"==typeof this.value?this.value.split(" "):void 0;return(0,n.qy)(u||(u=m` <div class="input"> <ha-date-input .label="${0}" .locale="${0}" .disabled="${0}" .required="${0}" .value="${0}" @value-changed="${0}"> </ha-date-input> <ha-time-input enable-second .value="${0}" .locale="${0}" .disabled="${0}" .required="${0}" @value-changed="${0}"></ha-time-input> </div> ${0} `),this.label,this.hass.locale,this.disabled,this.required,null==t?void 0:t[0],this._valueChanged,(null==t?void 0:t[1])||"00:00:00",this.hass.locale,this.disabled,this.required,this._valueChanged,this.helper?(0,n.qy)(c||(c=m`<ha-input-helper-text .disabled="${0}">${0}</ha-input-helper-text>`),this.disabled,this.helper):"")}_valueChanged(t){t.stopPropagation(),this._dateInput.value&&this._timeInput.value&&(0,l.r)(this,"value-changed",{value:`${this._dateInput.value} ${this._timeInput.value}`})}constructor(...t){super(...t),this.disabled=!1,this.required=!0}}v.styles=(0,n.AH)(p||(p=m`.input{display:flex;align-items:center;flex-direction:row}ha-date-input{min-width:150px;margin-right:4px;margin-inline-end:4px;margin-inline-start:initial}`)),(0,a.Cg)([(0,o.MZ)({attribute:!1})],v.prototype,"hass",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],v.prototype,"selector",void 0),(0,a.Cg)([(0,o.MZ)()],v.prototype,"value",void 0),(0,a.Cg)([(0,o.MZ)()],v.prototype,"label",void 0),(0,a.Cg)([(0,o.MZ)()],v.prototype,"helper",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean,reflect:!0})],v.prototype,"disabled",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],v.prototype,"required",void 0),(0,a.Cg)([(0,o.P)("ha-date-input")],v.prototype,"_dateInput",void 0),(0,a.Cg)([(0,o.P)("ha-time-input")],v.prototype,"_timeInput",void 0),v=(0,a.Cg)([(0,o.EM)("ha-selector-datetime")],v),s()}catch(u){s(u)}})},31157:function(t,i,e){e.a(t,async function(t,s){try{e.r(i),e.d(i,{HaNumberSelector:function(){return f}});e(62953);var a=e(40445),n=e(5124),o=e(67576),l=e(1087),r=(e(3449),e(70759)),h=e(91485),d=t([r,h]);[r,h]=d.then?(await d)():d;let u,c,p,m,v,_,g=t=>t;class f extends n.WF{reportValidity(){var t,i;return null===(t=null===(i=this._input)||void 0===i?void 0:i.reportValidity())||void 0===t||t}willUpdate(t){t.has("value")&&(""!==this._valueStr&&this.value===Number(this._valueStr)||(this._valueStr=null==this.value||isNaN(this.value)?"":this.value.toString()))}render(){var t,i,e,s,a,o,l,r,h,d,_,f,b,y;const $="box"===(null===(t=this.selector.number)||void 0===t?void 0:t.mode)||void 0===(null===(i=this.selector.number)||void 0===i?void 0:i.min)||void 0===(null===(e=this.selector.number)||void 0===e?void 0:e.max);let x;var w;if(!$&&(x=null!==(w=this.selector.number.step)&&void 0!==w?w:1,"any"===x)){x=1;const t=(this.selector.number.max-this.selector.number.min)/100;for(;x>t;)x/=10}const C=null===(s=this.selector.number)||void 0===s?void 0:s.translation_key;let S=null===(a=this.selector.number)||void 0===a?void 0:a.unit_of_measurement;return $&&S&&this.localizeValue&&C&&(S=this.localizeValue(`${C}.unit_of_measurement.${S}`)||S),(0,n.qy)(u||(u=g` ${0} <div class="input"> ${0} <ha-input .inputMode="${0}" .label="${0}" .placeholder="${0}" class="${0}" .min="${0}" .max="${0}" .value="${0}" .step="${0}" .hint="${0}" .disabled="${0}" .required="${0}" type="number" autoValidate .withoutSpinButtons="${0}" @input="${0}"> ${0} </ha-input> </div> ${0} `),this.label&&!$?(0,n.qy)(c||(c=g`${0}${0}`),this.label,this.required?"*":""):n.s6,$?n.s6:(0,n.qy)(p||(p=g` <ha-slider labeled .min="${0}" .max="${0}" .value="${0}" .step="${0}" .disabled="${0}" .required="${0}" @change="${0}" .withMarkers="${0}"> </ha-slider> `),this.selector.number.min,this.selector.number.max,this.value,x,this.disabled,this.required,this._handleSliderChange,(null===(o=this.selector.number)||void 0===o?void 0:o.slider_ticks)||!1),"any"===(null===(l=this.selector.number)||void 0===l?void 0:l.step)||(null!==(r=null===(h=this.selector.number)||void 0===h?void 0:h.step)&&void 0!==r?r:1)%1!=0?"decimal":"numeric",$?this.label:void 0,void 0!==this.placeholder?this.placeholder.toString():"",$?"single":"",null===(d=this.selector.number)||void 0===d?void 0:d.min,null===(_=this.selector.number)||void 0===_?void 0:_.max,null!==(f=this._valueStr)&&void 0!==f?f:"",null!==(b=null===(y=this.selector.number)||void 0===y?void 0:y.step)&&void 0!==b?b:1,$?this.helper:void 0,this.disabled,this.required,!$,this._handleInputChange,S?(0,n.qy)(m||(m=g`<span slot="end">${0}</span>`),S):n.s6,!$&&this.helper?(0,n.qy)(v||(v=g`<ha-input-helper-text .disabled="${0}">${0}</ha-input-helper-text>`),this.disabled,this.helper):n.s6)}_handleInputChange(t){t.stopPropagation(),this._valueStr=t.target.value;const i=""===t.target.value||isNaN(t.target.value)?void 0:Number(t.target.value);this.value!==i&&(0,l.r)(this,"value-changed",{value:i})}_handleSliderChange(t){t.stopPropagation();const i=Number(t.target.value);this.value!==i&&(0,l.r)(this,"value-changed",{value:i})}constructor(...t){super(...t),this.required=!0,this.disabled=!1,this._valueStr=""}}f.styles=(0,n.AH)(_||(_=g`.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,o.MZ)({attribute:!1})],f.prototype,"selector",void 0),(0,a.Cg)([(0,o.MZ)({type:Number})],f.prototype,"value",void 0),(0,a.Cg)([(0,o.MZ)({type:Number})],f.prototype,"placeholder",void 0),(0,a.Cg)([(0,o.MZ)()],f.prototype,"label",void 0),(0,a.Cg)([(0,o.MZ)()],f.prototype,"helper",void 0),(0,a.Cg)([(0,o.MZ)({attribute:!1})],f.prototype,"localizeValue",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],f.prototype,"required",void 0),(0,a.Cg)([(0,o.MZ)({type:Boolean})],f.prototype,"disabled",void 0),(0,a.Cg)([(0,o.P)("ha-input",!0)],f.prototype,"_input",void 0),f=(0,a.Cg)([(0,o.EM)("ha-selector-number")],f),s()}catch(u){s(u)}})},19691:function(t,i,e){e.a(t,async function(t,s){try{e.r(i),e.d(i,{DialogStatisticsFixUnsupportedUnitMetadata:function(){return T}});e(44114),e(26910),e(18111),e(7588),e(3362),e(27495),e(25440),e(62953);var a=e(40445),n=e(31569),o=e(5124),l=e(67576),r=e(22786),h=e(95747),d=e(1087),u=e(65829),c=(e(93444),e(72554)),p=e(18350),m=e(52763),v=(e(43661),e(28732),e(39045)),_=e(31157),g=(e(67094),e(23528)),f=e(65063),b=e(14503),y=e(81619),$=t([u,c,p,m,v,_,h,g]);[u,c,p,m,v,_,h,g]=$.then?(await $)():$;let x,w,C,S,M,q,k,z,j,D,H=t=>t;class T extends o.WF{showDialog(t){var i;this._params=t,this._open=!0;const e=new Date;e.setMinutes(e.getMinutes()-e.getMinutes()%5,0),this._moment=(0,n.s)(e),this._fetchStats();const s=this.hass.entities[t.statistic.statistic_id];this._precision=Math.max(null!==(i=null==s?void 0:s.display_precision)&&void 0!==i?i: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,d.r)(this,"dialog-closed",{dialog:this.localName})}render(){if(!this._params)return o.s6;let t,i;return this._chosenStat?(t=this._renderAdjustStat(),i=(0,o.qy)(w||(w=H` <ha-button slot="secondaryAction" .disabled="${0}" @click="${0}" appearance="plain"> ${0}</ha-button> <ha-button slot="primaryAction" .disabled="${0}" @click="${0}"> ${0}</ha-button> `),this._busy,this._clearChosenStatistic,this.hass.localize("ui.common.back"),this._busy,this._fixIssue,this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.adjust"))):(t=this._renderPickStatistic(),i=(0,o.qy)(x||(x=H` <ha-button slot="secondaryAction" appearance="plain" @click="${0}"> ${0} </ha-button> <ha-button slot="primaryAction" data-dialog="close"> ${0} </ha-button> `),this._fetchOutliers,this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.outliers"),this.hass.localize("ui.common.close"))),(0,o.qy)(C||(C=H` <ha-dialog .open="${0}" header-title="${0}" @closed="${0}"> ${0} <ha-dialog-footer slot="footer">${0}</ha-dialog-footer> </ha-dialog> `),this._open,this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.title"),this._dialogClosed,t,i)}shouldUpdate(t){if(1!==t.size||!t.has("hass"))return!0;const i=t.get("hass");return!i||i.localize!==this.hass.localize}_renderPickStatistic(){let t;if(this._stats5min&&this._statsHour)if(this._statsHour.length<1&&this._stats5min.length<1)t=(0,o.qy)(M||(M=H`<p> ${0} </p>`),this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.no_statistics_found"));else{const i=this._stats5min.length>=1?this._stats5min:this._statsHour,e=(0,g.JE)(this.hass,this._params.statistic.statistic_id,this._params.statistic),s=[];for(const t of i){const i=10**this._precision,a=Math.round(t.change*i)/i;s.push((0,o.qy)(q||(q=H` <ha-list-item twoline hasMeta .stat="${0}" @click="${0}"> <span>${0} ${0}</span> <span slot="secondary"> ${0} </span> <ha-icon-next slot="meta"></ha-icon-next> </ha-list-item> `),t,this._setChosenStatistic,a,e,(0,h.r6)(new Date(t.start),this.hass.locale,this.hass.config)))}t=(0,o.qy)(k||(k=H`${0}`),s)}else t=(0,o.qy)(S||(S=H`<ha-spinner></ha-spinner>`));return(0,o.qy)(z||(z=H` <div class="text-content"> ${0} </div> <div class="text-content"> <b>${0}</b> ${0} </div> <ha-selector-datetime .label="${0}" .hass="${0}" .selector="${0}" .value="${0}" @value-changed="${0}"></ha-selector-datetime> <div class="stat-list">${0}</div> `),this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.info_text_1"),this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.statistic"),this._params.statistic.statistic_id,this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.pick_a_time"),this.hass,this._dateTimeSelector,this._moment,this._dateTimeSelectorChanged,t)}_clearChosenStatistic(){this._chosenStat=void 0}_setChosenStatistic(t){const i=t.currentTarget.stat,e=10**this._precision,s=Math.round(i.change*e)/e;this._chosenStat=i,this._origAmount=s,this._amount=s}_dateTimeSelectorChanged(t){this._moment=t.detail.value,this._fetchStats()}_renderAdjustStat(){const t=(0,g.JE)(this.hass,this._params.statistic.statistic_id,this._params.statistic);return(0,o.qy)(j||(j=H` <div class="text-content"> <b>${0}</b> ${0} </div> <div class="table-row"> <span>${0}</span> <span>${0}</span> </div> <div class="table-row"> <span>${0}</span> <span>${0}</span> </div> <ha-selector-number .label="${0}" .hass="${0}" .selector="${0}" .value="${0}" .disabled="${0}" @value-changed="${0}"></ha-selector-number> `),this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.statistic"),this._params.statistic.statistic_id,this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.start"),(0,h.r6)(new Date(this._chosenStat.start),this.hass.locale,this.hass.config),this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.end"),(0,h.r6)(new Date(this._chosenStat.end),this.hass.locale,this.hass.config),this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.new_value"),this.hass,this._amountSelector(t||void 0,this._precision),this._amount,this._busy,this._amountChanged)}_amountChanged(t){this._amount=t.detail.value}async _fetchStats(){this._stats5min=void 0,this._statsHour=void 0;const t=this._params.statistic.statistic_id,i=new Date(this._moment.replace(" ","T")),e=new Date(i.getTime());e.setTime(e.getTime()-72e5);const s=new Date(i.getTime());s.setTime(s.getTime()+108e5);const a=await(0,g.sz)(this.hass,e,s,[t],"hour");if(this._statsHour=t in a?a[t].slice(0,5):[],0===this._statsHour.length)return void(this._stats5min=[]);const n=new Date(i.getTime());n.setTime(n.getTime()-6e5);const o=new Date(i.getTime());o.setTime(o.getTime()+9e5);const l=await(0,g.sz)(this.hass,n,o,[t],"5minute");this._stats5min=t in l?l[t].slice(0,5):[]}async _fetchOutliers(){this._stats5min=void 0,this._statsHour=void 0;const t=this._params.statistic.statistic_id,i=new Date(0),e=new Date,s=await(0,g.sz)(this.hass,i,e,[t],"hour"),a=t in s?s[t]:[];if(0===a.length)return;const n=await(0,g.sz)(this.hass,i,e,[t],"5minute"),o=t in n?n[t]:[];o.shift();const l=[];a.forEach(t=>{l.push({hour:t,fiveMin:[]})});const r={hour:null,fiveMin:[]};let h=0;o.forEach(t=>{let i=!1;for(;h<l.length;h++){const e=l[h].hour;if(e&&t.start>=e.start&&t.end<=e.end){l[h].fiveMin.push(t),i=!0;break}}i||r.fiveMin.push(t)}),l.push(r);let d=[],u=0;const c=t=>{var i;const e=Math.abs(null!==(i=t.change)&&void 0!==i?i:0);var s;(d.length<10||e>u)&&(d.push(t),d=d.sort((t,i)=>{var e,s;return Math.abs(null!==(e=i.change)&&void 0!==e?e:0)-Math.abs(null!==(s=t.change)&&void 0!==s?s:0)}),d=d.slice(0,10),u=null!==(s=d[d.length-1].change)&&void 0!==s?s:0)};l.forEach(t=>{12!==t.fiveMin.length&&t.hour?c(t.hour):t.fiveMin.forEach(t=>{c(t)})}),this._statsHour=d,this._stats5min=[]}async _fixIssue(){const t=(0,g.JE)(this.hass,this._params.statistic.statistic_id,this._params.statistic);this._busy=!0;try{await(0,g.Uf)(this.hass,this._params.statistic.statistic_id,this._chosenStat.start,this._amount-this._origAmount,t||null)}catch(i){return this._busy=!1,void(0,f.showAlertDialog)(this,{text:this.hass.localize("ui.panel.config.developer-tools.tabs.statistics.fix_issue.adjust_sum.error_sum_adjusted",{message:i.message||i})})}(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[b.RF,b.nA,(0,o.AH)(D||(D=H`.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,r.A)((t,i)=>({number:{step:10**-i,unit_of_measurement:t,mode:"box"}}))}}(0,a.Cg)([(0,l.MZ)({attribute:!1})],T.prototype,"hass",void 0),(0,a.Cg)([(0,l.wk)()],T.prototype,"_params",void 0),(0,a.Cg)([(0,l.wk)()],T.prototype,"_open",void 0),(0,a.Cg)([(0,l.wk)()],T.prototype,"_busy",void 0),(0,a.Cg)([(0,l.wk)()],T.prototype,"_moment",void 0),(0,a.Cg)([(0,l.wk)()],T.prototype,"_stats5min",void 0),(0,a.Cg)([(0,l.wk)()],T.prototype,"_statsHour",void 0),(0,a.Cg)([(0,l.wk)()],T.prototype,"_chosenStat",void 0),(0,a.Cg)([(0,l.wk)()],T.prototype,"_amount",void 0),T=(0,a.Cg)([(0,l.EM)("dialog-statistics-adjust-sum")],T),s()}catch(x){s(x)}})},43332:function(t,i,e){function s(t,i){return(t<0?"-":"")+Math.abs(t).toString().padStart(i,"0")}e.d(i,{F:function(){return s}})},31569:function(t,i,e){e.d(i,{s:function(){return o}});e(16280);var s=e(43332),a=e(38864),n=e(83504);function o(t,i){var e,o;const l=(0,n.a)(t,null==i?void 0:i.in);if(!(0,a.f)(l))throw new RangeError("Invalid time value");const r=null!==(e=null==i?void 0:i.format)&&void 0!==e?e:"extended",h=null!==(o=null==i?void 0:i.representation)&&void 0!==o?o:"complete";let d="";const u="extended"===r?"-":"",c="extended"===r?":":"";if("time"!==h){const t=(0,s.F)(l.getDate(),2),i=(0,s.F)(l.getMonth()+1,2);d=`${(0,s.F)(l.getFullYear(),4)}${u}${i}${u}${t}`}if("date"!==h){d=`${d}${""===d?"":" "}${(0,s.F)(l.getHours(),2)}${c}${(0,s.F)(l.getMinutes(),2)}${c}${(0,s.F)(l.getSeconds(),2)}`}return d}},38864:function(t,i,e){function s(t){return t instanceof Date||"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)}e.d(i,{f:function(){return n}});var a=e(83504);function n(t){return!(!s(t)&&"number"!=typeof t||isNaN(+(0,a.a)(t)))}}}]);