How to calculate the electrical energy kWh from the value of the active power sensor kW? The active power sensor “P2” kW already works via modbus and can have a positive value (power from the network - consumption) or a negative value (power to the network - delivery) and I need to calculate separately the “consumed energy +kWh” and the “supplied energy -kWh”.
The calculated sensors “consumed energy +kWh” and “supplied energy -kWh” should have an increasing value without reset, similar to the values on the electricity meter.
Thanks for the answers.
Just an idea … could you create a second template sensor that is the inverse of P2 (i.e. P2 x -1.0), you could then create two utility meters to totalise the energy for each of these. The net_consumption parameter defaults to off meaning that only positive values for each will be used.
Both of the above suggestions are incorrect. The utility meter needs to be fed with energy sensors, not power sensors. The Riemann Sum helper needs to have the power split into consumed and supplied first.
To do this you need to split your power into consumed and supplied energy sensors using template sensors: