However, It can not add the sensor.elektriciteit_datacenter_energy to the “individual devices” of my Energy Dashboard section. I receive following error:
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?
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).
Just yesterday I went through very similar exercie and here are my learnings
Make sure that both power and energy sensors are included in recorder.
Customize the energy sensor to add the state_class:
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
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
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.
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…
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:
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.