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ā would distribute the usage between readings evenly to the Intervall between readings.
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.
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.
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:
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.
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?