Energy costs sensor resets after restart

These come from the huawei inverter, they were hidden, but are connected to energy-sources-table
I also have nordpool added, and everything in the energy dashboard is correct, used electricity and sold electricity with floating nordpool price.
I just want to have those 2 in a card so i don’t need to go into the energy dashboard to see what I have sold and bought.

**


**

But it does not reset in the energy dashboard, just the card.
Or do you have any better suggestion how to get those 2 entities to a card with history so it doesnt reset.

Which integration?

Share your config for them if they are not discovered.

Integration is SUN2000-10KTL-M1SUN2000-12

Where do I find the config for them, talk to me like you are talking to a little child, with 0 knowledge about this :slight_smile:

That appears to be the inverter model number.

How did you make the sensors?

How did you connect the inverter to Home Assistant?

Here in the forum there is a tutorial, but i went into hacks and searched for huawei solar github link

The sensors are there, just hidden, i didn’t make them.

Only thing i did was to name them “såld” “köpt”

I also noticed the same (and maybe to add some information to this post). With the new energy dashboard from some releases ago, in the latest release when setting up an energy sensors with a pricing entity linked to calculate costs, HomeAssistant also auto-creates new sensors named ‘Sensor cost’ with a price which seems to be like a meter entity that:

  • Resets once per day
  • Resets when HA restarts.

I guess second option can’t be changed as it might be some tracked cost in the portal, but my question is, any way to change when in the day does the sensor cost resets? It would be more useful to have it reset at midnight, to have the cost sensor direclty show the accumulated costs throughout the day.

I tired searching a bit about these automatically created sensors costs but couldn’t find much. Any link to docs or something would be very appreciated to understand them better!

Thanks

1 Like

Hi,
These sensors will be created, when you add tarifs to your energy dashboard.

In my Energy Dashboard, I have configured a price for Imported Energy and a price for exported energy.
HomeAssistant does generate these “monetary” sensors automatically:


But it seems, that they reset on reboot of the system.
As you can see, both sensors do have the same “last_reset” timestamp (except for some miliseconds)…
Both have been resetted on October 27th (Thursday)

In this case, it seems that the sensors don’t use a fixed “reset” option like daily, weekly, monthly or something else… which makes it a bit difficult to use them somewhere in a custom dashboard…

Here’s the “history” for the “exported compensation”

as well as for the “imported costs”

Here’s a “zoom in” into the range from Oct. 27th 21:00 to Oct. 28th 02:00

I would really like to use these Sensors - but I would prefer to have them in the same form like other utility meters… with “fixed” reset periods, like daily / weekly / monthly / quarterly / yearly

Atm, the only way I do see is to create custom sensors / templates / utility meters, where I need to set the price again - and then - calculate the prices / revenues by multiplikating the price with the exported / imported energy.
But when HA does already provide this kind of information in some way - I would prefer to use this one, instead of creating these entities manually.

I think I have solved it, at least for my self.
I created a helper (utility meter) Input sensor =one of the generated sensors.
Reset daily and that was it.
Now it has history so I can restart, and the history is still there.
Only problem I had was that I got 17-18 decimals
The way I fixed that was I made a sensor:

  totalt_spotpris_idag:
      friendly_name: Spotpris skulle ha kostat
      value_template: '{{ states("sensor.spot_test_reset_daily") | float | round(2)}}'       
      unit_of_measurement: "€"

This is with the helper i created, 17-18 decimals
image

And this is the results with the created sensor:
image

If someone have some improvements, feel free to share.

1 Like

yes, writing the data of the existing meter-sensor into a new one can be used as a workaround.
But the downside of this is:

You have two components doing exactly the same… (the one without having a “bug”) - but I prefer if the team could fix the underlying issue :smiley: rather than working around it

I wonder if this has been addressed yet or if this is reported as an issue?
At least for my v2022.10.5 it still seems to be resetted…

let me check, but I don’t think that it’ll be fixed

Edit:
The sensors still reset on reboot:

based on what I know, the state_class: total should be able to reset.
I think, the sensor is doing what it is supposed to do… it does measure and it does save the “last reset”.

