Individual device detail usage

I am struggling to figure out why my hotwater reports incorretly for my energy dashboard. The program is the same for other devices (tiny home) and it reports fine. What am I missing ?

# Energy Monitoring Package for Refoss EM16

template:
  - sensor:
      # Power sensors (combining A + B pairs)
      - name: "Main Power"
        unique_id: main_power_total
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: >
          {{ (states('sensor.em16_a1_power') | float(0)) + 
             (states('sensor.em16_b1_power') | float(0)) }}
      
      - name: "Tiny Home Power"
        unique_id: tiny_home_power_total
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: >
          {{ (states('sensor.em16_a2_power') | float(0)) + 
             (states('sensor.em16_b2_power') | float(0)) }}
      
      - name: "Shop Office Power"
        unique_id: shop_office_power_total
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: >
          {{ (states('sensor.em16_a3_power') | float(0)) + 
             (states('sensor.em16_b3_power') | float(0)) }}
      
      - name: "Dryer Power"
        unique_id: dryer_power_total
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: >
          {{ (states('sensor.em16_a4_power') | float(0)) + 
             (states('sensor.em16_b4_power') | float(0)) }}
      
      - name: "Hot Tub Power"
        unique_id: hot_tub_power_total
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: >
          {{ (states('sensor.em16_a5_power') | float(0)) + 
             (states('sensor.em16_b5_power') | float(0)) }}
      
      - name: "Hot Water Tank Power"
        unique_id: hot_water_tank_power_total
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: >
          {{ (states('sensor.em16_a6_power') | float(0)) + 
             (states('sensor.em16_b6_power') | float(0))  }}

      # Energy sensors (kWh from power sensors)
      - name: "Main Energy"
        unique_id: main_energy_total
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {{ states('sensor.main_energy_riemann') }}

      - name: "Tiny Home Energy"
        unique_id: tiny_home_energy_total
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {{ states('sensor.tiny_home_energy_riemann') }}

      - name: "Shop Office Energy"
        unique_id: shop_office_energy_total
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {{ states('sensor.shop_office_energy_riemann') }}

      - name: "Dryer Energy"
        unique_id: dryer_energy_total
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {{ states('sensor.dryer_energy_riemann') }}

      - name: "Hot Tub Energy"
        unique_id: hot_tub_energy_total
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {{ states('sensor.hot_tub_energy_riemann') }}

      - name: "Hot Water Tank Energy"
        unique_id: hot_water_tank_energy_total
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: total_increasing
        state: >
          {{ states('sensor.hot_water_tank_energy_riemann') }}

sensor:
  # Riemann sum integral sensors to convert W to kWh
  - platform: integration
    source: sensor.main_power
    name: main_energy_riemann
    unique_id: main_energy_riemann
    unit_prefix: k
    round: 2
    method: trapezoidal
  
  - platform: integration
    source: sensor.tiny_home_power
    name: tiny_home_energy_riemann
    unique_id: tiny_home_energy_riemann
    unit_prefix: k
    round: 2
    method: trapezoidal
  
  - platform: integration
    source: sensor.shop_office_power
    name: shop_office_energy_riemann
    unique_id: shop_office_energy_riemann
    unit_prefix: k
    round: 2
    method: trapezoidal
  
  - platform: integration
    source: sensor.dryer_power
    name: dryer_energy_riemann
    unique_id: dryer_energy_riemann
    unit_prefix: k
    round: 2
    method: trapezoidal
  
  - platform: integration
    source: sensor.hot_tub_power
    name: hot_tub_energy_riemann
    unique_id: hot_tub_energy_riemann
    unit_prefix: k
    round: 2
    method: trapezoidal
  
  - platform: integration
    source: sensor.hot_water_tank_power
    name: hot_water_tank_energy_riemann
    unique_id: hot_water_tank_energy_riemann
    unit_prefix: k
    round: 2
    method: trapezoidal

Change your Reimann Integrals method to ‘left’

Thanks Geoff with a G :).
All of them ??

Whilst in theory trapezoidal is the most accurate, it only works where the source value is changing sub-minute and not excessively at each change.

Where the source is a switch with a step change, and goes from 0 to a high value after many hours of “off”, trapezoidal will record half-use over the off period and give a very inflated wrong result.

In general, in HA, always use “left” as it always works

Thanks Geoff, that worked.
Last question as I see a lot of different information. Can you get individual device costs on the energy page with a TOU entitity ? Works fine for Base meter.

I am no expert on the finer detail of the Energy Dashboard, it was just obvious to me that you were using an inappropriate Reimann method.

As far as I know, Time of use energy rate entity works only with the primary sensors, not the individual use ones. I believe that you need to set up your own template sensors.