Skip to content

Conversation

@iseeberg79
Copy link
Contributor

@iseeberg79 iseeberg79 commented Feb 4, 2026

Fix #27129

  • not to skip short precondition phase (15min) because of slot duration handling
  • avoid unfortunate interrupted planning on continuous plans

Testplan:

  • continuous
  • w/o precondition
  • precondition (minimum)
  • existing repeating plans
  • non-continuous plans
  • check simplified condition

The debug logs for above charging sessions completed the last days show no unfortunate behavior.

@iseeberg79 iseeberg79 marked this pull request as ready for review February 6, 2026 05:45
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The newly added requiredDuration > strategy.Precondition checks are repeated in multiple branches; consider extracting this into a named predicate or restructuring the switch to avoid duplication and make the intent clearer.
  • The added continuous-plan condition combines several time comparisons in a single case; breaking this out into well-named intermediate variables (e.g., wouldInterruptContinuous) or a helper function would improve readability and make the business rules easier to reason about.
  • For both the precondition-related checks and the continuous-plan condition, review whether strict > vs >= behavior is intended at the thresholds, and consider documenting or encoding these boundary decisions explicitly to avoid subtle off-by-one timing issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The newly added `requiredDuration > strategy.Precondition` checks are repeated in multiple branches; consider extracting this into a named predicate or restructuring the switch to avoid duplication and make the intent clearer.
- The added continuous-plan condition combines several time comparisons in a single `case`; breaking this out into well-named intermediate variables (e.g., `wouldInterruptContinuous`) or a helper function would improve readability and make the business rules easier to reason about.
- For both the precondition-related checks and the continuous-plan condition, review whether strict `>` vs `>=` behavior is intended at the thresholds, and consider documenting or encoding these boundary decisions explicitly to avoid subtle off-by-one timing issues.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@andig andig added the bug Something isn't working label Feb 6, 2026
@iseeberg79
Copy link
Contributor Author

iseeberg79 commented Feb 6, 2026

@andig it solves the issues reported for continuous planning. From my point of view we may go for it. Let's just discuss the open comment because it is relevant for non-continuous planning, would be valid to change in another PR probably

@andig andig changed the title fix continuous plan execution Planner: fix continuous plan execution Feb 7, 2026
@andig
Copy link
Member

andig commented Feb 7, 2026

@iseeberg79 I guess this needs tests

@iseeberg79
Copy link
Contributor Author

Very difficult to unit test, I tried but it got way to complicated

case lp.clock.Until(planStart) < tariff.SlotDuration:
lp.log.DEBUG.Printf("plan: avoid re-start within %v, continuing for remaining %v", tariff.SlotDuration, lp.clock.Until(planStart).Round(time.Second))
return true
case strategy.Continuous && requiredDuration > strategy.Precondition && planStart.After(lp.clock.Now()) && planStart.Before(planTime.Add(-requiredDuration-strategy.Precondition)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be so complicated? The plan has already started- why check for plan start? Shouldn't this just be

case strategy.Continuous && requiredDuration > strategy.Precondition:

Copy link
Contributor Author

@iseeberg79 iseeberg79 Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATM I believe we could skip a redundant, defensive planStart.After(lp.clock.Now()) but need to keep the additional condition having repeating plans in focus - I'll double-check this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reduced condition should be fine indeed. There are other checks guarding what I intended to check. I'll analyze a charging session in detail, it should be fine.

@iseeberg79 iseeberg79 marked this pull request as draft February 8, 2026 15:41
@andig andig marked this pull request as ready for review February 8, 2026 15:48
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The new strategy.Continuous && requiredDuration > strategy.Precondition case encodes a fairly specific behavioral rule; consider adding a short inline comment explaining why this condition is the right threshold to avoid interrupting continuous charging.
  • To make the new debug log more useful when diagnosing planner behavior, consider including requiredDuration and strategy.Precondition values in the message alongside the planStart time.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `strategy.Continuous && requiredDuration > strategy.Precondition` case encodes a fairly specific behavioral rule; consider adding a short inline comment explaining why this condition is the right threshold to avoid interrupting continuous charging.
- To make the new debug log more useful when diagnosing planner behavior, consider including `requiredDuration` and `strategy.Precondition` values in the message alongside the `planStart` time.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@andig
Copy link
Member

andig commented Feb 8, 2026

Rein damit?

@iseeberg79

This comment has been minimized.

@andig andig merged commit 7b8256f into evcc-io:master Feb 8, 2026
13 checks passed
@iseeberg79
Copy link
Contributor Author

iseeberg79 commented Feb 9, 2026

Ladevorgang erfolgreich: Start/Ziel und Precondition zum geplanten Zeitpunkt, Lademenge (Energie+SoC) zutreffend. Log Analyse ohne Auffälliges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Continuous plan stops and restarts

2 participants