Energy dashboard: how to add integral template sensor to dashboard

Hi,

I have some powerplugs.
Some of them only report W, V and A but do not consumption of energy in kWh

So I created a template sensor as follows

  # ---------------------------------------------------
  - name: "Elektriciteit datacenter power"
    unique_id: "sensor.elektriciteit_datacenter_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_108_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_108_energy_power') | is_number }}

and to have the total energy consumption, I created an integration sensor as follows:

  # ---------------------------------------------------
  - name: "Elektriciteit datacenter energy"
    unique_id: "sensor.elektriciteit_datacenter_energy"
    platform: integration
    source: sensor.elektriciteit_datacenter_power
    unit_time: h

However, It can not add the sensor.elektriciteit_datacenter_energy to the “individual devices” of my Energy Dashboard section. I receive following error:

2023-08-04_16-16-08

But I can NOT add a device class to the integration sensor.

How can I add my custom “integration sensor” to the energy dashboard
Any advice on this?

kind regards,
Bart

nobody? Really?

Try adding a device class of power to the first sensor. The integration sensor should then automatically change it to a device class of energy for itself (at least it does using the integration helper in the UI).

hi @brooksben11

I changed my sensor to

  # ---------------------------------------------------
  - name: "Elektriciteit datacenter power"
    unique_id: "sensor.elektriciteit_datacenter_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_108_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_108_energy_power') | is_number }}

It gives no error, but the integral does not work anymore: no increment of values anymore:

# ---------------------------------------------------
  - name: "Elektriciteit datacenter energy"
    unique_id: "sensor.elektriciteit_datacenter_energy"
    platform: integration
    source: sensor.elektriciteit_datacenter_power
    unit_time: h

any other suggestions?

grtz
Bart

PS:
But I can add the sensor.elektriciteit_datacenter_energy to my energy dashboard now!!!

Has the power value changed since you updated it though? The integral is only calculated on changes in the source sensor.

Just yesterday I went through very similar exercie and here are my learnings :slight_smile:
Make sure that both power and energy sensors are included in recorder.
Customize the energy sensor to add the state_class:

customize:
  sensor.elektriciteit_datacenter_energy:
    state_class: total_increasing

Enforce Integral sensor configuration to be more resistant to rarely changing values. Also I think it might be more usefull to calculate energy consumtion in kWh rather than Wh. So add 2 lines to your sensor (last 2 in example below):

# ---------------------------------------------------
  - name: "Elektriciteit datacenter energy"
    unique_id: "sensor.elektriciteit_datacenter_energy"
    platform: integration
    source: sensor.elektriciteit_datacenter_power
    unit_time: h
    method: left
    unit_prefix: k

Many thanx @mirekmal !

I’ll try this out.
However yesterday I was playing with the unit_prefix: k,which give some strange results:
Around 22:30, I added the unit_prefix to my integration, but energy went from 7072Wh to 7072000Wh!!! So I reverted this back

WOW, than some serious devices you must have in your home :smiley:
But seriously, I have also some serious misreading of owen consumtion before I changed integral sensor to method: left. Lets first check if other changes fix your problem and what would be the reading afterwards.

1 Like

to isolate everything, I created new sensors:

  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_power_test1"
    unique_id: "sensor.elektriciteit_datacenter_power_test1"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_108_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_108_energy_power') | is_number }} 

  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_power_test2"
    unique_id: "sensor.elektriciteit_datacenter_power_test2"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_108_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_108_energy_power') | is_number }} 

  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_power_test3"
    unique_id: "sensor.elektriciteit_datacenter_power_test3"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_108_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_108_energy_power') | is_number }} 

  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_power_test4"
    unique_id: "sensor.elektriciteit_datacenter_power_test4"
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_108_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_108_energy_power') | is_number }}

and

  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_energy_test1"
    unique_id: "sensor.elektriciteit_datacenter_energy_test1"
    platform: integration
    source: sensor.elektriciteit_datacenter_power_test1
    unit_time: h
    
  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_energy_test2"
    unique_id: "sensor.elektriciteit_datacenter_energy_test2"
    platform: integration
    source: sensor.elektriciteit_datacenter_power_test2
    unit_time: h
    method: left
    unit_prefix: k

  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_energy_test3"
    unique_id: "sensor.elektriciteit_datacenter_energy_test3"
    platform: integration
    source: sensor.elektriciteit_datacenter_power_test3
    unit_time: h
    method: left
    unit_prefix: k

  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_energy_test4"
    unique_id: "sensor.elektriciteit_datacenter_energy_test4"
    platform: integration
    source: sensor.elektriciteit_datacenter_power_test4
    unit_time: h
    method: left
    unit_prefix: k

and

# -------------------------------------------
# POWERPLUGS - ENERGY
# -------------------------------------------
  sensor.elektriciteit_datacenter_energy_test3:
    state_class: total_increasing
  sensor.elektriciteit_datacenter_energy_test4:
    state_class: total_increasing

W’ll see what happens

OK,
everything seems to be more or less settled now:

sensors:

tasmota-108 ENERGY Total:

the information that I receive directly from the tasmota plug

elektriciteit_datacenter_energy_xxx

the integral (Riemann sum) of the power (in W) that get from the tasmota plug

values seem to be (more or less) equal, so integral is correct. Energy is expressed in KWh
So far so good.

Only for some other plugs (shelly plug, and TV Powerplug) there is a difference between the energy value coming directly from the plug and the value calculated by the integral.
Defenitions are the same:

    unit_time: h
    method: left
    unit_prefix: k

but the result is different …

I’ll try with with trapezoidal and right and see what happens…

grtz
B

Is there any way you can show me the entire file? I am new to this and I am trying to do the same to track energy usage of the devices detected in Sense. The “state_class: total_increasing” is confusing me.

Also, how do you get it to reset the counter after 24-hours? I am trying to mimic the Kasa plugs I have with “Today’s” consumption" where they reset every 24-hours. I imagine I could also translate that into the Kasa emulated plugs I have, too.

Here is what I have and I did not duplicate the original sensor with new sensors:

---------------------------------------------------

  • name: “furnace_energy”
    unique_id: “sensor.furnace_energy”
    platform: integration
    source: sensor.furnace_usage_5
    unit_time: h

Hi @kahilzinger

First, I defined my custom sensors:

