Skip to content

Implemented charge windows instead of just picking random low price s…#951

Draft
fredli74 wants to merge 82 commits into
masterfrom
charge_window_planner
Draft

Implemented charge windows instead of just picking random low price s…#951
fredli74 wants to merge 82 commits into
masterfrom
charge_window_planner

Conversation

@fredli74
Copy link
Copy Markdown
Owner

@fredli74 fredli74 commented Feb 6, 2026

No description provided.

…egments

Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
@fredli74
Copy link
Copy Markdown
Owner Author

fredli74 commented Feb 6, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 GeneratePlan function 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.

Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
fredli74 and others added 6 commits February 6, 2026 02:46
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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread server/logic.ts Outdated
@fredli74
Copy link
Copy Markdown
Owner Author

fredli74 commented Feb 6, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread server/logic.ts Outdated
Comment thread server/logic.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread server/logic.ts Outdated
Comment thread app/src/app.vue
Comment thread app/src/app.vue
Comment thread app/src/app.vue
Comment thread server/logic.ts
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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread app/src/app.vue
Comment thread app/src/app.vue
Signed-off-by: Fredrik Lidström <fredli74@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/src/app.vue
Comment on lines 76 to 91
@@ -85,6 +87,7 @@
tile
@input="closedInfo"
>
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="info.message"></span>
Comment thread server/logic.ts
Comment on lines +1472 to +1479
vehicleLog(
LogLevel.Trace,
vehicle.vehicle_uuid,
`scheduleWindows(${scheduleTag}): after step=${stepIndex + 1}/${atomicSteps.length} ` +
`${new Date(step.start).toISOString()}..${new Date(step.stop).toISOString()}@${fmtDbPrice(step.price)} ` +
`frontier=${frontierSummary(nextStates)} total=${countFrontierNodes(nextStates)} nodesRecorded=${nodesRecorded} ` +
`prunedDominated=${nodesPrunedDominated} prunedReplaced=${nodesPrunedReplaced}`
);
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread shared/sc-utils.ts
Comment on lines 32 to 37
return {
locationID: location_uuid,
directLevel: DEFAULT_DIRECTLEVEL,
goal: SmartChargeGoal.Balanced,
splitCharge: SplitCharge.Auto,
};
Comment on lines 96 to +126
@@ -90,18 +105,25 @@

saving!: { [key: string]: boolean };
goalCBList!: { text: string; value: string }[];
splitChargeList!: { text: string; value: string }[];
data() {
return {
saving: {
directLevel: false,
goal: false,
splitCharge: false,
},
goalCBList: [
{ text: "Low cost", value: SmartChargeGoal.Low },
{ text: "Balanced", value: SmartChargeGoal.Balanced },
{ text: "Full charge", value: SmartChargeGoal.Full },
{ text: "Custom", value: "%" },
],
splitChargeList: [
{ text: "Never", value: SplitCharge.Never },
{ text: "Auto", value: SplitCharge.Auto },
{ text: "Always", value: SplitCharge.Always },
],
Comment on lines +178 to +180
get splitCharge(): string {
return this.settings.splitCharge || SplitCharge.Auto;
}
Comment on lines 212 to 217
{
locationID: this.settings.locationID,
directLevel: this.settings.directLevel,
goal: goal.value || goal,
splitCharge: this.settings.splitCharge || SplitCharge.Auto,
} as GQLVehicleLocationSetting,
Comment thread server/logic.ts
Comment on lines +1472 to +1482
vehicleLog(
LogLevel.Trace,
vehicle.vehicle_uuid,
`scheduleWindows(${scheduleTag}): after step=${stepIndex + 1}/${atomicSteps.length} ` +
`${new Date(step.start).toISOString()}..${new Date(step.stop).toISOString()}@${fmtDbPrice(step.price)} ` +
`frontier=${frontierSummary(nextStates)} total=${countFrontierNodes(nextStates)} nodesRecorded=${nodesRecorded} ` +
`prunedDominated=${nodesPrunedDominated} prunedReplaced=${nodesPrunedReplaced}`
);
states = nextStates;
}

fredli74 and others added 11 commits April 28, 2026 00:08
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants