Manual Utility Meter

I have smart meters, but they dont work and the energy provider seems to have no incentive to fix them anytime soon, so I would still like to track my usage using a manual meter reading and entry into HA.

The meter will be read randomly, i.e. not on a specific day of the month, but as & when I feel like it, and the new value entered into the input_number meter reading.

Here’s how I have set it up, not really sure if it’s correct ??

## input_number.yaml
meter_gas:
  name: Manual Gas Readings
  min: 0
  max: 1000000000
  step: 1
  mode: box

## utility_meter.yaml
util_meter_gas_month:
  unique_id: util_meter_gas_month
  source: input_number.meter_gas
  name: Meter Gas Month
  cycle: monthly

I added the input number about a week ago, (3352) and have only just added the utility_meter using the input_number as the source, as I was unsure how to configure it then.

The utility meter is showing 0, I presume this is because I added the utility after the input number was created.

Obviously a week has now passed, and I would like to take another reading and have the utility meter calculate the usage between the number I entered a week ago, and the new reading taken today.

So based on my configuration above, is that what will happen, for example if I enter a value of 3362 today, will the utility meter subtract and show a value of 10 or ??

I know you may say just enter it and try, but I would prefer not to corrupt the data with test values, and would like to know if my interpretation / configuration is correct.

1 Like

The utility meter did calculate the usage, but it seems impossible to get the sensor or utility meter to be added to the Energy dashboard as a “Gas Source”.

I also created a template sensor but using that as the source for the utility meter still does not allow me to add it as a Gas Source.

sensor:
   name: "Gas Monthly Energy"
   unit_of_measurement: "m³"
   state_class: total_increasing
   device_class: energy
   state: "{{ states('input_number.meter_gas') }}"


util_meter_gas_month:
  unique_id: util_meter_gas_month
  source: sensor.gas_monthly_energy
  name: Meter Gas Month
  cycle: monthly

If anyone else has managed to achieve this, would really appreciate to know how you did it.

I’ve spent a day on this now and not made progress, no selectable sources for “gas” at all.

Please try settings the device_class of the sensor to gas.
Afterwards it might take a while until the sensor shows up.

Thanks for helping, changing the device_class to ‘gas’ did allow me to add the sensor to the Gas Sources in the Energy Dashboard.

But despite waiting 1 day no values are shown. It seems that the sensor.gas_monthly_energy below, simply shows the last value entered and does not subtract the current value from previous value.

I can use Utility Meter pac_util_meter_gas_month to do this calculation and it works, however I cannot add a Utility Meter to the Energy dashboard.

The only sensor / entity that the Energy Dashboard Gas Input will allow me to select is the sensor.gas_monthly_energy sensor above, and that just reflects a value of 0 gas consumption.

So how can I add the pac_util_meter_gas_month utility meter to the Gas Inputs dashboard ?

input_number:
	pac_meter_gas:
	  name: Manual Gas Readings
	  min: 0
	  max: 1000000000
	  step: 1
	  mode: box
	  unit_of_measurement: "m³"

template:
	sensor:
	   # id: sensor.gas_monthly_energy
	   ## 14 Nov=3352 19:Nov=3367 Total = 15 units
	   name: "Gas Monthly Energy"
	   unit_of_measurement: "m³"
	   state_class: total_increasing
	   device_class: gas
	   state: "{{ states('input_number.pac_meter_gas') }}"

utility_meter:
	pac_util_meter_gas_month:
	  unique_id: pac_util_meter_gas_month
	  source: sensor.gas_monthly_energy
	  name: PAC Meter Gas Month
	  cycle: monthly

That’s what the sensor does: it just adds the device_class, measurement, etc to your input number which makes it available to the energy dashboard.

When you now increase the input regularly, the statistics engine should kick in and display the differencees in the dashboard.
For the dashboard, the utility meter isn’t actually needed.

@elfrinjo - thanks, I appreciate your help & patience.

So ok, I have added it to the Gas Input, and incremented the previous value entered yesterday 3367 to 3368, and it now shows consumption of 1 unit for the month instead of including the previous entries.

