Energy monitoring - struggling on start

I’m starting with energy consumption monitoring.
And seems I’m missing something crucial because the Energy dashboard shows values that don’t make sense to me (ie total house consumption is 106kWh, for today, as of 11:20 am :wink: )

But readings are wrong even for more basic measurements. Let’s start with it.
Measuring of TV consumption.
It drains about 80W. So I would expect 80Wh after an hour, which is 0.08kWh

Let’s look at the configuration, then the available values and graphs.

pck_socket2:
  mqtt:
    sensor:
      - name: "TV Power"
        state_topic: "shellies/shplug-2/relay/0/power"
        availability_topic: "shellies/shplug-2/online"
        device_class: power
        unit_of_measurement: "W"
        payload_available: "true"
        payload_not_available: "false"
   
  template:
    - sensor:
        - name: "TV Consumption"
          state: "{{ (states('sensor.tv_power')|float  / 1000) | round(2) }}"
          device_class: energy
          state_class: total_increasing
          unit_of_measurement: 'kWh'

Here is what is shown for power and energy sensors by HA history. TBH I would expect TV consumption as by-hour aggregation. Anyway, the value oscillates at about expected value (0.08kWh)

Lets show what shows history card
image
It automatically aggregates by hours (which is what I would expect) but the value is off. It should be 0.08, not 1.14

Energy dashboard is totally off

It shows 9kWh for TV running for 3 hours… This daily total differs from what is shown in the history card above, but this comparison is not important until those values are all off.

Could you please point me to a mistake I’m doing?

Power is momentary, your calculation from W to kWh does not incorporate the time between each sample.

Use the integration integration to properly estimate your kWh sensor instead of what you’re using above.

What do you mean exactly? What integration should I use?

Edit: I just found, probably this? Integration - Riemann sum integral - Home Assistant

Hehe, the integration is called integration, as in calculus. Integration vs differentiation. Integration tells you the area under a curve, which happens to be Wh’s if your sensor is W.

Just to confirm. your info helped to solve my issue. I let myself mark my prev post as a solution since I posted the exact link to docs. Anyway, credits go to you.
I started configuring my devices from reading forums, probably picking some advice from out of context.
Now I took a look at HA docs and obviously there is info about that on the main Energy page.