@@ -9,6 +9,7 @@ import "../../../../components/ha-dialog";
99import "../../../../components/ha-button" ;
1010import "../../../../components/ha-formfield" ;
1111import "../../../../components/ha-radio" ;
12+ import "../../../../components/ha-markdown" ;
1213import type { HaRadio } from "../../../../components/ha-radio" ;
1314import type {
1415 FlowFromGridSourceEnergyPreference ,
@@ -19,11 +20,7 @@ import {
1920 emptyFlowToGridSourceEnergyPreference ,
2021 energyStatisticHelpUrl ,
2122} from "../../../../data/energy" ;
22- import {
23- getDisplayUnit ,
24- getStatisticMetadata ,
25- isExternalStatistic ,
26- } from "../../../../data/recorder" ;
23+ import { isExternalStatistic } from "../../../../data/recorder" ;
2724import { getSensorDeviceClassConvertibleUnits } from "../../../../data/sensor" ;
2825import type { HassDialog } from "../../../../dialogs/make-dialog-manager" ;
2926import { haStyleDialog } from "../../../../resources/styles" ;
@@ -47,8 +44,6 @@ export class DialogEnergyGridFlowSettings
4744
4845 @state ( ) private _costs ?: "no-costs" | "number" | "entity" | "statistic" ;
4946
50- @state ( ) private _pickedDisplayUnit ?: string | null ;
51-
5247 @state ( ) private _energy_units ?: string [ ] ;
5348
5449 @state ( ) private _error ?: string ;
@@ -81,11 +76,6 @@ export class DialogEnergyGridFlowSettings
8176 : "stat_energy_to"
8277 ] ;
8378
84- this . _pickedDisplayUnit = getDisplayUnit (
85- this . hass ,
86- initialSourceId ,
87- params . metadata
88- ) ;
8979 this . _energy_units = (
9080 await getSensorDeviceClassConvertibleUnits ( this . hass , "energy" )
9181 ) . units ;
@@ -103,7 +93,6 @@ export class DialogEnergyGridFlowSettings
10393 public closeDialog ( ) {
10494 this . _params = undefined ;
10595 this . _source = undefined ;
106- this . _pickedDisplayUnit = undefined ;
10796 this . _error = undefined ;
10897 this . _excludeList = undefined ;
10998 fireEvent ( this , "dialog-closed" , { dialog : this . localName } ) ;
@@ -117,10 +106,6 @@ export class DialogEnergyGridFlowSettings
117106
118107 const pickableUnit = this . _energy_units ?. join ( ", " ) || "" ;
119108
120- const unitPriceSensor = this . _pickedDisplayUnit
121- ? `${ this . hass . config . currency } /${ this . _pickedDisplayUnit } `
122- : undefined ;
123-
124109 const unitPriceFixed = `${ this . hass . config . currency } /kWh` ;
125110
126111 const externalSource =
@@ -246,9 +231,15 @@ export class DialogEnergyGridFlowSettings
246231 .hass = ${ this . hass }
247232 include- domains= '["sensor ", "input_number"]'
248233 .value = ${ this . _source . entity_energy_price }
249- .label = ${ ` ${ this . hass . localize (
234+ .label = ${ this . hass . localize (
250235 `ui.panel.config.energy.grid.flow_dialog.${ this . _params . direction } .cost_entity_input`
251- ) } ${ unitPriceSensor ? ` (${ unitPriceSensor } )` : "" } `}
236+ ) }
237+ .helper = ${ html `<ha- markdown
238+ .content = ${ this . hass . localize (
239+ "ui.panel.config.energy.grid.flow_dialog.cost_entity_helper" ,
240+ { currency : this . hass . config . currency }
241+ ) }
242+ > </ ha- markdown> ` }
252243 @value-changed = ${ this . _priceEntityChanged }
253244 > </ ha- entity- picker> `
254245 : "" }
@@ -341,16 +332,6 @@ export class DialogEnergyGridFlowSettings
341332 }
342333
343334 private async _statisticChanged ( ev : CustomEvent < { value : string } > ) {
344- if ( ev . detail . value ) {
345- const metadata = await getStatisticMetadata ( this . hass , [ ev . detail . value ] ) ;
346- this . _pickedDisplayUnit = getDisplayUnit (
347- this . hass ,
348- ev . detail . value ,
349- metadata [ 0 ]
350- ) ;
351- } else {
352- this . _pickedDisplayUnit = undefined ;
353- }
354335 this . _source = {
355336 ...this . _source ! ,
356337 [ this . _params ! . direction === "from"
0 commit comments