Implemented charge windows instead of just picking random low price s… - #951
Conversation
…egments Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4aff26557
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This pull request implements a sophisticated charge window scheduling algorithm that replaces the simpler approach of just picking random low-price slots. The new system intelligently schedules charge windows by considering price data, time constraints, and multiple competing charge intents (manual, trip, routine, fill) to optimize both cost and charging behavior.
Changes:
- Replaced the old
GeneratePlanfunction with a new "soft intents" model that collects all charge requirements first, then schedules them optimally across available price windows - Implemented a greedy sliding-window algorithm to find optimal charge windows that minimize cost while respecting constraints like minimum window duration (to avoid fragmentation in cold weather) and maximum price thresholds
- Added support for splitting charge sessions across multiple windows when cost savings justify it, with configurable thresholds for when to split vs. consolidate charging
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 289a128246
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
… quantumMs Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
…ehicle not waking up to charge, cause it though the level was ok already Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
…silon Audit comparisons previously included non-SmartCharge schedule IDs (e.g. Tesla app schedules like 1723769697) causing false positive mismatches whenever the car had extra schedules in the live data. Fix 1: filter normalizeChargeSchedules / equalChargeSchedules to IDs in [TeslaScheduleIDs.First, TeslaScheduleIDs.Last] and filter normalizePreconditionSchedules / equalPreconditionSchedules to TeslaScheduleIDs.Precondition only. Fix 2: increase SCHEDULE_COORD_ABS_EPSILON from 1e-5 to 5e-5. The original 1e-5 was insufficient to cover the observed ~2.6e-5 drift between micro-degree integer DB values (e.g. 57695873/1e6) and what Tesla stores as IEEE 754 float32 (~57.695899). float32 ULP near 60 N is ~4-8e-6; the new epsilon (5e-5) covers both float32 rounding and DB-to-float32 conversion artefacts while still catching genuine location changes of >5 m. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Keep audit interval logic but with past cutoffs to disable recurring audits - Keep same-leg in-place schedule adjustments by ID - Require enabled in Tesla schedule payloads - Send enabled=true on adjustment updates to enforce explicit authoritative behavior - Remove ambiguous cache fallback for enabled on schedule write-back Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Shift the audit sunset window three months so the periodic and post-update schedule audits run at 30-minute cadence again while the new charge window planner is being verified in production.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 27 changed files in this pull request and generated no new comments.
Suppressed comments (2)
app/src/components/edit-vehicle.vue:160
locationSettings()is invoked from the template during render, but it mutates reactive state viagetOrCreateLocationSettings()(pushing intothis.vehicle.locationSettings). Render-time side effects can cause extra render passes and make UI state harder to reason about (andlocationSettings()is called more than once per render:v-if="locationSettings().length"and thev-for). Consider moving the “ensure defaults exist” mutation to a lifecycle hook / watcher and keepinglocationSettings()pure (mapping only).
locationSettings(): any[] {
return (
(this.locations &&
this.locations
.filter((l) => l.ownerID === this.vehicle.ownerID)
.map((l) => {
const settings = this.getOrCreateLocationSettings(l.id);
providers/tesla/tesla-server.ts:189
Vehiclesquery may returnnullwhenincompleteis true. At least one existing caller (providers/tesla/app/tesla.vue) iterates the result directly (for (const v of await providerQuery(...))), which will throw onnulland can lead to a misleading UI state (e.g., showing the authorize button even though vehicles exist). Ifnullis the intended “mapping incomplete” sentinel (as TeslaAgent now expects), please update all call sites to explicitly handlenull(e.g., treat as “retry later” / show a transient error) rather than assuming an array.
if (incomplete) {
return null;
}
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 285ff52727
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const plan = await planWindows(timeNeeded, deadline, undefined, `intent:${cohortMaxLevel}`, isActiveCharge()); | ||
| hardStart = applyWindows(plan.windows, buildAllocations(plannedLevel, cohortIntents)); |
There was a problem hiding this comment.
Fall back when no price windows are available
When a scheduled manual/trip/routine intent has a future deadline but the location has no price data (or every slot before the deadline is filtered out), planWindows() returns an empty windows array; this branch still applies that empty plan and then marks the cohort as planned. The result is an empty chargePlan, so scheduled charging is silently skipped at locations without tariff data, whereas the old path fell back to direct charging when priceAvailable was false.
Useful? React with 👍 / 👎.
Follow-up to #951, covering the review and cleanup findings on that PR. Planner: the per-step Trace logging ran unconditionally (LOGLEVEL defaults to Trace and nothing lowers it), costing ~54 stdout lines and ~35% of every planning call; keep a header and one outcome line and drop the scaffolding that only fed logs. State the ordering and finiteness preconditions as asserts now that the redundant sorts are gone, merge the redundant node comparator, fold action/stepIndex into a step reference, and yield on a 5 ms budget instead of a step count. Charge curve: the 0.75 anti-overshoot trim sat behind `l < to`, true for every iteration of its own loop, so every estimate ran ~25% of a band long. Extract chargeDuration so it can be tested and fix the predicate. Settings: settings.vue and vehicleFragment now share one locationSettings field list, and splitCharge's default moves into the schema. Verified identical over 4500 fuzzed plans on well-formed input.
No description provided.