template:
  sensor:



  # ---------------------------------------------------
  - name: "Elektriciteit totaal power"
    unique_id: "sensor.elektriciteit_totaal_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ 
        states('sensor.elektriciteit_n00_power') | float(default=0.0) + 
        states('sensor.elektriciteit_n01_power') | float(default=0.0) +
        states('sensor.elektriciteit_n02_power') | float(default=0.0) +
        states('sensor.elektriciteit_n03_power') | float(default=0.0) +
        states('sensor.elektriciteit_n91_power') | float(default=0.0) +
        states('sensor.elektriciteit_n92_power') | float(default=0.0)
      }}

  # ---------------------------------------------------
  - name: "Elektriciteit onbekend power"
    unique_id: "sensor.elektriciteit_onbekend_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.elektriciteit_meter_power') | float(default=0.0) -
         states('sensor.elektriciteit_totaal_power') | float(default=0.0) 
      }}


  # ---------------------------------------------------
  - name: "Elektriciteit subtotaal 1 power"
    unique_id: "sensor.elektriciteit_subtotaal_1_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ 
        states('sensor.elektriciteit_tv_power') | float(default=0.0) +
        states('sensor.elektriciteit_kast_power') | float(default=0.0) +
        states('sensor.elektriciteit_bureau_power') | float(default=0.0) +
        states('sensor.elektriciteit_koelkast_power') | float(default=0.0) +
        states('sensor.elektriciteit_koelkast_smeg_power') | float(default=0.0)
      }}

  # ---------------------------------------------------
  - name: "Elektriciteit subtotaal 2 power"
    unique_id: "sensor.elektriciteit_subtotaal_2_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ 
        states('sensor.elektriciteit_datacenter_power') | float(default=0.0) +
        states('sensor.elektriciteit_proxmox_power') | float(default=0.0) + 
        states('sensor.elektriciteit_srv_19_power') | float(default=0.0) +
        states('sensor.elektriciteit_gasketel_power') | float(default=0.0) +
        states('sensor.elektriciteit_kelder_werktafel_power') | float(default=0.0) +
        states('sensor.elektriciteit_kelder_werkbank_power') | float(default=0.0)
      }}

  # ---------------------------------------------------
  - name: "Elektriciteit n00 power"
    unique_id: "sensor.elektriciteit_n00_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.elektriciteit_tv_power') | float(default=0.0) +
         states('sensor.elektriciteit_kast_power') | float(default=0.0) +
         states('sensor.elektriciteit_koelkast_power') | float(default=0.0) +
         states('sensor.elektriciteit_koelkast_smeg_power') | float(default=0.0)
      }}
  # ---------------------------------------------------
  - name: "Elektriciteit n01 power"
    unique_id: "sensor.elektriciteit_n01_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ 
         states('sensor.elektriciteit_bureau_power') | float(default=0.0)
      }}

  # ---------------------------------------------------
  - name: "Elektriciteit n02 power"
    unique_id: "sensor.elektriciteit_n02_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}
  # ---------------------------------------------------
  - name: "Elektriciteit n03 power"
    unique_id: "sensor.elektriciteit_n03_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}

  # ---------------------------------------------------
  - name: "Elektriciteit n91 power"
    unique_id: "sensor.elektriciteit_n91_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ 
         states('sensor.elektriciteit_datacenter_power') | float(default=0.0) +
         states('sensor.elektriciteit_proxmox_power') | float(default=0.0) + 
         states('sensor.elektriciteit_srv_19_power') | float(default=0.0) +
         states('sensor.elektriciteit_gasketel_power') | float(default=0.0) +
         states('sensor.elektriciteit_diepvriezer_power') | float(default=0.0) +
         states('sensor.elektriciteit_wasmachine_power') | float(default=0.0) +
         states('sensor.elektriciteit_kelder_werktafel_power') | float(default=0.0) +
         states('sensor.elektriciteit_kelder_werkbank_power') | float(default=0.0)
      }}

  # ---------------------------------------------------
  - name: "Elektriciteit n92 power"
    unique_id: "sensor.elektriciteit_n92_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}










  # ---------------------------------------------------
  - name: "Elektriciteit koelkast power"
    unique_id: "sensor.elektriciteit_koelkast_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}

  # ---------------------------------------------------
  - name: "Elektriciteit koelkast voltage"
    unique_id: "sensor.elektriciteit_koelkast_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}



  # ---------------------------------------------------
  - name: "Elektriciteit koelkast_smeg power"
    unique_id: "sensor.elektriciteit_koelkast_smeg_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p07_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p07_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit koelkast_smeg voltage"
    unique_id: "sensor.elektriciteit_koelkast_smeg_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p07_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p07_voltage') | is_number }} 



  # ---------------------------------------------------
  - name: "Elektriciteit datacenter power"
    unique_id: "sensor.elektriciteit_datacenter_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_108_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_108_energy_power') | is_number }} 
  # ---------------------------------------------------
  - name: "Elektriciteit datacenter voltage"
    unique_id: "sensor.elektriciteit_datacenter_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_108_energy_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_108_energy_voltage') | is_number }} 



  # ---------------------------------------------------
  - name: "Elektriciteit kast power"
    unique_id: "sensor.elektriciteit_kast power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_109_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_109_energy_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit kast voltage"
    unique_id: "sensor.elektriciteit_kast voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_109_energy_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_109_energy_voltage') | is_number }} 



  # ---------------------------------------------------
  - name: "Elektriciteit bureau power"
    unique_id: "sensor.elektriciteit_bureau_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_111_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_111_energy_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit bureau voltage"
    unique_id: "sensor.elektriciteit_bureau_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_111_energy_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_111_energy_voltage') | is_number }} 



  # ---------------------------------------------------
  - name: "Elektriciteit gasketel power"
    unique_id: "sensor.elektriciteit_gasketel_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_113_energy_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_113_energy_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit gasketel voltage"
    unique_id: "sensor.elektriciteit_gasketel_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.tasmota_113_energy_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tasmota_113_energy_voltage') | is_number }} 


  # ---------------------------------------------------
  - name: "Elektriciteit wasmachine power"
    unique_id: "sensor.elektriciteit_wasmachine_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p10_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p10_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit wasmachine voltage"
    unique_id: "sensor.elektriciteit_wasmachine_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p10_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p10_voltage') | is_number }} 



  # ---------------------------------------------------
  - name: "Elektriciteit diepvriezer power"
    unique_id: "sensor.elektriciteit_driepviezer_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.my_n91_p03_powerplug_p12_diepvriezer_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.my_n91_p03_powerplug_p12_diepvriezer_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit diepvriezer voltage"
    unique_id: "sensor.elektriciteit_diepvriezer_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.my_n91_p03_powerplug_p12_diepvriezer_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.my_n91_p03_powerplug_p12_diepvriezer_voltage') | is_number }} 



  # ---------------------------------------------------
  - name: "Elektriciteit ProxMox power"
    unique_id: "sensor.elektriciteit_proxmox_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.shellyplug_s_69e086_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.shellyplug_s_69e086_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit ProxMox voltage"
    unique_id: "sensor.elektriciteit_proxmox_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}

  # ---------------------------------------------------
  - name: "Elektriciteit SRV-19 power"
    unique_id: "sensor.elektriciteit_srv_19_power"
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}

  # ---------------------------------------------------
  - name: "Elektriciteit SRV-19 voltage"
    unique_id: "sensor.elektriciteit_srv_19_voltage"
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}



  # ---------------------------------------------------
  - name: "Elektriciteit TV power"
    unique_id: "sensor.elektriciteit_tv_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.0xa4c13832d824a383_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.0xa4c13832d824a383_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit TV voltage"
    unique_id: "sensor.elektriciteit_tv_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.tv_powerplug_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.tv_powerplug_voltage') | is_number }} 


  # ---------------------------------------------------
  - name: "Elektriciteit Kelder werktafel power"
    unique_id: "sensor.elektriciteit_kelder_werktafel_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p08_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p08_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit Kelder werktafel voltage"
    unique_id: "sensor.elektriciteit_kelder_werktafel_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p08_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p08_voltage') | is_number }} 


  # ---------------------------------------------------
  - name: "Elektriciteit Kelder werkbank power"
    unique_id: "sensor.elektriciteit_kelder_werkbank_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p09_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p09_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit Kelder werkbank voltage"
    unique_id: "sensor.elektriciteit_kelder_werkbank_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p09_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p09_voltage') | is_number }} 



















  # ---------------------------------------------------
  - name: "Elektriciteit Kring A power"
    unique_id: "sensor.elektriciteit_kring_a_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}

  # ---------------------------------------------------
  - name: "Elektriciteit Kring A voltage"
    unique_id: "sensor.elektriciteit_kring_a_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
        {{ "0" | float(default=0.0) }}




  # ---------------------------------------------------
  - name: "Elektriciteit Kring B power"
    unique_id: "sensor.elektriciteit_kring_b_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p08_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p08_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit Kring B voltage"
    unique_id: "sensor.elektriciteit_kring_b_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p08_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p08_voltage') | is_number }} 




  # ---------------------------------------------------
  - name: "Elektriciteit Kring C power"
    unique_id: "sensor.elektriciteit_kring_c_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p09_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p09_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit Kring C voltage"
    unique_id: "sensor.elektriciteit_kring_c_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p09_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p09_voltage') | is_number }} 



  # ---------------------------------------------------
  - name: "Elektriciteit Kring D power"
    unique_id: "sensor.elektriciteit_kring_d_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p10_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p10_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit Kring D voltage"
    unique_id: "sensor.elektriciteit_kring_d_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p10_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p10_voltage') | is_number }} 



  # ---------------------------------------------------
  - name: "Elektriciteit Kring E power"
    unique_id: "sensor.elektriciteit_kring_e_power"
    icon: mdi:flash
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p11_power') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p11_power') | is_number }} 

  # ---------------------------------------------------
  - name: "Elektriciteit Kring E voltage"
    unique_id: "sensor.elektriciteit_kring_e_voltage"
    icon: mdi:sine-wave
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    state: >
      {{ states('sensor.smart_plug_p11_voltage') | float(default=0.0) }}
    availability: >
      {{ states('sensor.smart_plug_p11_voltage') | is_number }}

