I might be missing something but that template is not that simple.
Shelly uses ade7880 which provides momentary power but also energy usage.
To do this math in template you need to check if sum of power across three phases is negative or positive and the integrate power over time.
The problem is you loose precision of the IC that does high frequency sampling.
Somehow I’ve missed that in their doco. Thank you!
In stead of using 1x Shelly 3EM its possible measure 3f + N connection with 3x Shelly EM. If you have no solarpanels its possible to measure the powerusage just by adding the 3 power consumption parameters.
When you have solarpanels we need to use the kwh_returned parameter (available on the Shelly EM) on the fase where your solarpanels are connected.
Total_kwh_Usage = kwh_used_Line1 + kwh_used_Line2 + kwh_user_Line3 + kwh_PV_generated - kwh_returned_Line_PV_connected
This way the Total_kwh_Usage calculed value takes into account your power comsumption on the fase where your solarpanels are connected.
I bought 2 Shelly 3EM’s
I have to say I damaged the first one with an incorrect connection. Inside nothing to be found so I guess the voltage regulator is damaged.
After installing it finally correctly and having a new module, the app shows all the data. But…
The 3 phase system in Poland works fine with the CTs connected. Two of them need to be installed opposite of what is indicated on the side. K-L direction
Then when the app runs and I test voltage with a seperate meter the app is pretty close
However when I measure Amperage seperate we are totally off the mark. In certain scenarios when the load drops on the phase the app shows negative flow. (I have no solar)
Tried calibration. Nothing works. The Amperage is wrong and if correct it will be wrong when the load changes.
Totally DO NOT recommend this Shelly 3EM set for 3 phase