-
-
Notifications
You must be signed in to change notification settings - Fork 101
Update api.py #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update api.py #98
Conversation
Bugfix processing phase measurands
🎉 HACS repository validator action summary 🎉 |
@drc38, why are positive voltages treated differently from negative? if metric in Measurand.voltage.value:
sum = (
value[Phase.l1_n.value]
+ value[Phase.l2_n.value]
+ value[Phase.l3_n.value]
)
if sum > 0:
self._metrics[metric] = round(sum / 3, 1)
else:
self._metrics[metric] = round(sum, 1) |
There should not be negative voltages, and the >0 was to protect against a div by 0 error. |
You’re never dividing by sum though. And if sum equals zero, the metric value will be zero. Ok if I just change it to: self._metrics[metric] = round(sum / 3, 1) |
😄 good spotting, I was working too late. Please update |
Will you also update prior loop to reference |
Improve processing of voltage phases
I will keep that the same for now, but I do think there is some room improvement. We should aim to provide the one-phase equivalent voltage, current and power when three phases are reported. See here for some background info. Assuming the voltages Vx-n are balanced, we can simply add the currents to get the one-phase equivalent current. When line-to-line voltages are reported we should divide by sqrt(3) to get the line to neutral voltage. The line-to-neutral voltages are simply averaged. |
Bugfix processing phase measurands. See #95