Than, I created some integration sensors:

sensor:

  # ---------------------------------------------------
  - name: "Elektriciteit totaal energy"
    unique_id: "sensor.elektriciteit_totaal_energy"
    platform: integration
    source: sensor.elektriciteit_totaal_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit onbekend energy"
    unique_id: "sensor.elektriciteit_onbekend_energy"
    platform: integration
    source: sensor.elektriciteit_onbekend_power
    unit_time: h
    method: left
    unit_prefix: k

  # ---------------------------------------------------
  - name: "Elektriciteit n00 energy"
    unique_id: "sensor.elektriciteit_n00_energy"
    platform: integration
    source: sensor.elektriciteit_n00_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit n01 energy"
    unique_id: "sensor.elektriciteit_n01_energy"
    platform: integration
    source: sensor.elektriciteit_n01_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit n02 energy"
    unique_id: "sensor.elektriciteit_n02_energy"
    platform: integration
    source: sensor.elektriciteit_n02_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit n03 energy"
    unique_id: "sensor.elektriciteit_n03_energy"
    platform: integration
    source: sensor.elektriciteit_n03_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit n91 energy"
    unique_id: "sensor.elektriciteit_n91_energy"
    platform: integration
    source: sensor.elektriciteit_n91_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit n92 energy"
    unique_id: "sensor.elektriciteit_n92_energy"
    platform: integration
    source: sensor.elektriciteit_n92_power
    unit_time: h
    method: left
    unit_prefix: k





  # ---------------------------------------------------
  - name: "Elektriciteit subtotaal 1 energy"
    unique_id: "sensor.elektriciteit_subtotaal_1_energy"
    platform: integration
    source: sensor.elektriciteit_subtotaal_1_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit subtotaal 2 energy"
    unique_id: "sensor.elektriciteit_subtotaal_2_energy"
    platform: integration
    source: sensor.elektriciteit_subtotaal_2_power
    unit_time: h
    method: left
    unit_prefix: k




  # ---------------------------------------------------
  - name: "Elektriciteit koelkast energy"
    unique_id: "sensor.elektriciteit_koelkast_energy"
    platform: integration
    source: sensor.elektriciteit_koelkast_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit koelkast_smeg energy"
    unique_id: "sensor.elektriciteit_koelkast_smeg_energy"
    platform: integration
    source: sensor.elektriciteit_koelkast_smeg_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit datacenter energy"
    unique_id: "sensor.elektriciteit_datacenter_energy"
    platform: integration
    source: sensor.elektriciteit_datacenter_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_left_energy"
    unique_id: "sensor.elektriciteit_datacenter_left_energy"
    platform: integration
    source: sensor.elektriciteit_datacenter_power
    unit_time: h
    method: left
    unit_prefix: k    
  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_trapezoidal_energy"
    unique_id: "sensor.elektriciteit_datacenter_trapezoidal_energy"
    platform: integration
    source: sensor.elektriciteit_datacenter_power
    unit_time: h
    method: trapezoidal
    unit_prefix: k    
  # ---------------------------------------------------
  - name: "elektriciteit_datacenter_right_energy"
    unique_id: "sensor.elektriciteit_datacenter_right_energy"
    platform: integration
    source: sensor.elektriciteit_datacenter_power
    unit_time: h
    method: right
    unit_prefix: k    




  # ---------------------------------------------------
  - name: "Elektriciteit kast energy"
    unique_id: "sensor.elektriciteit_kast_energy"
    platform: integration
    source: sensor.elektriciteit_kast_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit bureau energy"
    unique_id: "sensor.elektriciteit_bureau_energy"
    platform: integration
    source: sensor.elektriciteit_bureau_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit gasketel energy"
    unique_id: "sensor.elektriciteit_gasketel_energy"
    platform: integration
    source: sensor.elektriciteit_gasketel_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit proxmox energy"
    unique_id: "sensor.elektriciteit_proxmox_energy"
    platform: integration
    source: sensor.elektriciteit_proxmox_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "elektriciteit_proxmox_left_energy"
    unique_id: "sensor.elektriciteit_proxmox_left_energy"
    platform: integration
    source: sensor.elektriciteit_proxmox_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "elektriciteit_proxmox_trapezoidal_energy"
    unique_id: "sensor.elektriciteit_proxmox_trapezoidal_energy"
    platform: integration
    source: sensor.elektriciteit_proxmox_power
    unit_time: h
    method: trapezoidal
    unit_prefix: k
  # ---------------------------------------------------
  - name: "elektriciteit_proxmox_right_energy"
    unique_id: "sensor.elektriciteit_proxmox_right_energy"
    platform: integration
    source: sensor.elektriciteit_proxmox_power
    unit_time: h
    method: right
    unit_prefix: k






  # ---------------------------------------------------
  - name: "Elektriciteit SRV-19 energy"
    unique_id: "sensor.elektriciteit_srv_19_energy"
    platform: integration
    source: sensor.elektriciteit_srv_19_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit TV energy"
    unique_id: "sensor.elektriciteit_tv_energy"
    platform: integration
    source: sensor.tv_powerplug_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "elektriciteit_tv_left_energy"
    unique_id: "sensor.elektriciteit_tv_left_energy"
    platform: integration
    source: sensor.tv_powerplug_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "elektriciteit_tv_trapezoidal_energy"
    unique_id: "sensor.elektriciteit_tv_trapezoidal_energy"
    platform: integration
    source: sensor.tv_powerplug_power
    unit_time: h
    method: trapezoidal
    unit_prefix: k  
  # ---------------------------------------------------
  - name: "elektriciteit_tv_right_energy"
    unique_id: "sensor.elektriciteit_tv_right_energy"
    platform: integration
    source: sensor.tv_powerplug_power
    unit_time: h
    method: right
    unit_prefix: k



  # ---------------------------------------------------
  - name: "Elektriciteit kelder werktafel energy"
    unique_id: "sensor.elektriciteit_kelder_werktafel_energy"
    platform: integration
    source: sensor.elektriciteit_kelder_werktafel_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit kelder werkbank energy"
    unique_id: "sensor.elektriciteit_kelder_werkbank_energy"
    platform: integration
    source: sensor.elektriciteit_kelder_werkbank_power
    unit_time: h
    method: left
    unit_prefix: k







  # ---------------------------------------------------
  - name: "Elektriciteit Kring A energy"
    unique_id: "sensor.elektriciteit_kring_a_energy"
    platform: integration
    source: sensor.elektriciteit_kring_a_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit Kring B energy"
    unique_id: "sensor.elektriciteit_kring_b_energy"
    platform: integration
    source: sensor.elektriciteit_kring_b_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit Kring C energy"
    unique_id: "sensor.elektriciteit_kring_c_energy"
    platform: integration
    source: sensor.elektriciteit_kring_c_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit Kring D energy"
    unique_id: "sensor.elektriciteit_kring_d_energy"
    platform: integration
    source: sensor.elektriciteit_kring_d_power
    unit_time: h
    method: left
    unit_prefix: k
  # ---------------------------------------------------
  - name: "Elektriciteit Kring E energy"
    unique_id: "sensor.elektriciteit_kring_e_energy"
    platform: integration
    source: sensor.elektriciteit_kring_e_power
    unit_time: h
    method: left
    unit_prefix: k

