Using a Utility Meter and a static value to create gas meter reading

Hello,
I’m trying to create a actual gas meter reading for my dumb gas meter in the basement.
I have a esphome which nicely reports current consumption, it works also nice with the energy dashboard with created utility meters.
However what I want to achieve is a “overall” meter reading to reflect exactly the number of the gasmeter in the basement.
To achieve this I created a numeric input “initial meter value” and then wanted to create a helper to sum up the initial value with the utility meter value. But this only works as long as not restart happens, as the utility meter is then reset to 0:

So I’d need a way to store a ever increasing number and keep adding the diffs of the utility meter value? Any ideas how this can be done?

Hi Reinhard,

If I understand your question correctly, you are wanting to be able to read the current physical gas meter value, and have that increase in HA as your gas consumption increases. The HA reading will then mirror the physical gas meter reading?

I do something similar, see screengrab below

I set up a meter ‘helper’ called Gas Meter, and it uses the output from the actual gas meter sensor as the base of the data. This should then just keep increasing. What you then have to do is ‘calibrate’ that Meter Helper to then show the current, physical gas meter reading, this will then increase as you consume gas, and should mirror the reading on the meter.

Once you have setup the Meter Helper which you will use for the current gas meter value, you need to go to Developer Tools > Services (there are two modes of use here yaml mode and UI mode - I use yaml mode)

If you cut and paste the following into the yaml mode box and then click “Call Service” box at the lower right, you will set the meter helper to the current gas meter value.

service: utility_meter.calibrate #This will call the required calibrate function
target:
  entity_id: sensor.gas_meter #This is the id of the meter helper you have set up to store the gas meter reading
data:
  value: "206439" #This is the up-to-date reading from your gas meter which you want to set the meter helper to

I hope that helps,

Cheers,

Mike.

1 Like

Hi Mike,

Thanks for your solution. I think my problem is that the sensor value reports total consumption since start of the esphome that counts “ticks” and reports a constant increasing consuption value. This value is kept as long as the esp is running, if it restarts its reset to zero.
This would mean upon restart the calibration value would be added with 0.
I somehow need a way to persist the final value, or is that your helper metric?

Hi Reinhard,

The Meter Helper should just log the increasing value. If you reset HA it should remember the value and continue logging the increase from the value when you reset HA.

I hope that helps,

Cheers,

Mike

Ah, I think i figured it out with your help!
Setting / calibrating the utility meter itself is the key! Seems ok now, lets see how this works!
I had a static input as the base and adding to it didn’t work.

Thanks a lot, Mike!

1 Like