iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 25.7 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[45078],{78649:function(t,e,i){i.d(e,{n:function(){return a}});i(27495);const s=/^(\w+)\.(\w+)$/,a=t=>s.test(t)},82474:function(t,e,i){i.a(t,async function(t,e){try{i(13609),i(18111),i(20116),i(61701),i(3362),i(62953);var s=i(40445),a=i(5124),o=i(67576),n=i(22786),r=i(1087),l=i(74705),h=i(78649),c=i(53756),p=i(95350),d=i(24367),u=i(19711),_=(i(75064),i(38508)),g=(i(47680),i(67094),i(74281)),y=t([_,g]);[_,g]=y.then?(await y)():y;let m,v,b,C,$,f,w,x,O,T,j,k,M,z,E,I=t=>t;const q="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",Z="M11,13.5V21.5H3V13.5H11M12,2L17.5,11H6.5L12,2M17.5,13C20,13 22,15 22,17.5C22,20 20,22 17.5,22C15,22 13,20 13,17.5C13,15 15,13 17.5,13Z",B="___create-new-entity___";class L extends a.WF{willUpdate(t){var e;this._pendingEntityId&&t.has("hass")&&this.hass.states!==(null===(e=t.get("hass"))||void 0===e?void 0:e.states)&&this.hass.states[this._pendingEntityId]&&(this._setValue(this._pendingEntityId),this._pendingEntityId=void 0)}firstUpdated(t){super.firstUpdated(t),this.hass.loadBackendTranslation("title")}_findExtraOption(t){var e;return t?null===(e=this.extraOptions)||void 0===e?void 0:e.find(e=>e.id===t):void 0}_renderExtraOptionStart(t){const e=t.entity_id?this.hass.states[t.entity_id]:void 0;return e?(0,a.qy)(m||(m=I` <state-badge slot="start" .stateObj="${0}" .hass="${0}"></state-badge> `),e,this.hass):t.icon_path?(0,a.qy)(v||(v=I` <ha-svg-icon slot="start" .path="${0}" style="margin:0 4px"></ha-svg-icon> `),t.icon_path):t.icon?(0,a.qy)(b||(b=I`<ha-icon slot="start" .icon="${0}"></ha-icon>`),t.icon):a.s6}get _showEntityId(){var t;return this.showEntityId||(null===(t=this.hass.userData)||void 0===t?void 0:t.showEntityIdPicker)}_shouldHideClearIcon(){var t;return!(null===(t=this._findExtraOption(this.value))||void 0===t||!t.hide_clear)}render(){var t,e;const i=null!==(t=this.placeholder)&&void 0!==t?t:this.hass.localize("ui.components.entity.entity-picker.placeholder");return(0,a.qy)(C||(C=I` <ha-generic-picker .hass="${0}" .disabled="${0}" .autofocus="${0}" .allowCustomValue="${0}" .required="${0}" .label="${0}" .placeholder="${0}" .helper="${0}" .value="${0}" .searchLabel="${0}" .notFoundLabel="${0}" .rowRenderer="${0}" .getItems="${0}" .getAdditionalItems="${0}" .hideClearIcon="${0}" .searchFn="${0}" .valueRenderer="${0}" .searchKeys="${0}" use-top-label .addButtonLabel="${0}" .unknownItemText="${0}" -changed="${0}"> </ha-generic-picker> `),this.hass,this.disabled,this.autofocus,this.allowCustomEntity,this.required,this.label,i,this.helper,this.addButton?void 0:this.value,this.searchLabel,this._notFoundLabel,this._rowRenderer,this._getItems,this._getAdditionalItems,this.hideClearIcon||this._shouldHideClearIcon(),this._searchFn,this._valueRenderer,c.t,this.addButton?null!==(e=this.addButtonLabel)&&void 0!==e?e:this.hass.localize("ui.components.entity.entity-picker.add"):void 0,this.hass.localize("ui.components.entity.entity-picker.unknown"),this._valueChanged)}async open(){var t;await this.updateComplete,await(null===(t=this._picker)||void 0===t?void 0:t.open())}_valueChanged(t){t.stopPropagation();const e=t.detail.value;if(e){if(e.startsWith(B)){const t=e.substring(B.length);return void(0,u.$)(this,{domain:t,dialogClosedCallback:t=>{t.entityId&&(this.hass.states[t.entityId]?this._setValue(t.entityId):this._pendingEntityId=t.entityId)}})}((0,h.n)(e)||this._findExtraOption(e))&&this._setValue(e)}else this._setValue(void 0)}_setValue(t){this.value=t,(0,r.r)(this,"value-changed",{value:t}),(0,r.r)(this,"change")}constructor(...t){super(...t),this.autofocus=!1,this.disabled=!1,this.required=!1,this.showEntityId=!1,this.hideClearIcon=!1,this.addButton=!1,this._valueRenderer=t=>{const e=t||"",i=this._findExtraOption(e);if(i)return(0,a.qy)($||($=I` ${0} <span slot="headline">${0}</span> ${0} `),this._renderExtraOptionStart(i),i.primary,i.secondary?(0,a.qy)(f||(f=I`<span slot="supporting-text">${0}</span>`),i.secondary):a.s6);const s=this.hass.states[e];if(!s)return(0,a.qy)(w||(w=I` <ha-svg-icon slot="start" .path="${0}" style="margin:0 4px"></ha-svg-icon> <span slot="headline">${0}</span> `),Z,e);const{primary:o,secondary:n}=(0,l.Bj)(this.hass,s);return(0,a.qy)(x||(x=I` <state-badge .hass="${0}" .stateObj="${0}" slot="start"></state-badge> <span slot="headline">${0}</span> <span slot="supporting-text">${0}</span> `),this.hass,s,o,n)},this._rowRenderer=(t,e)=>{const i=this._showEntityId;return(0,a.qy)(O||(O=I` <ha-combo-box-item type="button" compact="compact" .borderTop="${0}"> ${0} <span slot="headline">${0}</span> ${0} ${0} ${0} </ha-combo-box-item> `),0!==e,t.icon_path?(0,a.qy)(T||(T=I` <ha-svg-icon slot="start" style="margin:0 4px" .path="${0}"></ha-svg-icon> `),t.icon_path):(0,a.qy)(j||(j=I` <state-badge slot="start" .stateObj="${0}" .hass="${0}"></state-badge> `),t.stateObj,this.hass),t.primary,t.secondary?(0,a.qy)(k||(k=I`<span slot="supporting-text">${0}</span>`),t.secondary):a.s6,t.stateObj&&i?(0,a.qy)(M||(M=I` <span slot="supporting-text" class="code"> ${0} </span> `),t.stateObj.entity_id):a.s6,t.domain_name&&!i?(0,a.qy)(z||(z=I` <div slot="trailing-supporting-text" class="domain"> ${0} </div> `),t.domain_name):a.s6)},this._getAdditionalItems=()=>this._getCreateItems(this.hass.localize,this.createDomains),this._getCreateItems=(0,n.A)((t,e)=>null!=e&&e.length?(this.hass.loadFragmentTranslation("config"),e.map(e=>{const i=t("ui.components.entity.entity-picker.create_helper",{domain:(0,d.z)(e)?t(`ui.panel.config.helpers.types.${e}`)||e:(0,p.p$)(t,e)});return{id:B+e,primary:i,secondary:t("ui.components.entity.entity-picker.new_entity"),icon_path:q}})):[]),this._getEntitiesMemoized=(0,n.A)(c.w),this._getItems=()=>{var t;const e=this._getEntitiesMemoized(this.hass,this.includeDomains,this.excludeDomains,this.entityFilter,this.includeDeviceClasses,this.includeUnitOfMeasurement,this.includeEntities,this.excludeEntities,this.value);if(null!==(t=this.extraOptions)&&void 0!==t&&t.length){return[...this.extraOptions.map(t=>Object.assign(Object.assign({},t),{},{stateObj:t.entity_id?this.hass.states[t.entity_id]:void 0})),...e]}return e},this._searchFn=(t,e)=>{const i=e.findIndex(e=>{var i;return(null===(i=e.stateObj)||void 0===i?void 0:i.entity_id)===t});if(-1===i)return e;const[s]=e.splice(i,1);return e.unshift(s),e},this._notFoundLabel=t=>this.hass.localize("ui.components.entity.entity-picker.no_match",{term:(0,a.qy)(E||(E=I`<b>‘${0}’</b>`),t)})}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],L.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],L.prototype,"autofocus",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],L.prototype,"disabled",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],L.prototype,"required",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"allow-custom-entity"})],L.prototype,"allowCustomEntity",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"show-entity-id"})],L.prototype,"showEntityId",void 0),(0,s.Cg)([(0,o.MZ)()],L.prototype,"label",void 0),(0,s.Cg)([(0,o.MZ)()],L.prototype,"value",void 0),(0,s.Cg)([(0,o.MZ)()],L.prototype,"helper",void 0),(0,s.Cg)([(0,o.MZ)()],L.prototype,"placeholder",void 0),(0,s.Cg)([(0,o.MZ)({type:String,attribute:"search-label"})],L.prototype,"searchLabel",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],L.prototype,"createDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-domains"})],L.prototype,"includeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-domains"})],L.prototype,"excludeDomains",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-device-classes"})],L.prototype,"includeDeviceClasses",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-unit-of-measurement"})],L.prototype,"includeUnitOfMeasurement",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"include-entities"})],L.prototype,"includeEntities",void 0),(0,s.Cg)([(0,o.MZ)({type:Array,attribute:"exclude-entities"})],L.prototype,"excludeEntities",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],L.prototype,"entityFilter",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],L.prototype,"extraOptions",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"hide-clear-icon",type:Boolean})],L.prototype,"hideClearIcon",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"add-button",type:Boolean})],L.prototype,"addButton",void 0),(0,s.Cg)([(0,o.MZ)({attribute:"add-button-label"})],L.prototype,"addButtonLabel",void 0),(0,s.Cg)([(0,o.P)("ha-generic-picker")],L.prototype,"_picker",void 0),(0,s.Cg)([(0,o.wk)()],L.prototype,"_pendingEntityId",void 0),L=(0,s.Cg)([(0,o.EM)("ha-entity-picker")],L),e()}catch(m){e(m)}})},53756:function(t,e,i){i.d(e,{t:function(){return l},w:function(){return h}});i(74423),i(18111),i(22489),i(61701),i(62953);var s=i(71727),a=i(74705),o=i(28978),n=i(15638),r=i(95350);const l=[{name:"search_labels.entityName",weight:10},{name:"search_labels.friendlyName",weight:8},{name:"search_labels.deviceName",weight:7},{name:"search_labels.areaName",weight:6},{name:"search_labels.domainName",weight:6},{name:"search_labels.entityId",weight:3}],h=(t,e,i,l,h,c,p,d,u,_="")=>{let g,y=Object.keys(t.states);return p&&(y=y.filter(t=>p.includes(t))),d&&(y=y.filter(t=>!d.includes(t))),e&&(y=y.filter(t=>e.includes((0,s.m)(t)))),i&&(y=y.filter(t=>!i.includes((0,s.m)(t)))),g=y.map(e=>{const i=t.states[e],l=(0,o.u)(i),[h,c,p]=(0,a.Cf)(i,[{type:"entity"},{type:"device"},{type:"area"}],t.entities,t.devices,t.areas,t.floors),d=(0,r.p$)(t.localize,(0,s.m)(e)),u=(0,n.qC)(t.language,t.translationMetadata.translations),g=h||c||e,y=[p,h?c:void 0].filter(Boolean).join(u?" ◂ ":" ▸ ");return{id:`${_}${e}`,primary:g,secondary:y,domain_name:d,sorting_label:[g,y].filter(Boolean).join("_"),search_labels:{entityName:h||null,deviceName:c||null,areaName:p||null,domainName:d||null,friendlyName:l||null,entityId:e},stateObj:i}}),h&&(g=g.filter(t=>{var e;return t.id===u||(null===(e=t.stateObj)||void 0===e?void 0:e.attributes.device_class)&&h.includes(t.stateObj.attributes.device_class)})),c&&(g=g.filter(t=>{var e;return t.id===u||(null===(e=t.stateObj)||void 0===e?void 0:e.attributes.unit_of_measurement)&&c.includes(t.stateObj.attributes.unit_of_measurement)})),l&&(g=g.filter(t=>t.id===u||t.stateObj&&l(t.stateObj))),g}},65941:function(t,e,i){i.a(t,async function(t,s){try{i.r(e),i.d(e,{DialogEnergyGridSettings:function(){return E}});i(44114),i(18111),i(7588),i(3362),i(62953);var a=i(40445),o=i(5124),n=i(67576),r=i(1087),l=i(82474),h=i(81423),c=i(18350),p=i(72554),d=(i(93444),i(64013),i(92677),i(91485)),u=i(38114),_=i(23528),g=i(64808),y=i(14503),m=i(66902),v=t([l,h,c,p,d,m,u,_]);[l,h,c,p,d,m,u,_]=v.then?(await v)():v;let b,C,$,f,w,x,O,T,j,k,M=t=>t;const z=["energy"];class E extends o.WF{async showDialog(t){var e,i,s,a,o,n,r,l,h,c,p,d,_;this._params=t,this._source=t.source?Object.assign({},t.source):(0,u.uh)(),this._powerType=(0,m.S9)(null===(e=t.source)||void 0===e?void 0:e.power_config,null===(i=t.source)||void 0===i?void 0:i.stat_rate),this._powerConfig=(0,m.us)(null===(s=t.source)||void 0===s?void 0:s.power_config,null===(a=t.source)||void 0===a?void 0:a.stat_rate),null!==(o=t.source)&&void 0!==o&&o.stat_cost?this._importCostType="stat":null!==(n=t.source)&&void 0!==n&&n.entity_energy_price?this._importCostType="entity":null!==(null===(r=t.source)||void 0===r?void 0:r.number_energy_price)&&void 0!==(null===(l=t.source)||void 0===l?void 0:l.number_energy_price)?this._importCostType="number":this._importCostType="no_cost",null!==(h=t.source)&&void 0!==h&&h.stat_compensation?this._exportCostType="stat":null!==(c=t.source)&&void 0!==c&&c.entity_energy_price_export?this._exportCostType="entity":null!==(null===(p=t.source)||void 0===p?void 0:p.number_energy_price_export)&&void 0!==(null===(d=t.source)||void 0===d?void 0:d.number_energy_price_export)?this._exportCostType="number":this._exportCostType="no_cost",this._energy_units=(await(0,g.j4)(this.hass,"energy")).units;const y=[];this._params.grid_sources.forEach(t=>{t.stat_energy_from&&y.push(t.stat_energy_from),t.stat_energy_to&&y.push(t.stat_energy_to)}),this._excludeList=y.filter(t=>{var e,i;return t!==(null===(e=this._source)||void 0===e?void 0:e.stat_energy_from)&&t!==(null===(i=this._source)||void 0===i?void 0:i.stat_energy_to)}),this._excludeListPower=(0,m.A_)(this._params.grid_sources,this._powerConfig,null===(_=t.source)||void 0===_?void 0:_.stat_rate),this._open=!0}closeDialog(){return this._open=!1,!0}_dialogClosed(){this._params=void 0,this._source=void 0,this._powerType="none",this._powerConfig={},this._importCostType="no_cost",this._exportCostType="no_cost",this._error=void 0,this._excludeList=void 0,this._excludeListPower=void 0,(0,r.r)(this,"dialog-closed",{dialog:this.localName})}render(){var t,e,i,s,a,n,r,l,h;if(!this._params||!this._source)return o.s6;const c=!!this._source.stat_energy_to,p=this._source.stat_energy_from&&(0,_.OQ)(this._source.stat_energy_from),d=this._source.stat_energy_to&&(0,_.OQ)(this._source.stat_energy_to);return(0,o.qy)(b||(b=M` <ha-dialog .open="${0}" header-title="${0}" prevent-scrim-close ="${0}"> ${0} <ha-statistic-picker .hass="${0}" .helpMissingEntityUrl="${0}" .includeUnitClass="${0}" .value="${0}" .label="${0}" .excludeStatistics="${0}" -changed="${0}" .helper="${0}" autofocus></ha-statistic-picker> <ha-statistic-picker .hass="${0}" .helpMissingEntityUrl="${0}" .includeUnitClass="${0}" .value="${0}" .label="${0}" .excludeStatistics="${0}" -changed="${0}" .helper="${0}"></ha-statistic-picker> <ha-input class="name" .label="${0}" type="text" .disabled="${0}" .value="${0}" .placeholder="${0}" ="${0}"> </ha-input> <p class="section-label"> ${0} </p> <p class="section-description"> ${0} </p> <ha-radio-group .value="${0}" name="importCostType" ="${0}"> <ha-radio-option value="no_cost"> ${0} </ha-radio-option> <ha-radio-option value="stat"> ${0} </ha-radio-option> <ha-radio-option value="entity" .disabled="${0}"> ${0} </ha-radio-option> <ha-radio-option value="number" .disabled="${0}"> ${0} </ha-radio-option> </ha-radio-group> ${0} ${0} ${0} ${0} <ha-energy-power-config .hass="${0}" .powerType="${0}" .powerConfig="${0}" .excludeList="${0}" .localizeBaseKey="${0}" -config-changed="${0}"></ha-energy-power-config> <ha-dialog-footer slot="footer"> <ha-button appearance="plain" ="${0}" slot="secondaryAction"> ${0} </ha-button> <ha-button ="${0}" .disabled="${0}" slot="primaryAction"> ${0} </ha-button> </ha-dialog-footer> </ha-dialog> `),this._open,this.hass.localize("ui.panel.config.energy.grid.dialog.header"),this._dialogClosed,this._error?(0,o.qy)(C||(C=M`<p class="error">${0}</p>`),this._error):o.s6,this.hass,u.X4,z,this._source.stat_energy_from,this.hass.localize("ui.panel.config.energy.grid.dialog.energy_from_grid"),[...this._excludeList||[],this._source.stat_energy_to].filter(t=>Boolean(t)),this._statisticFromChanged,this.hass.localize("ui.panel.config.energy.grid.dialog.energy_from_helper",{unit:(null===(t=this._energy_units)||void 0===t?void 0:t.join(", "))||""}),this.hass,u.X4,z,this._source.stat_energy_to,this.hass.localize("ui.panel.config.energy.grid.dialog.energy_to_grid"),[...this._excludeList||[],this._source.stat_energy_from].filter(t=>Boolean(t)),this._statisticToChanged,this.hass.localize("ui.panel.config.energy.grid.dialog.energy_to_helper",{unit:(null===(e=this._energy_units)||void 0===e?void 0:e.join(", "))||""}),this.hass.localize("ui.panel.config.energy.grid.dialog.display_name"),!(null!==(i=this._source)&&void 0!==i&&i.stat_energy_from||null!==(s=this._source)&&void 0!==s&&s.stat_energy_to),(null===(a=this._source)||void 0===a?void 0:a.name)||"",null!==(n=this._source)&&void 0!==n&&n.stat_energy_from?(0,_.$O)(this.hass,this._source.stat_energy_from,null===(r=this._params)||void 0===r||null===(r=r.statsMetadata)||void 0===r?void 0:r[this._source.stat_energy_from]):null!==(l=this._source)&&void 0!==l&&l.stat_energy_to?(0,_.$O)(this.hass,this._source.stat_energy_to,null===(h=this._params)||void 0===h||null===(h=h.statsMetadata)||void 0===h?void 0:h[this._source.stat_energy_to]):"",this._nameChanged,this.hass.localize("ui.panel.config.energy.grid.dialog.import_cost"),this.hass.localize("ui.panel.config.energy.grid.dialog.import_cost_para"),this._importCostType,this._handleImportCostTypeChanged,this.hass.localize("ui.panel.config.energy.grid.dialog.no_cost_tracking"),this.hass.localize("ui.panel.config.energy.grid.dialog.cost_stat"),p,this.hass.localize("ui.panel.config.energy.grid.dialog.cost_entity"),p,this.hass.localize("ui.panel.config.energy.grid.dialog.cost_number"),"stat"===this._importCostType?(0,o.qy)($||($=M` <ha-statistic-picker .hass="${0}" .value="${0}" .label="${0}" -changed="${0}"></ha-statistic-picker> `),this.hass,this._source.stat_cost,this.hass.localize("ui.panel.config.energy.grid.dialog.cost_stat_label"),this._statCostChanged):o.s6,"entity"===this._importCostType?(0,o.qy)(f||(f=M` <ha-entity-picker .hass="${0}" .value="${0}" .label="${0}" include-domains='["sensor", "input_number"]' -changed="${0}"></ha-entity-picker> `),this.hass,this._source.entity_energy_price,this.hass.localize("ui.panel.config.energy.grid.dialog.cost_entity_label"),this._entityCostChanged):o.s6,"number"===this._importCostType?(0,o.qy)(w||(w=M` <ha-input .value="${0}" .label="${0}" type="number" step="any" ="${0}"> <span slot="end">${0}/kWh</span> </ha-input> `),null!==this._source.number_energy_price?String(this._source.number_energy_price):"",this.hass.localize("ui.panel.config.energy.grid.dialog.cost_number_label"),this._numberCostChanged,this.hass.config.currency):o.s6,c?(0,o.qy)(x||(x=M` <p class="section-label"> ${0} </p> <p class="section-description"> ${0} </p> <ha-radio-group .value="${0}" name="exportCostType" ="${0}"> <ha-radio-option value="no_cost"> ${0} </ha-radio-option> <ha-radio-option value="stat"> ${0} </ha-radio-option> <ha-radio-option value="entity" .disabled="${0}"> ${0} </ha-radio-option> <ha-radio-option value="number" .disabled="${0}"> ${0} </ha-radio-option> </ha-radio-group> ${0} ${0} ${0} `),this.hass.localize("ui.panel.config.energy.grid.dialog.export_compensation"),this.hass.localize("ui.panel.config.energy.grid.dialog.export_compensation_para"),this._exportCostType,this._handleExportCostTypeChanged,this.hass.localize("ui.panel.config.energy.grid.dialog.no_compensation_tracking"),this.hass.localize("ui.panel.config.energy.grid.dialog.compensation_stat"),d,this.hass.localize("ui.panel.config.energy.grid.dialog.compensation_entity"),d,this.hass.localize("ui.panel.config.energy.grid.dialog.compensation_number"),"stat"===this._exportCostType?(0,o.qy)(O||(O=M` <ha-statistic-picker .hass="${0}" .value="${0}" .label="${0}" -changed="${0}"></ha-statistic-picker> `),this.hass,this._source.stat_compensation,this.hass.localize("ui.panel.config.energy.grid.dialog.compensation_stat_label"),this._statCompensationChanged):o.s6,"entity"===this._exportCostType?(0,o.qy)(T||(T=M` <ha-entity-picker .hass="${0}" .value="${0}" .label="${0}" include-domains='["sensor", "input_number"]' -changed="${0}"></ha-entity-picker> `),this.hass,this._source.entity_energy_price_export,this.hass.localize("ui.panel.config.energy.grid.dialog.compensation_entity_label"),this._entityCompensationChanged):o.s6,"number"===this._exportCostType?(0,o.qy)(j||(j=M` <ha-input .value="${0}" .label="${0}" type="number" step="any" ="${0}"> <span slot="end">${0}/kWh</span> </ha-input> `),null!==this._source.number_energy_price_export?String(this._source.number_energy_price_export):"",this.hass.localize("ui.panel.config.energy.grid.dialog.compensation_number_label"),this._numberCompensationChanged,this.hass.config.currency):o.s6):o.s6,this.hass,this._powerType,this._powerConfig,this._excludeListPower,"ui.panel.config.energy.grid.dialog",this._handlePowerConfigChanged,this.closeDialog,this.hass.localize("ui.common.cancel"),this._save,!this._isValid(),this.hass.localize("ui.common.save"))}_isValid(){var t,e;const i=!(null===(t=this._source)||void 0===t||!t.stat_energy_from),s=!(null===(e=this._source)||void 0===e||!e.stat_energy_to),a="none"!==this._powerType;return!!(i||s||a)&&!(a&&this._powerConfigEl&&!this._powerConfigEl.isValid())}async _updateMetadata(t){var e;if(t&&(0,_.OQ)(t)&&null!==(e=this._params)&&void 0!==e&&e.statsMetadata&&!(t in this._params.statsMetadata)){const[e]=await(0,_.Wr)(this.hass,[t]);e&&(this._params.statsMetadata[t]=e,this.requestUpdate("_params"))}}_statisticFromChanged(t){this._source=Object.assign(Object.assign({},this._source),{},{stat_energy_from:t.detail.value}),t.detail.value&&(0,_.OQ)(t.detail.value)&&("entity"===this._importCostType||"number"===this._importCostType)&&(this._importCostType="no_cost",this._source=Object.assign(Object.assign({},this._source),{},{entity_energy_price:null,number_energy_price:null})),this._updateMetadata(t.detail.value)}_statisticToChanged(t){this._source=Object.assign(Object.assign({},this._source),{},{stat_energy_to:t.detail.value||null}),t.detail.value?!(0,_.OQ)(t.detail.value)||"entity"!==this._exportCostType&&"number"!==this._exportCostType||(this._exportCostType="no_cost",this._source=Object.assign(Object.assign({},this._source),{},{entity_energy_price_export:null,number_energy_price_export:null})):(this._exportCostType="no_cost",this._source=Object.assign(Object.assign({},this._source),{},{stat_compensation:null,entity_energy_price_export:null,number_energy_price_export:null})),this._updateMetadata(t.detail.value)}_nameChanged(t){this._source=Object.assign(Object.assign({},this._source),{},{name:t.target.value}),this._source.name||delete this._source.name}_handleImportCostTypeChanged(t){this._importCostType=t.currentTarget.value,this._source=Object.assign(Object.assign({},this._source),{},{stat_cost:null,entity_energy_price:null,number_energy_price:null})}_handleExportCostTypeChanged(t){this._exportCostType=t.currentTarget.value,this._source=Object.assign(Object.assign({},this._source),{},{stat_compensation:null,entity_energy_price_export:null,number_energy_price_export:null})}_statCostChanged(t){this._source=Object.assign(Object.assign({},this._source),{},{stat_cost:t.detail.value||null})}_entityCostChanged(t){this._source=Object.assign(Object.assign({},this._source),{},{entity_energy_price:t.detail.value||null})}_numberCostChanged(t){const e=t.currentTarget,i=e.value?parseFloat(e.value):null;this._source=Object.assign(Object.assign({},this._source),{},{number_energy_price:i})}_statCompensationChanged(t){this._source=Object.assign(Object.assign({},this._source),{},{stat_compensation:t.detail.value||null})}_entityCompensationChanged(t){this._source=Object.assign(Object.assign({},this._source),{},{entity_energy_price_export:t.detail.value||null})}_numberCompensationChanged(t){const e=t.currentTarget,i=e.value?parseFloat(e.value):null;this._source=Object.assign(Object.assign({},this._source),{},{number_energy_price_export:i})}_handlePowerConfigChanged(t){this._powerType=t.detail.powerType,this._powerConfig=t.detail.powerConfig}async _save(){try{var t;const e={type:"grid",stat_energy_from:this._source.stat_energy_from,stat_energy_to:this._source.stat_energy_to,stat_cost:this._source.stat_cost,stat_compensation:this._source.stat_compensation,entity_energy_price:this._source.entity_energy_price,number_energy_price:this._source.number_energy_price,entity_energy_price_export:this._source.entity_energy_price_export,number_energy_price_export:this._source.number_energy_price_export,cost_adjustment_day:this._source.cost_adjustment_day};null!==(t=this._source)&&void 0!==t&&t.name&&(e.name=this._source.name),"none"!==this._powerType&&(e.power_config=Object.assign({},this._powerConfig)),await this._params.saveCallback(e),this.closeDialog()}catch(e){this._error=e.message}}static get styles(){return[y.RF,y.nA,(0,o.AH)(k||(k=M`ha-entity-picker,ha-statistic-picker{display:block;margin-bottom:var(--ha-space-4)}ha-input{margin-bottom:var(--ha-space-4);--ha-input-padding-bottom:0}ha-entity-picker:last-of-type,ha-input:last-of-type,ha-statistic-picker:last-of-type{margin-bottom:0}ha-input.name{margin-top:var(--ha-space-4)}ha-radio-group{margin-bottom:var(--ha-space-4)}.section-label{margin-top:var(--ha-space-4);margin-bottom:var(--ha-space-2)}.section-description{margin-top:0;margin-bottom:var(--ha-space-2);color:var(--secondary-text-color);font-size:.875em}`))]}constructor(...t){super(...t),this._open=!1,this._powerType="none",this._powerConfig={},this._importCostType="no_cost",this._exportCostType="no_cost"}}(0,a.Cg)([(0,n.MZ)({attribute:!1})],E.prototype,"hass",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_params",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_open",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_source",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_powerType",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_powerConfig",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_importCostType",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_exportCostType",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_energy_units",void 0),(0,a.Cg)([(0,n.wk)()],E.prototype,"_error",void 0),(0,a.Cg)([(0,n.P)("ha-energy-power-config")],E.prototype,"_powerConfigEl",void 0),E=(0,a.Cg)([(0,n.EM)("dialog-energy-grid-settings")],E),s()}catch(b){s(b)}})},24367:function(t,e,i){i.d(e,{L:function(){return a},z:function(){return o}});var s=i(23832);const a=["input_boolean","input_button","input_text","input_number","input_datetime","input_select","counter","timer","schedule"],o=(0,s.g)(a)},19711:function(t,e,i){i.d(e,{$:function(){return o}});i(3362),i(62953);var s=i(1087);const a=()=>Promise.all([i.e(80131),i.e(70183),i.e(47677)]).then(i.bind(i,79029)),o=(t,e)=>{(0,s.r)(t,"show-dialog",{dialogTag:"dialog-helper-detail",dialogImport:a,dialogParams:e})}}}]);