GoodWe: Fix battery charging with PV when constraint is active#3509
GoodWe: Fix battery charging with PV when constraint is active#3509iseeberg79 wants to merge 1 commit intoOpenEMS:developfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3509 +/- ##
=============================================
+ Coverage 59.57% 59.63% +0.06%
Complexity 105 105
=============================================
Files 3006 3006
Lines 130472 130474 +2
Branches 9639 9640 +1
=============================================
+ Hits 77720 77789 +69
+ Misses 49848 49770 -78
- Partials 2904 2915 +11 🚀 New features to boost your workflow:
|
|
@sfeilmeier, I would appreciate if you could review this. I've analyzed the issues related to evcc usage, referencing both the KACO implementation (https://community.openems.io/t/setactivepowerlessorequals-verhalten/10697/7) and the GoodWe (FENECON) implementation (already referenced). Sadly I've not found a solution for the KACO device as it looks like it's not about the implementation by OpenEMS (probably related to firmware/external library?). I cannot fiddle out the reason for PV routing for those. It's related to the prevent discharge function implemented by the opemens template in evcc. Because I have no hardware to test, you need to take it as theoretical work and someone else needs to the testing. It's additional unit tests are based on real-world scenarios and proove to solve the issue. Users having issues are FEMS users and because of this a test is not possible easily. |
Problem
When an external controller (e.g., evcc) sets a discharge constraint via setActivePowerLessOrEquals(0) to keep the battery neutral, the GoodWe handler incorrectly charged the battery with available PV power instead of allowing PV to supply household consumption first.
Root Cause
In handleRemoteMode(), when activePowerSetPoint == 0 and PV was available, the condition pvProduction >= activePowerSetPoint (e.g., 300 >= 0) triggered CHARGE_BAT mode, routing PV to battery instead of household loads.
Fix
Added explicit handling for constraint case (activePowerSetPoint == 0) to return DISCHARGE_BAT, 0 (neutral), allowing PV to serve household consumption before any battery interaction.
Test Coverage
Reference