Fix displayed unit for fixed water price (#16616)

This commit is contained in:
karwosts 2023-05-24 09:21:41 -07:00 committed by GitHub
parent 50bd9da94c
commit cccce5711c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,10 +83,14 @@ export class DialogEnergyWaterSettings
const pickableUnit = this._water_units?.join(", ") || ""; const pickableUnit = this._water_units?.join(", ") || "";
const unitPrice = this._pickedDisplayUnit const unitPriceSensor = this._pickedDisplayUnit
? `${this.hass.config.currency}/${this._pickedDisplayUnit}` ? `${this.hass.config.currency}/${this._pickedDisplayUnit}`
: undefined; : undefined;
const unitPriceFixed = `${this.hass.config.currency}/${
this.hass.config.unit_system.volume === "gal" ? "gal" : "m³"
}`;
const externalSource = const externalSource =
this._source.stat_energy_from && this._source.stat_energy_from &&
isExternalStatistic(this._source.stat_energy_from); isExternalStatistic(this._source.stat_energy_from);
@ -189,7 +193,7 @@ export class DialogEnergyWaterSettings
.value=${this._source.entity_energy_price} .value=${this._source.entity_energy_price}
.label=${`${this.hass.localize( .label=${`${this.hass.localize(
"ui.panel.config.energy.water.dialog.cost_entity_input" "ui.panel.config.energy.water.dialog.cost_entity_input"
)}${unitPrice ? ` (${unitPrice})` : ""}`} )}${unitPriceSensor ? ` (${unitPriceSensor})` : ""}`}
@value-changed=${this._priceEntityChanged} @value-changed=${this._priceEntityChanged}
></ha-entity-picker>` ></ha-entity-picker>`
: ""} : ""}
@ -210,13 +214,13 @@ export class DialogEnergyWaterSettings
? html`<ha-textfield ? html`<ha-textfield
.label=${`${this.hass.localize( .label=${`${this.hass.localize(
"ui.panel.config.energy.water.dialog.cost_number_input" "ui.panel.config.energy.water.dialog.cost_number_input"
)}${unitPrice ? ` (${unitPrice})` : ""}`} )} (${unitPriceFixed})`}
class="price-options" class="price-options"
step=".01" step="any"
type="number" type="number"
.value=${this._source.number_energy_price} .value=${this._source.number_energy_price}
@change=${this._numberPriceChanged} @change=${this._numberPriceChanged}
.suffix=${unitPrice || ""} .suffix=${unitPriceFixed}
> >
</ha-textfield>` </ha-textfield>`
: ""} : ""}