The most flexible way to organize this:

  • I places both *.yaml-files in a folder called “packages”
  • in configuration.yaml, I included this folder with packages: !include_dir_named packages
# ===============================================
# GLOBAL CONFIG FILE
# ===============================================
homeassistant:

  # Name of the location where Home Assistant is running
  name: xxxx

  # Location required to calculate the time the sun rises and sets
  latitude: 50.xx
  longitude: 4.xx

  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 28

  # metric for Metric, imperial for Imperial
  unit_system: metric

  # country
  country: BE

  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Europe/Brussels

  # Customization file
  customize: !include customize.yaml

  # zie https://community.home-assistant.io/t/please-help-automation-for-ikea-tradfri-remote-control-e1524-e1810/142707/2
  packages: !include_dir_named packages

# Show links to resources in log and frontend
#introduction:

default_config:

I just created a sensors.yaml file and added it to my configuration.yaml file.

Thank you for this but I think something is way off in my math. When I added:

  • name: “furnace_energy”
    unique_id: “sensor.furnace_energy”
    platform: integration
    source: sensor.furnace_usage_5 <–The actual current usage in wattage from Sense.
    unit_time: h
    method: left <–Added
    unit_prefix: k <–Added

It showed like 741-kWh burned in one hour when the value that I get from Sense is like 0.7kWh so I think I need to divide by 1000 to get the correct number.

Also, how do I get this cumulative value to reset at midnight or is that just something that happens?

I know I am a noob at this, as engineering is my strong suit, not coding. I do thank you for the help, though.