Manual input for electricity, gas and water consumption

I got a bit further by defining a template sensor in configuration.yaml:

(First I created an “input_number” [stromablesen] helper to input the actual values)

input_number:
  stromablesen:
    initial: null
    editable: true
    min: 0
    max: 100000
    step: 1
    mode: box
    unit_of_measurement: kWh
    icon: mdi:meter-electric
    friendly_name: StromAblesen

Then I created a template sensor in Configuration.yaml:

template:
 sensor:
   name: "stromverbrauch"
   unit_of_measurement: kWh
   state_class: total_increasing
   device_class: energy
   state: "{{ states('input_number.stromablesen') }}"

I am now able to create the “Utility Meter”.

sensor:
  strom:
    state_class: total_increasing
    source: sensor.stromverbrauch
    status: collecting
    last_period: 0
    last_reset: 2022-11-04T00:33:23.138130+00:00
    unit_of_measurement: kWh
    device_class: energy
    icon: mdi:counter
    friendly_name: Strom

But still no luck in using the final “strom” Utility Meter sensor on the Energy Dashboard. I am not able to select it as a energy source.

What am I doing wrong?

Edit:
I checked the definition of the metadata on the database. The unit of measure was recorded as “KW” even though I specified “kWh” when creating the sensors. After manually modifying the database records, I was able to add the “Utility Meter” to the Energy Dashboard.

SELECT * FROM `statistics_meta` WHERE statistic_id = "sensor.strom";
40	sensor.strom	recorder	kW	0	1	NULL	

After changing the unit from “kW” to “kWh” I was able add the sensor “strom” to the energy Dashboard.

3 Likes