scheduled charging: increase buffer time by soc request interval after charge start#3160
scheduled charging: increase buffer time by soc request interval after charge start#3160LKuemmel wants to merge 2 commits intoopenWB:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request modifies the scheduled charging logic to conditionally apply the soc_request_interval_offset based on whether charging has started and the type of charging plan. The change addresses timing precision in scheduled charging by differentiating between SOC-based and amount-based charging plans.
Changes:
- Added
charge_stateparameter to track whether the chargepoint is actively charging - Modified logic to exclude
soc_request_interval_offsetfor amount-based plans before charging starts - Updated all test calls to include the new parameter (all with value
True)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/control/ev/ev.py | Added charge_state parameter to get_required_current method signature and forwarded it to scheduled charging logic |
| packages/control/ev/charge_template.py | Added conditional logic to set soc_request_interval_offset to 0 for non-SOC plans when charging hasn't started |
| packages/control/ev/charge_template_test.py | Updated all test calls to include the new charge_state parameter |
| packages/control/chargepoint/chargepoint.py | Passed self.data.get.charge_state to the get_required_current method |
Comments suppressed due to low confidence (1)
packages/control/ev/ev.py:142
- The docstring should be updated to document the new charge_state parameter. Add a description explaining that it indicates whether charging is currently active, which affects how the soc_request_interval_offset is applied in scheduled charging calculations.
""" ermittelt, ob und mit welchem Strom das EV geladen werden soll (unabhängig vom Lastmanagement)
Parameter
---------
imported_since_mode_switch: float
seit dem letzten Lademodi-Wechsel geladene Energie.
Return
------
state: bool
Soll geladen werden?
message: str
Nachricht, warum nicht geladen werden soll
submode: str
Lademodus, in dem tatsächlich geladen wird
required_current: int
Strom, der nach Ladekonfiguration benötigt wird
"""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -288,7 +288,7 @@ def test_scheduled_charging_calc_current_no_plans(): | |||
|
|
|||
| # execution | |||
| ret = ct.scheduled_charging_calc_current( | |||
| None, 63, 5, 3, 3, 6, 0, ChargingType.AC.value, EvTemplate(), BidiState.BIDI_CAPABLE) | |||
| None, 63, 5, 3, 3, 6, 0, ChargingType.AC.value, EvTemplate(), BidiState.BIDI_CAPABLE, True) | |||
There was a problem hiding this comment.
All existing tests use charge_state=True. Consider adding test cases with charge_state=False and plan.limit.selected="amount" to verify the new logic at line 561-564 of charge_template.py that sets soc_request_interval_offset to 0 for amount-based plans before charging starts. This would ensure the conditional behavior works correctly for both SOC and amount-based plans.
| # das Abfrageintervall nur einbeziehen, wenn die Ladung bereits gestartet wurde, sonst wird einfach alles | ||
| # um das Abfrageintervall früher gestartet, und nicht die Pufferzeit um das Abfrageintervall erhöht. |
There was a problem hiding this comment.
The comment could be more specific to clarify that this logic applies only to non-SOC plans. Consider rephrasing to: "Für Pläne ohne SoC-Begrenzung das Abfrageintervall nur einbeziehen, wenn die Ladung bereits gestartet wurde. Bei SoC-basierten Plänen wird das Abfrageintervall immer berücksichtigt, da der SoC-Wert unabhängig vom Ladezustand veraltet sein kann." This makes it clear that SOC plans always use the offset while amount plans only use it after charging starts.
| # das Abfrageintervall nur einbeziehen, wenn die Ladung bereits gestartet wurde, sonst wird einfach alles | |
| # um das Abfrageintervall früher gestartet, und nicht die Pufferzeit um das Abfrageintervall erhöht. | |
| # Für Pläne ohne SoC-Begrenzung das Abfrageintervall nur einbeziehen, wenn die Ladung bereits gestartet | |
| # wurde. Bei SoC-basierten Plänen wird das Abfrageintervall immer berücksichtigt, da der SoC-Wert | |
| # unabhängig vom Ladezustand veraltet sein kann. |
No description provided.