#Combine several sensors to calculate household use

1 messages · Page 1 of 1 (latest)

rough ravine
#

I have many devices in my home on individual power measuring plugs etc, but i like to have one global sensor that just shows the total power usage of my home. Including all devices that dont have individual power measuring on them.
In the past this was easy, because i just read what the power meter said. These days i have solar panels with batteries. Which means most of the time, i dont pull any electricity from the grid.

So instead, i made a template number sensor, which basically just sums up the different electricity sources and drains:

{% set coming_from_roof = float(states('sensor.inverter_input_power')) %}
{% set going_to_battery = max(float(states('sensor.batteries_charge_discharge_power')),0) %}
{% set coming_from_battery = min(float(states('sensor.batteries_charge_discharge_power')),0)*-1 %}


{% set going_to_grid = max(float(states('sensor.power_meter_active_power')),0) %}
{% set coming_from_grid = min(float(states('sensor.power_meter_active_power')),0)*-1 %}

{{ coming_from_roof + coming_from_battery + coming_from_grid - going_to_grid - going_to_battery }}

This technically works. Unfortunately, the different sensors update at slightly different intervals, and only once every 30-something seconds via modbus tcp from the Huawei inverter. For example the power coming from the roof might spike up because a cloud went away, but the power meter has not updated yet, so this template sensor thinks my home uses 8kW. You can see how much it varies in the chart.

If i use a mini-graph-card or Grafana to visualize it, i can just average it out over a short time and everything is fine. But i would love for the sensor in HA to already be a bit less chaotic.
I'm trying to think of some other combo of sensors i could use for the same result (i've added the screeenshots from the different huawei devices on the bus), maybe using the total yield/consumed/exported sensors and feeding them into a utility meter somehow.

Does anyone have any recommendation/ideas?

warm plaza
#

You can use filtering. But accept it will never be fully correct

#

There are some filters available in core

rough ravine
#

Oh wow, i wasnt able to select my template number in the filter helper. But that was because its a number, not a sensor. Interesting

#

Alright, i made a template sensor instead, and then a filtered helper that throws a moving average over it. That should do it. Thanks!

south hedge
#

I recently purchased a Shelly EM gen3 and I've installed it in my main panel. This device comes with a sensor but you can attach another one. It's easy then to configure it as incoming / outgoing, etc. Maybe can be a solution. Such device costs about 70 euro

#

By the way, I've been comparing the data with my company's and it's not exactly the same, but good enough for my case