[Solved] Energy cost not calculated

Also tried using integer number (1) without any decimal and separator, and no cost is calculated.

Hey guys I managed to make it work. You need to record the cost sensors, otherwise it will stay at zero. Since I added the sensor.xxxxxx_energy_cost in my recorder, everything gets calculated

1 Like

Same here, did work but stopped working since a few days. Both Gas and Energy.
Also tried changing to 2 decimals.
First calculation was incorrect and next days costs remain 0
image (2021-10-09)
1 m3 = €0,82 in my case so this should be €2,173

Still no solution?

I had the same problem.
It started to happen after one of the updates…

I noticed these errors in the log:

2021-10-07 15:16:43 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.shellyem3_e8db84d72667_channel_a_energy_cost (ILS) does not match the unit of already compiled statistics (EUR). Generation of long term statistics will be suppressed unless the unit changes back to EUR
2021-10-07 15:16:43 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.shellyem3_e8db84d72667_channel_b_energy_cost (ILS) does not match the unit of already compiled statistics (EUR). Generation of long term statistics will be suppressed unless the unit changes back to EUR
2021-10-07 15:16:43 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.shellyem3_e8db84d72667_channel_c_energy_cost (ILS) does not match the unit of already compiled statistics (EUR). Generation of long term statistics will be suppressed unless the unit changes back to EUR

So I went to “Developer Tools → Statistics” and noticed there is a “FIX ISSUE” next to these entities.

fixed the issue and now it’s working

7 Likes

Fixed in 2021.10 - developer tools + statistics. You can see which ones need to be fixed. Pressed this and the next day it’s working again.

1 Like

I have not set a sensor for the cost, so nothing to be fixed. What should I do in this case?

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.