Utility Meter - manually enter current total value

I’ll give that a shot.

Thanks

Good point but I was listing what was needed for a Template Sensor alone (as has been done by others and posted throughout the two recent blog threads). Incorporating it with Utility Meter is a good tip.

Not an attribute but a separate integration.

1 Like

Good idea. Tried it. No dice :frowning:
Also the energy-meter doesn’t pick up the unit of measurement of the base-sensor.

From the dev-tools

state_class: measurement
last_reset: '2021-08-05T10:08:30.920250+00:00'
source: sensor.home_energy
status: collecting
last_period: 0
meter_period: monthly
friendly_name: home_energy_monthly
icon: mdi:counter

I’m not sure if the problem lies between base-sensor and utility-meter or between utility-meter and energy-dashboard.
It possibly boils down to the base-sensor having some kind of impact on the energy-dashboard, and being a template it is not supported jet.

After fiddling around with my existing ESPHome sensors as a base sensor, I finally got the utility meter to show up in the grid selector.

What did it (I think but I do not understand): I changed the period to “daily”. After a reboot, the energy meter picked up the unit of measurement and was selectable as grid source.

It stayed selectable even after changing the period back to monthly and another reboot.

Though now I’m not sure, if this all will help in achieving my initial goal. The daily energy will still be 0 no matter how often I “calibrate” the utility meter.

I was hoping “something” :flushed: would distribute the usage between readings evenly to the Intervall between readings.

Hi @seanomat did you find some solution for your problem? I am looking to do the same (manually enter the month consume 1 time per month) ….

I meanwhile installed measurement-clamps to my distribution box.

But I had it working before, by entering the current reading in an input_number and using this as the base for an utility_meter, like suggested somewhere above. I think the utility-meter is not necessary, as long as the input_number has the correct attributes.

But you will always have spikes when you enter a new reading.

1 Like

I am trying to get manual gas tracking with input_number and utility_meter like so:

input_number:
  duju_skaitliukas:
    name: "Dujų Skaitliukas"
    mode: box
    unit_of_measurement: "m³"
    icon: mdi:fire
    step: 1
    min: 0
    max: 1000000
    
utility_meter:
  gas:
    source: input_number.duju_skaitliukas
    cycle: monthly

But the “Gas Consumption” section in the Energy configuration does not give a selection:

I also tried to switch to cycle: daily but that did not help either. What am I missing? Is it the unit of measurements that is not recognized?

Does the utility meter have all the required attributes in dev tools, like

state_class: total_increasing
device_class: gas
unit_of_measurement: m³

Did you wait 2 hours, after creating these entities for the statistics to be calculated?

Yup, still selection is empty after 2 hours.

device_class and unit_of_measurement is not there:

Hm. What kind of additional configuration am I missing? Can I just add device_class and unit_of_measurement under utility_meter.gas even if these are not documented?

The attributes are missing because the underlying entity is missing them. I’m not sure if you can use an input as the source. You could try and add the missing attributes to the input_number through customizations.
Or better: create an intermediate template sensor, based on your input, and as source for the utility_meter. If you use the modern way to define your template sensor, you can definitely add the missing attributes.

I just used the same configuration in another Home Assistant instance and now developer tools show that sensor.gas has a proper unit_of_measurement:

And now also I can select sensor.gas in the Energy settings.

Back to the first Home Assistant machine that had problems. I have recreated the sensors using the exact configuration from the second machine where it worked, and now developer tools show exactly the same configuration as in the second machine:

But still the “Gas usage” selection reports that “No matching statistics found”. Now I am a bit at a loss what to try next.

Found the solution in Energy dashboard displays "No statistics" despite working utility meters - #2 by Oliv

Even if the developer tools show the correct unit of measurement, it was missing in the DB:

sqlite> SELECT * FROM statistics_meta GROUP BY id;
1|sensor.shellyplug_s_9dd989_power|recorder|W|1|0
2|sensor.shellyplug_s_9dd989_energy|recorder|kWh|0|1
3|sensor.gas|recorder||0|1

After fixing that with UPDATE statistics_meta SET unit_of_measurement="m³" WHERE id=3; now I can select sensor.gas in the Energy configuration.

1 Like

Hi can you please share your final code of this counter? For me, your meter works, the problem is that after an hour, the costs are restored to zero (I changed the cycle from monthly to hourly as part of the test)
In the energy tab, I do not see any costs, does it show costs for you?

My final configuration is:

input_number:
  gas_meter:
    mode: box
    unit_of_measurement: "m³"
    icon: mdi:fire
    step: 1
    min: 0
    max: 1000000
    
utility_meter:
  gas:
    source: input_number.gas_meter
    cycle: monthly

In the Energy tab, I also do not see any costs:

But in the Developer Tools page I see that the sensor.gas_cost sensor is being updated:

1 Like

yes, it also shows energy costs, but after restarting Home Assistat, the value is zero

You need to add the cost sensor to the recorder. Otherwise it will not show in energy-dashboard and it will reset on reboot.

unfortunately it doesn’t help, it’s probably some global problem in HA

1 Like

There already is a feature request for this: Manual input for electricity, gas and water consumption