diff --git a/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts
index 0dfc85cc60..05698f0aff 100644
--- a/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts
+++ b/src/panels/config/energy/dialogs/dialog-energy-gas-settings.ts
@@ -9,6 +9,7 @@ import "../../../../components/ha-dialog";
import "../../../../components/ha-formfield";
import "../../../../components/ha-radio";
import "../../../../components/ha-button";
+import "../../../../components/ha-markdown";
import type { HaRadio } from "../../../../components/ha-radio";
import "../../../../components/ha-textfield";
import type { GasSourceTypeEnergyPreference } from "../../../../data/energy";
@@ -109,6 +110,15 @@ export class DialogEnergyGasSettings
? `${this.hass.config.currency}/${this._pickedDisplayUnit}`
: undefined;
+ const pickedUnitClass =
+ this._pickedDisplayUnit &&
+ this._energy_units?.includes(this._pickedDisplayUnit)
+ ? "energy"
+ : this._pickedDisplayUnit &&
+ this._gas_units?.includes(this._pickedDisplayUnit)
+ ? "volume"
+ : undefined;
+
const externalSource =
this._source.stat_energy_from &&
isExternalStatistic(this._source.stat_energy_from);
@@ -213,9 +223,33 @@ export class DialogEnergyGasSettings
.hass=${this.hass}
include-domains='["sensor", "input_number"]'
.value=${this._source.entity_energy_price}
- .label=${`${this.hass.localize(
+ .label=${this.hass.localize(
"ui.panel.config.energy.gas.dialog.cost_entity_input"
- )} ${unitPrice ? ` (${unitPrice})` : ""}`}
+ )}
+ .helper=${pickedUnitClass
+ ? html``
+ : nothing}
@value-changed=${this._priceEntityChanged}
>`
: ""}
diff --git a/src/panels/config/energy/dialogs/dialog-energy-water-settings.ts b/src/panels/config/energy/dialogs/dialog-energy-water-settings.ts
index 46d1552b06..8d54cf8541 100644
--- a/src/panels/config/energy/dialogs/dialog-energy-water-settings.ts
+++ b/src/panels/config/energy/dialogs/dialog-energy-water-settings.ts
@@ -9,6 +9,7 @@ import "../../../../components/ha-dialog";
import "../../../../components/ha-button";
import "../../../../components/ha-formfield";
import "../../../../components/ha-radio";
+import "../../../../components/ha-markdown";
import type { HaRadio } from "../../../../components/ha-radio";
import "../../../../components/ha-textfield";
import type { WaterSourceTypeEnergyPreference } from "../../../../data/energy";
@@ -16,11 +17,7 @@ import {
emptyWaterEnergyPreference,
energyStatisticHelpUrl,
} from "../../../../data/energy";
-import {
- getDisplayUnit,
- getStatisticMetadata,
- isExternalStatistic,
-} from "../../../../data/recorder";
+import { isExternalStatistic } from "../../../../data/recorder";
import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor";
import type { HassDialog } from "../../../../dialogs/make-dialog-manager";
import { haStyle, haStyleDialog } from "../../../../resources/styles";
@@ -40,8 +37,6 @@ export class DialogEnergyWaterSettings
@state() private _costs?: "no-costs" | "number" | "entity" | "statistic";
- @state() private _pickedDisplayUnit?: string | null;
-
@state() private _water_units?: string[];
@state() private _error?: string;
@@ -55,11 +50,6 @@ export class DialogEnergyWaterSettings
this._source = params.source
? { ...params.source }
: emptyWaterEnergyPreference();
- this._pickedDisplayUnit = getDisplayUnit(
- this.hass,
- params.source?.stat_energy_from,
- params.metadata
- );
this._costs = this._source.entity_energy_price
? "entity"
: this._source.number_energy_price
@@ -79,7 +69,6 @@ export class DialogEnergyWaterSettings
this._params = undefined;
this._source = undefined;
this._error = undefined;
- this._pickedDisplayUnit = undefined;
this._excludeList = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
return true;
@@ -92,10 +81,6 @@ export class DialogEnergyWaterSettings
const pickableUnit = this._water_units?.join(", ") || "";
- const unitPriceSensor = this._pickedDisplayUnit
- ? `${this.hass.config.currency}/${this._pickedDisplayUnit}`
- : undefined;
-
const unitPriceFixed = `${this.hass.config.currency}/${
this.hass.config.unit_system.volume === "gal" ? "gal" : "m³"
}`;
@@ -202,9 +187,15 @@ export class DialogEnergyWaterSettings
.hass=${this.hass}
include-domains='["sensor", "input_number"]'
.value=${this._source.entity_energy_price}
- .label=${`${this.hass.localize(
+ .label=${this.hass.localize(
"ui.panel.config.energy.water.dialog.cost_entity_input"
- )}${unitPriceSensor ? ` (${unitPriceSensor})` : ""}`}
+ )}
+ .helper=${html``}
@value-changed=${this._priceEntityChanged}
>`
: ""}
@@ -287,16 +278,6 @@ export class DialogEnergyWaterSettings
}
private async _statisticChanged(ev: CustomEvent<{ value: string }>) {
- if (ev.detail.value) {
- const metadata = await getStatisticMetadata(this.hass, [ev.detail.value]);
- this._pickedDisplayUnit = getDisplayUnit(
- this.hass,
- ev.detail.value,
- metadata[0]
- );
- } else {
- this._pickedDisplayUnit = undefined;
- }
if (isExternalStatistic(ev.detail.value) && this._costs !== "statistic") {
this._costs = "no-costs";
}
diff --git a/src/translations/en.json b/src/translations/en.json
index 1c10ecca34..297cf06981 100644
--- a/src/translations/en.json
+++ b/src/translations/en.json
@@ -3206,6 +3206,9 @@
"cost_stat_input": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_stat_input%]",
"cost_entity": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_entity%]",
"cost_entity_input": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_entity_input%]",
+ "cost_entity_helper": "Any entity with a unit of `{currency}/(valid {class} unit)` (e.g. `{currency}/{unit1}` or `{currency}/{unit2}`) may be used and will be automatically converted.",
+ "cost_entity_helper_energy": "energy",
+ "cost_entity_helper_volume": "volume",
"cost_number": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_number%]",
"cost_number_input": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_number%]",
"gas_usage": "Gas usage"
@@ -3229,6 +3232,7 @@
"cost_stat_input": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_stat_input%]",
"cost_entity": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_entity%]",
"cost_entity_input": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_entity_input%]",
+ "cost_entity_helper": "Any entity with a unit of `{currency}/(valid water unit)` (e.g. `{currency}/gal` or `{currency}/m³`) may be used and will be automatically converted.",
"cost_number": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_number%]",
"cost_number_input": "[%key:ui::panel::config::energy::grid::flow_dialog::from::cost_number%]",
"water_usage": "Water usage"