[Solved] Energy cost not calculated

In configurations → energy, then set the rate there. You need this for it to calculate.

Same problem, not working with static price.

1 Like

I have the same problem only for the gas sensor (I’m using the Hildebrand Glow (DCC) and my gas sensor is in kWh). I tried to put a fixed price and an input_number with my gas rate but no luck. I can’t understand why the electric one is working with the same settings.

Is any news for gas sensor?

Sure, I did since the initial config, but It doesn’t work. And I am nor the only one

Same issue here, no errors.

Both using a manual value or a sensor which exposes the data below, the cost is always 0€.

state_class: measurement
attribution: Data retrieved with auth token from api.esios.ree.es by REE
Esios name: PVPC T. 2.0TD
Esios code: 1001
period: P3
next_period: P2
hours_to_next_period: 63
next_better_price: 0.30125
hours_to_better_price: 3
num_better_prices_ahead: 3
price_position: 20
price_ratio: 0.9
max_price: 0.31044
max_price_at: 18
min_price: 0.24227
min_price_at: 5
next_best_at:
  - 23
  - 22
  - 20
  - 17
  - 19
  - 21
  - 18
price_00h: 0.3059
price_01h: 0.28575
price_02h: 0.262
price_03h: 0.24335
price_04h: 0.24369
price_05h: 0.24227
price_06h: 0.24444
price_07h: 0.26117
price_08h: 0.27644
price_09h: 0.28504
price_10h: 0.28346
price_11h: 0.27963
price_12h: 0.28209
price_13h: 0.27287
price_14h: 0.27029
price_15h: 0.26091
price_16h: 0.2772
price_17h: 0.30362
price_18h: 0.31044
price_19h: 0.30914
price_20h: 0.30125
price_21h: 0.30963
price_22h: 0.28888
price_23h: 0.2743
unit_of_measurement: EUR/kWh
friendly_name: ESIOS PVPC
icon: mdi:currency-eur

(current state: 0.30362).

Same problem here.
Work with the static price.

As soon as I create a helper and update it with the same price it doesn’t work
I have tried all suggestions (e.g. EUR/Kwh, less digits, $/Kwh) but nothing works for me

when use it at the energy tab I get the following

I can’t figure out how comes this threat has been solved?

I solved it by creating a template sensor for each energy consumption entity. It’s time consuming but I assume it’s necessary to make it work. I basically have a sensor of a sensor of a sensor now…

Here’s my current (now working) config:
Get power consumption via Rest sensor

sensor:
  - platform: rest
    resource: http://[local_ip_of_my_switch/report
    value_template: "{{ value_json.power }}"
    name: "Power Consumption [device]"
    unit_of_measurement: W
    device_class: power

Use the Riemann sum integral to calculate energy consumption from power consumption

sensor:
  - platform: integration
    source: sensor.power_consumption_[device]
    name: "Riemann Energy Consumption [device]"
    unit_prefix: k
    round: 4

The sensor which is than added to the energy dashboard

sensor:
  - platform: template
    sensors:
      energy_consumption_[device]:
        friendly_name: "[device]"
        unique_id: energy_consumption_[device]
        value_template: "{{ states('sensor.riemann_energy_consumption_[device]') | float }}"

and finally the customization for the sensors added to the energy dashboard

homeassistant:
  customize_glob:
    sensor.energy_consumption_*:
      unit_of_measurement: kWh
      device_class: energy
      state_class: total_increasing

Hope this solves it for some of you :smiley:

(To make this work you obviously have to have a tariff entity set up with a numeric value and {currency}/kWh as unit of measurement or set a static value)

1 Like

Hey guys,
I am struggling with the energy dashboard as well. It’s calculating my produced solar energy and gives me the revenue for that based on the same sensor as the consumption cost, yet I don’t get any calculation on consumption.

I’ll post the sensors I am using:

From Tibber

Energy Cost:
state_class: measurement
app_nickname: B7
grid_company: Energi AB
estimated_annual_consumption: 3190
price_level: CHEAP
max_price: 1.336
avg_price: 1.157
min_price: 0.565
off_peak_1: 1.21
peak: 1.244
off_peak_2: 0.79
unit_of_measurement: SEK/kWh
icon: mdi:currency-usd
friendly_name: Electricity price 

Grid consumtion sensor:

state_class: total_increasing
name: Load 
id: QPH5RE5X
state_cumulativeActivePowerImport: 20585.8
state_cumulativeReactivePowerImport: 33.2
unit_of_measurement: kWh
device_class: energy
friendly_name: JuiceBalancer Import energy

Yet I still don’t get any cost calculations in the energy dashboard. Do you have any ideas where to start or what might be wrong?

Thanks!
Rob

Just so everyone understands: if you use a static cost, a hidden sensor cost entity will be created. This entity will share the same entity_id as your energy sensor but will end with _cost. This entity must be recording to your database. If you’re filtering recorder, ensure this entity is included. Otherwise the cost will always be 0

Another thing that I just found out, check your customize and customize_glob entries if you still have issues. I had sensor.energy_delivered_* overwrite that was setting resets and device_class for them and the cost sensor that is automatically added as mentioned above was falling into the same glob. This caused my costs to be 0 all the time.

Hi petro,

Can you give me a tip, how to filtering recorder to include this entity (in a HA container)? My static costs are always 0.00.
And maybe you could suggest why I have 6 Tiers, which one should I use, these are all so different, I have only on tarif for day and night €0.21 per kWh.

You have to be recording history for all entities involved in the calculations, otherwise the results will be zero.

yes, it’s logical. But wher and how to manupulate this or any recordings, I’m totally new to HA… Is it somewhere in GUI?

it’s not working for me @ 2023.7.1
i am recording anything (or default settings of the recorder) and energy with static price is working
water and gas are not, tested helper (input_number) and static price, the cost always says 0€

any suggestions?

Same issue with static price.
Just configured it and it shows zero cost, but there is consumption history.

I saw an info with “After setting up a new device, it can take up to 2 hours for new data to arrive in your energy dashboard.”, I will recheck after some time.

HA 2024.1.5, OS 11.4

Seems that energy cost is calculated starting from config time, even if there is history.
Now the cost is increasing (today timeframe, but yesterday still shows 0 cost):

Energy does not use history to make calculations, it uses long term statistics. It will only calculate from the time the entities were configured and added to the energy dashboard.

1 Like

There is a bug if you change the id of the original entity. Then we I set again the price, it does not create another entity with the right id_cost.
The _cost entity stays the same and can not be deleted.

Do you have an idea how to delete it ?

I found how to delete it.
In dev tools, find the entity, it the ID starts with the same id as the entity. Click on the “Info” icon of the entity, then on the gog wheel and a delete button is displayed. Or may be change the id of the entity to match the right one.