Utility Meter - keep values after restart

Hmm, today I performed an update to my server, it has been off-line for about an hour.
This is what happens to the utility-meter sensor:
image

This is the result of my own sensor:
image

My own sensor follows the data provided by a kWh-counter that I obtain from a device that is connected to my DSMR meter at home (I use an Aurum Meetstekker, if someone is interested).
My sensor stays correct, as long as the system is up when the important events happen: when the reset to zero happens and when the last measurement of the period is taken.

I’m not sure how the utility meter sensor is working under the hood, apparently it is loosing accuracy when the server experience some down-time.

Thanks for getting back to me!

On the first bullet, I understand what you mean, thanks! The sample period was per 15 minutes, now I’ve set it to per 1 minute :slight_smile:

On the second bullet: I want to know what the value at the end of each period has been. I want to be able to compare the results of various, let’s say, days. That information is available in the raw data of the utility-meter-sensor but can not be easily recovered (please correct me if I make a wrong conclusion here). So, I think it would be good if the utility-meter sensor could provide two outputs: the end result of the last period, next to the already available present result of the present, ongoing period.

Does this make more sense?

The sensors have an attribute called “last_period” with that information (it’s there available when you expand the sensor in the GUI). It’s not feasible to provide more then the last period in the HA state-machine (per HA architecture). What I recommend is that you save these values to another backend (example InfluxDB).

I noticed that attribute earlier, I wondered what that attribute was for. Now I know!
Would be good to write this in the documentation.

Thanks! Getting very close to my wish :slight_smile:

Please have a look at my post #21. This is my only worry left now.

Related to that post, the first picture shows “status: paused”. The update interval of the corresponding sensor is 15 minutes.
I have another utility-meter-sensor that shows “status: collecting” Update interval is 1 minute.
Is there a relation to the corresponding sensor update interval?

If you think you can improve the documentation do so! there is a link in each webpage to go into GitHub and propose changes.

In what respects to #21, yes… the utility meter will lose all readings made by the source during the time HA is offline because of the source sensor. When the source sensor comes back, if it does not store the previous value, then the first reading forwarded to the utility meter will not have information about the value before the downtime. It all comes down to the source sensor which is out of scope of utility_meter, and it must be the source sensor implementing restore_state logic. Which sensor are you using ?

My setup is like this: 1 have a physical Smart Meter (DSMR) in my home and 1 physical single phase electricity meter for my PV-inverter. These 2 meters are connected to an Aurum Meetstekker which makes all the data coming from the 2 meters available on a simple website.

If have made a simple scraping-script that reads the relevant data from that website.
For instance I scrape the PV-output-counter (in kWh) of the PV-electricity-meter. The values that get scraped are always correct, I rely on the fact that this meter is accurate and always shows the correct result. I have made my own daily sensor based on this data. Basically it follows the PV-output kWh counter and subtracts at the end the day the value of the counter at that moment, resetting the result of this daily sensor to zero.
I want to use the Utility-Meter for this, but I wonder if I can use the Utility-Meter in this scenario? Maybe I have misunderstood what the exact purpose is of the Utility-Meter?

The utility meter can be used for your scenario (that’s what I had in mind at least). The thing is: you only do the calculation once a day, the utility_meter does it every time the source changes, so chances are it misses on data while HA is down.

Check my discussion in https://github.com/home-assistant/home-assistant/issues/20931

Ok, I will join the discussion in the github-topic.

My comment was not a call to continue discussing in github :slight_smile:

It was just the lazy me avoiding writing the same explanation twice :wink:

Hi @dgomes my utility meter config is just setup to take kWh from my energy meter. There are no tariffs since it is single rate. I want to reset the utility daily, weekly, monthly, yearly values. Since I don’t use tariffs, I cannot use the utility_meter.reset. I guess I could make a dummy tariff and have the ability to reset. But is there a better way without having to do that or by deleting the entry in the core.restore_state file?

You just need to configure multiple meters with different cycles. The utility meter will handle the reset for you (that is the purpose of the utility_meter).

The service “reset” functionality is a stop gap for some utility companies that have eccentric tariff plans. 99% of the users should just rely in the configuration of the cycle option that will handle the periodic reset.

Yes I have each of the cycles. What I am asking for is a way to reset those values to 0. I’d like to start fresh.

1 Like

theoretically you could:

  • stop HA
  • edit .storage/core.restore_state to reset values
  • start HA

Other approach is to add a single dummy tariff (lets call it normal) and then you will get access to the reset service (but will create new entities)

It would only create the new entity the first time though so that might be my best option if I ever want to reset them again. I just want to get everything in sync now since I just updated everything along with my utility bill cycle. I also need to reset because it looks like the weekly and monthly values are reversed. So I need to test this out. Right now the weekly is higher than the monthly and that just isn’t supposed to happen.

Anyone who would like an alternative “utility_meter” I will refine and maintain the code here:

Hi Tiaan,

I tried to use it and placed it in config/custom_components/utility_meter. I have rebooted and then tried to add the “mode: alt” but a config check drops an error:

Invalid config for [utility_meter]: [mode] is an invalid option for [utility_meter]. Check: utility_meter->utility_meter->daily_power_offpeak_alt->mode. (See ?, line ?). Please check the docs at https://home-assistant.io/components/utility_meter/

What am I doing wrong?

Sorry. Not sure why, but since hass.io V0.91 the custom component “override” does not seem to work. Not sure how to resolve this yet.

Thanks. I seem to have it working. The link helped me.

Hi all, i didn’t yet understand what does it means “paused”. I can see it in some of my utility meters but can’t figure out why…