Electrical energy tracking not working correctly

I have read many posts in the forums and the official documentation on the topic of electrical energy tracking. However my results are incorrect, because I don’t think I understand the help I am reading properly, I am not sure, hence this post.

I have around 30 devices being tracked for power consumption and my energy dashboard data is not right and I don’t know why. I am going to discuss two of the power sensors and their associated configuration. They are fan heaters which both pull very close to 2Kw each when running. [They have stupid names so the kids don’t trigger them in Alexa]

From the two power sensors I am using a integral sensor to convert the reported watts into Kwh and the numbers here are about right. Here is my sensor YAML for this

# Pluto #
- platform: integration
  unique_id: 12ef4c3c-5b9f-465b-8519-2f657abbddc5
  source: sensor.pluto_power
  unit_prefix: k
  method: left
  round: 3
  name: pluto_kwh

# Mars Bin #
- platform: integration
  unique_id: 41d2592d-e07d-479e-baa6-09b175648ab1
  source: sensor.mars_bin_power
  unit_prefix: k
  method: left
  round: 3
  name: mars_bin_kwh

If I look at the state of one of the above sensors this is the result, which looks the same as the Tuya Smart Life app reports for the same device over the same period.

Up to here I think it’s pretty simple and easy. The only thing I am not sure about is that this is recording a “total” and not “total_increasing” and I am not if and how this is important for how to the data is used when reporting it in other areas.

I have another sensor which combines “Pluto and Mars” output’s and reports that output into the energy dashboard, grid consumption. This contains a bunch of energy combining sensors so that I can see where our watts are being used.

The YAML for that is taken from the energy monitoring guide listed on the HA community cookbook.

# Climate all Energy #
- sensor:
    - <<: *cumulator_sensor
      name: Climate all energy
      unique_id: "86462a92-c176-4eeb-a9b9-8bb0e53e7a3f"
  trigger:
    - <<: *cumulator_trigger
      entity_id:
        - sensor.pluto_kwh
        - sensor.mars_kwh

The statistics data in this sensor also looks to be about right. It is essentially the sum of the input Kwh sensor state values.

state_class: total_increasing
last_good:
  pluto_kwh: 0.522
  self: 1.036
  mars_bin_kwh: 0.514
unit_of_measurement: kWh
device_class: energy
icon: mdi:lightning-bolt
friendly_name: Climate all energy

All good so far but, I noticed that the energy dashboard isn’t quite reporting what was consumed today accurately [bit less] and this is where I wonder about the total vs total_increasing difference.

So I created a shim sensor.

# Pluto #
- sensor:
    - <<: *cumulator_sensor
      name: pluto total energy
      unique_id: b14aad7d-90e4-4930-ad04-ae8ff9a4ebf1
  trigger:
    - <<: *cumulator_trigger
      entity_id: sensor.pluto_kwh

which records the output of the integration sensors as a kWh total_increasing sensor

      device_class: energy
      unit_of_measurement: kWh
      state_class: total_increasing

and then pointed the Climate All energy sensor to those shim sensors.

# Climate all Energy #
- sensor:
    - <<: *cumulator_sensor
      name: Climate all energy
      unique_id: "86462a92-c176-4eeb-a9b9-8bb0e53e7a3f"
  trigger:
    - <<: *cumulator_trigger
      entity_id:
        - sensor.pluto_total_energy
        - sensor.mars_total_energy

The state values of the Kwh integration sensors, the “shim” sensor and the combined “climate total” sensors are mathematically identical; but as far as I can tell the energy dashboard value for “Climate Total” for today for instance is less than it should be [when viewed daily] when the “Cumulative Sensor” is being fed directly with the integral sensor output.

It does seem to work correctly when the Cumulative sensor is being fed by the total_increasing sensor, but as I said, I am confused and I did not find a topic which unpicks this in more detail than the straight power / energy conversion issue.

If you adults dont need to control them, you can disable the control over Alexa in the Voice Assistant settings.

As for your entities, I dont work with cumulators, but as I read your post you are just trying to get the sum of the integrations?
If you want a sum, why not just create either a group sensor with “sum” or a template sensor with them sumed with code?

Hi John and thanks for answering - the shim sensor is proving very accurate and so I am reluctant to brake it to test a sum sensor. It 100% did not accumulate correctly when KWH was just a total which was then summed. Summing a series of total_increasing “shim” sensors is working accurately and without spending allot of time [I don’t have] in the SQLite database with a calculator . . . I am not sure I am going to get much further.

Thanks also for the tip about Alexa, we do unfortunately need to control them with that solution on occasion.