Therefore, I don’t think that raising an issue will change anything…
Probably, the only way of getting this is really to create a template / helper “utility meter” that is inherited from the cost sensors.

Hhm, not sure if I understand correct:
If I look at my sensors, I see the cost sensor is reset but the corresponding production sensor not.

Is this really what it is supposed to do? I have no idea, what the idea or the use case for this behavior could be.
What is the idea to display an energy cost since last boot?

the production sensor has state class: total_increasing.
therefore, it does “never” reset.

The cost sensor - is another measurement sensor with state class: total.
The “total” state class is a sensor that requires a reset timestamp.
Therefore, - the sensor does behave as it has been designed (corresponding to the state_class)…

The Discussion would be more about, if the desired state_class is the correct one, or if it should also be “total_increasing”…

I don’t know, why the state_class “total” was choosen. Maybe, there’s a good reason for it…

1 Like

All, sorry to jump in here in this ongoing conversation.

After spending several days to build cool dashboards on InfluxDB and Grafana and fighting to understand why they look sometimes very good and sometimes weird, I did some troubleshooting on the data and saw the issue was coming from the problem described here (reset of the energy costs after HA restart). Unfortunately I do not see regular reset once a day as mentioned above. Is there a way to configure the regular reset at 00:00 as example?
For the second issue (reset when HA restarts) I will try to apply the sensor workaround as described as well here. as I am a beginner in HA hope to make it working before a new release of HA solve this reset issue :slight_smile: .

Thanks

I saw the same issue. They reset on restart but not daily or anything else so they are kind of pointless actually.
What I did now is create utility meter sensors for daily/monthly/yearly cycles for the desired generated sensors.
So for example I have sensor.e3dc_grid_import_energy and sensor.e3dc_grid_import_energy_cost and I just created utility_meter sensors for them like:

    # Grid Import Energy
    e3dc_grid_import_daily_energy:
      source: sensor.e3dc_grid_import_energy
      unique_id: e3dc_grid_import_daily_energy
      name: E3DC Grid Import Daily Energy
      cycle: daily
    e3dc_grid_import_monthly_energy:
      source: sensor.e3dc_grid_import_energy
      unique_id: e3dc_grid_import_monthly_energy
      name: E3DC Grid Import Monthly Energy
      cycle: monthly
    e3dc_grid_import_yearly_energy:
      source: sensor.e3dc_grid_import_energy
      unique_id: e3dc_grid_import_yearly_energy
      name: E3DC Grid Import Yearly Energy
      cycle: yearly
    # Grid Import Energy Cost
    e3dc_grid_import_daily_energy_cost:
      source: sensor.e3dc_grid_import_energy_cost
      unique_id: e3dc_grid_import_daily_energy_cost
      name: E3DC Grid Import Daily Energy Cost
      cycle: daily
    e3dc_grid_import_monthly_energy_cost:
      source: sensor.e3dc_grid_import_energy_cost
      unique_id: e3dc_grid_import_monthly_energy_cost
      name: E3DC Grid Import Monthly Energy Cost
      cycle: monthly
    e3dc_grid_import_yearly_energy_cost:
      source: sensor.e3dc_grid_import_energy_cost
      unique_id: e3dc_grid_import_yearly_energy_cost
      name: E3DC Grid Import Yearly Energy Cost
      cycle: yearly

I actually did this for almost all sensors related to energy, cost or compensation.
This makes it much easier to export to prometheus (VictoriaMetrics) and use them in Grafana for Daily/Monthly/Yearly graphs.
I just did this today, hope it works as I want them to.

1 Like

Good day, I was wondering dit this work for you? I am experiencing the same problem.

Well another year on and the problem still exists in the entity created by the Energy Dashboard.

Can we register this as a bug in the energy dashboard so it can be fixed in the next releases?

A few workarounds work but the energy cost meter should not reset on a restart of HASS… only at midnight.

1 Like

This open issue should cover this problem, let´s hope it is solved soon: energy dashboard showing incorrect costs for power consumed · Issue #17536 · home-assistant/frontend · GitHub