I’m trying to solve a routine problem of calculating electricity consumption in a house.
To begin with, I took the Xiaomi Aqara Wireless Relay 2 Channels Wifi Relay, which controls the convector with a capacity of about 1.8 kilowatts.
I added a sensor that converts power from watts to kilowatts and rounds to the 4th decimal place:
hourly_wifi_relay_komnata_load_kw:
source: sensor.wifi_relay_komnata_current_power_per_kw
cycle: hourly
tariffs:
- same
If I turn on the convector for a few seconds, then the instantaneous power reaches 1.8 kW, and hourly_wifi_relay_komnata_load_kw_same returns a similar value. Although in fact, the full consumption of 1.8 kW did not occur. If you turn on the convection again for a few seconds, the result is already 3.6 kW. Because of this, the cost of electricity is calculated incorrectly.
Tell me what is my mistake?
You are using a power sensor (kW) for the utility meter but it requires an energy consumed sensor (kWh) that always increases. There are many posts about this on the forum.
Thanks a lot! Before your answer, I could not understand what the problem was, but after your answer, I immediately found the necessary posts on the forum.
To improve the coverage of this issue, I will give my solution.
I created a sensor that shows the total instantaneous power in kilowatts of the devices I need. In this case, these are two wi-fi relays:
I use the value of this sensor to visualize energy consumption and calculate the cost of consumed energy.
Everything works great! Thanks to the developers and the Home Assistant community!
If you notice odd readings, change the method to left. From the docs:
method string (Optional, default: trapezoidal)
Riemann sum method to be used. Available methods are trapezoidal, left and right.
In case you have an appliance which produces spikey consumption (like an on/off electrical boiler) you should opt for the left method to get accurate readings.