Utility meter to calculate kWh while water heaters are running

Hi all, I need some assistance with creating a utility meter to track my water heater kWh usage when they are on during the day. I have my water heaters turn on twice daily so I would like this to reflect in my Energy dashboard. I have created a template sensor off an Effergy hub that measure the current kWh the water heaters are using. My issue is when I create a utility meter using this template sensor and the water heaters turn on, it starts counting from the initial live kW reading, for example, if the water heater draws 2.7kW when turned on, the meter starts counting from 2.7kW and starts increasing even after a few minutes of the water heater running. As I understand it, if the water heater’s draw is 2.7kW, it should only have consumed 2.7kW after an hour being on, unless I have this wrong?

My current template sensor looks as per below:

 geyser_total_usage_kw:
        friendly_name: "Geyser Total Usage"
        unit_of_measurement: 'kWh'
        device_class: energy
        value_template: "{{ (states ('sensor.power_usage_810238') |float / 1000) |round (2) }}"

And customize.yaml

sensor.geyser_total_usage_kw:
  state_class: total_increasing
  last_reset: '1970-01-01T00:00:00+00:00'  

The above gives me a live reading of the draw of the water heater. I would like this to be added to the energy dashboard as a device to track the kWh as well as to the Electricity grid as usage.

When I add the template sensor as is without creating a utility meter, it seems to calculate but it shows as a negative value and only calculates the cost (nagative value) with the kW stuck on “0”.
The cost is set as static 2.65 ZAR per KW

If anyone knows what I SHOULD do here, please offer your assistance.

Thanks

If you are monitoring instantaneous power you can use the integration platform to change from power to energy. I cut and pasted one of mine below and changed to your sensors.

sensor:
  - platform: integration
    source: sensor.power_usage_810238
    name: geyser_total_usage_kw
    round: 3
    unit_prefix: k
    unit_time: h

You might find the Powercalc HACS component useful for this, it does a great job at keeping track of kWh on a device-by-device basis. I use it across all my devices and it’s really helped to dial in the accuracy of my meters.