Reset values of utility_meter

Use the reset service.

Did you read the note in the docs?

…The first cycle for each sensor, will be incomplete; a sensor tracking daily usage, will start to be accurate the next day after the integration was activated. A sensor tracking monthly usage, will present accurate data starting the first of the next month after being added to Home Assistant.

All those unnecessary commas make it sound like William Shatner is reading it in my head. :crazy_face:

Not sure why you are getting Wh if your sensor is in kWh. It should use the unit of the sensor.

I read the doc, and I saw this. Makes sense, but makes the YEARLY value quite pointless. Waiting 9 month until I get a correct reading? C’mon. :rofl:
Resetting ALL values is useful in some cases, but doesn’t help if I need to reset ALL at once. If you incidently do it during the year, you will need to wait til beginning of next year until you get correct readings.
It would make sense to let me set the value to a desired one. Like setting up your bike computer where you can enter the total mileage from the old one when you install the new one.
Or maybe I misunderstand the underlying ideas.

Write a script. The sequence calls each utility reset you need.

BUT… one other thing to note is that the reset service only works if you have tariffs defined. You don’t appear to have.

You would have to request the new “set value” service be considered by @dgomes

I came across this topic just yesterday. If you want to manually set your utility meter sensor value, you need to follow steps described here (last post by febalci)

1 Like

Thanks krakers. Will try that. At least there’s a workaround. I contacted Diogo and maybe this funtionality can be added to the utility_meter. Seems I’m not the first one with this demand.

1 Like

Would a new service to set the value be good enough ?

1 Like

Sure :smiley: Highly appreciated. That would be very helpful for all kind of needs. :+1:
Btw: If you’re looking at it: It seems the utility_meter does not take the UNIT from the underlying sensor.

- platform: template
  sensors:
    shelly_total_power_consumption:
      friendly_name: 'Total Power Consumption'
      unit_of_measurement: 'kWh'
      value_template: '{{ ((float(states.sensor.........
  shelly_hourly_energy:
    source: sensor.shelly_total_power_consumption
    cycle: hourly
  shelly_daily_energy:
    source: sensor.shelly_total_power_consumption
    cycle: daily
  ......

image

It does, but only on the first run!

If when you create the utility_meter you are using a sensor with the wrong unit, the wrong unit will outlast any change in the configuration.

You must recreate the utility_meter.

1 Like

Also, that’s another way of doing it:

  - platform: template
    sensors:
      monthly_home_energy_corrected:
        friendly_name: "Home Energy Corrected"
        unit_of_measurement: kWh
        value_template: "{{ '%0.1f' | format(states('sensor.monthly_home_energy') | float - 1250) }}"

Please note that “sensor.monthly_home energy” is the utiliity_meter, and the “float - 1250” is the correction which is subtract 1250 kWh from the utility_meter value. So use sensor.monthly_home_energy_corrected for any purpose. This is much easier for me than dealing with db itself. Also, the utility_meter has some bugs i believe, which results in jumps when you restart HA randomly. My utility_meter reads from Aoetec ZWave home energy monitor, but sometimes it jumps lets say from 1450 kWh to 5600 kWh for no obvious reason other than an HA resrtart. Whenever i see this i correct it with the template sensor above…

That is an issue in ZHA support, that has been identified before.

In my case I needed to change for monthly one, so next month I would’t need this template and adjustment anymore.

@dgomes service would be nice :slight_smile:

You can always change that float - 1250 to float -0. I always keep that template sensor and change the number according to my monthly needs.

I know, but don’t like doing that this way. Prefer to change it once in DB and config/.storage/core.restore_state file once. Or by calling service if it will be made available.

Pull Request open:

https://github.com/home-assistant/core/pull/32658

4 Likes

GREAT! Thanks a lot!

Any idea IF it has been integrated yet, or when it should be there?
My problem I have right now is, that it looks like this:

image

In the meantime Shelly add-on switched to the (better) kWh, so it’s completely messed up.
How do I reinitialitze this? First remove those sensors and let them re-install so they pick up the correct “unit_of_measurement”?

It’s available in the “Services” tab

You will need to recreate the sensors, sorry :frowning:

Could you please tell me how to recreate? I deleted the sensor in yaml file but after adding them again they looked like before.
Thanks

That’s the only one I got:

image

2 Likes

that’s the one I added :slight_smile:

It’s the calibrate service…