The initial reading was taken on 14th of the month 3352, is there anyway to fix the data so that the original 3352 on 14th and 3367 on the 19th are reflected in the consumption data ?

No worries :slight_smile:

In the statistics tab of the dev-tools, there is a tool to change readings manually.
However, I have no experience how this affects the long-term stats and dashboard.

If you have multiple additional datapoints and a stable knowledge of SQL, you can add them directly to the statistics table in the recorder database. This is not straight-forward nor supported.

Thanks, unfortunately it’s not working.

I added todays meter readings 3 hours ago, and the gas usage is showing zero.!

Screenshot 2022-11-20 at 8.39.21 PM|690x24

Thats interesting; I expected it to work like like on the last consumption screenshot you posted.
Did the template sensor update to the new value?
Does anything change with the different resolutions (day, month,…) on the energy dashboard?

What if you set the new value of the utility meter with the service utility_meter.calibrate?

my sql is pretty good, I wrote a pythin script to regenerate the data for the statistics but it did not work:

DELETE FROM statistics WHERE metadata_id = 187
INSERT INTO statistics (metadata_id,created,start,state,sum) VALUES(187,'2022-11-14 09:40:00.000000','2022-11-14 00:00:00',3352,0)
INSERT INTO statistics (metadata_id,created,start,state,sum) VALUES(187,'2022-11-19 08:40:00.000000','2022-11-19 00:00:00',3367,15)
INSERT INTO statistics (metadata_id,created,start,state,sum) VALUES(187,'2022-11-20 10:18:00.000000','2022-11-20 00:00:00',3370,18)

I will keep trying different tables.

@parrel - thanks but not sure if that works on the energy dashboard and it looks like I cannot include the date/time in the update data.

You will also have to clear the short term statistics table as the statistics table will be filled from there by an hourly job.

Whats your current status, which things are working, which are not?

So just clear the table:

DELETE FROM statistics_short_term WHERE metadata_id = 187;

At the moment I am testing on a test system with to see what works, have not run anything on live system yet, but nothing is showing.

This ist how it shopuld work:
The datapoints from sensor.gas_monthly_energy are stored into statistics_short_term then
Every hour a statistics job copys the data into the statistics table and calculates the relevant things
The energy-dashboard displays data from statistics.
The graph in the sensor details takes its data from statistics_short_term

So, if sensor.gas_monthly_energy has the correct value, statistics contains datapoints, and the sensor is part of the dashboard it should work

That is VERY helpful, thanks.

I have deleted the statistics_short_term and statistics data for that sensor (167), and yep, every 5 minutes a new entry is added to statistics_short_term table, but what is happening is it is just reflecting the last entered value i.e 3370 and the sum is 0.

It wont pickup the previous input_number entries.

And as you correctly said, on the hour a record is added to to the statistics table but unfortunately the sum is 0:

The sum seems to be created from differences in the state colums. So it should increase when you update the input. As the energy dashboard shows the consumption (differences) instead of the meter-total this should be fine.

So as long as you calculate the sum on you own, you should be able to insert older values.
Reagrding the sum you could try this on your testsystem: update the short term stats and set sum=state

Hi,

Sorry I’m a bit late to this, and having read this thread entirely, may I just ask if it is easier to add a sensor to your meter(s) to automatically record the consumption?

You said:

I have smart meters, but they dont work and the energy provider seems to have no incentive to fix them anytime soon, so I would still like to track my usage using a manual meter reading and entry into HA

Whether they are smart or not doesn’t really matter as I have finally managed to get a dumb, analog meter to work, and is now accurately recording my gas usage. Surely a Smart Meter must have some form of pulsed output that can be sent into HA instead of manually recording everything?

Just thought I’d ask. BTW did you get it working with manual inputs??

Cheers,

Mike.

Any update on your investigation?
I’m on the same boat, trying to recrete a utility meter via manual inputs, also tried to clean up database directly and set values but not luck making anything work.

I’m sure many people would like to have this as an official integration but I guess meters in general don’t work “backwards” in HA.

Would appreciate if you made it further on your investigations to share any findings.

1 Like