Electricity price cannot be set when using an external statistic

Hi everyone :wave:

I have recently created and add-on that inserts electricity consumption statistics in Home Assistant using the WebSocket API.

All these statistics are “external” statistic, so their statistic_id contains a : instead of a . as separator, as explained here.

In the statistics meta, the unit is “Wh”.

However, when I try to add this statistic to my Energy Dashboard, I cannot set the price, because the radio buttons are disabled… :confused:

I thought at first it was a bug with the UI, but this seems to be by design according to this PR comment:

A price entity or a fixed price is only supported when the consumed gas is tracked by a sensor.

Where can I find more information about this ? I cannot find any other related documentation, and this limitation doesn’t make sense to me

And if you know a hack to bypass this problem, I’m all ears!


P.S: I tried to replace the : with a . in database, which enables the radio buttons, but the price displayed in the Energy dashboard is still 0…


Hi. By chance did you get a solution ? I also have the Linky consumption entity and unable to select the entity with the price current price (based on 2 different prices per day with 3 different types of day)

Also interested, same issue!

The reason for the limitation is a bit technical that requires you understand what’s going on internally in the energy integration, but basically the price is a sensor entity that is updated every time the consumption entity changes, and then that entity is processed into long term statistics.

There’s no mechanism for HA to calculate and generate price statistics retroactively from external statistics.

The only way (without changes to HA core) to get a cost for external statistics is to also generate and import a statistic for costs in the same way you imported external statistic for consumption.

OK, that makes sense, thanks for the explanation!