If you donāt mind sharing, how do I duplicate this API call? I too want to open a ticket with Shelly on this. I can use postman or whatever I just didnāt make any progress trying to find some kind of API documentation.
The integration has been modified to remove the negative sign on the Shelly Power Factor value, this made the results totally wrong.
Itās clear that most if not all commentators donāt understand Power Factor because if they did they would not have supported changing the integration.
The change that introduced abs(Power Factor) needs reversing.
Power is calculated with Voltage x Current x PF
Itās clear from the examples above that some people are not understanding the electrical engineering subjects that have given rise to this incorrect change.
A negative Power Factor either indicates energy export from a Solar or Wind generation system, or when loads are light perhaps a TV or LED lighting they present negative PF values.
The Shelly 3EM is reporting the correct values and PF ranges from -1 to +1 and canāt be converted into an absolute value, this is why the values are now incorrect.
It is not unusual for PF to swing from a negative to positive value frequently as load types or load distribution varies, itās all quite normal, but much misunderstood.
Voltage and current values are always positive the value of PF converts the readings to real power rather than Apparent Power.
So VxA = Apparent Power
V x A x PF = Real Power
Why would the device report positive real power and negative power factor? (See Tomās screenshot from the API report).
And why would it always show positive power factor in itās official web interface?
You can see from Tomās graph that his system is clearly generating solar energy and the PF is negative indicating an export, then after sunset the PF gives positive again, exactly as it should do.
The problem is people donāt understand Power Factors and they assume any negative value must be a fault, but itās not.
My system was working perfectly and as soon as this updated integration was implemented everything went wrong. Then I discovered the change made was to return the absolute value of PF - thatās just wrongā¦
Additionally, this API response contains contradicting information, right?
How could [real] power be positive when power factor is negative?
Iām not necessarily saying that the new code is right, Iām just pointing out that there likely is a bug in the Shelly firmware. If you want to get the patch reverted, you should raise an issue on Github and include your explanation of why the new code is wrong. I see you have already done that
Tomās house load is normally negative because he presumably has a lot of leading PF loads, this is not unusual and you can see that the much increased negative PF diminishes around sunset and then starts to go negative again at about 0800 as the Solar starts to export again after sunrise.
Yes Iāve reported the integration is now wrong on GitHub.
Leading PF (capacitive load) does not generate any real power.
PF should still be positive, itāll just be less then 1.
-pi/2 < phi < 0
0 < cos(phi) = PF < 1
The total load is a mix of 12.83 W real power and -93.52 var reactive power, thus giving sqrt(12.83^2 + (-93.52)^2) = 94.396 VA apparent power.
Power factor is PF = 12.83 W / 94.396 VA = 0.136
But you donāt know the sign because you havenāt measured the phase angle and the Shelly did and reported -0.14.
You ignored the sign in your calculations so the vector maths is wrong.
The bottom line is the integration was correct, now itās not.
So shelly is reporting abs(P) instead of P for real power?
P = -12.83 W
Q = -93.52 var
S = sqrt((-12.83 W)^2 + (-93.52 var)^2) = 94.396 VA
PF = -12.83 W / 94.396 VA = -0.136
12.83 watts of real power is generated.
So you sort of got to the correct result eventually, real power canāt be negative and Shelly does not report it as that.
If you think about the vectors the y-axis is the apparent power and the x-axis the real power.
So I knew that PF was negative for inductive loads (when voltage leads current, āCIVILā mnemonic) but had not considered that its sign changes when exporting power.
I agree that the PR needs reverting.
The only issue is that the Shelly web interface is showing positive PF when it should be showing negative PF. The API (that home assistant uses) is correct. So itās only a problem that Shelly needs to fix.