Skip to content

Commit 291bf84

Browse files
committed
Disable audit by moving dates to past.
1 parent 0efc770 commit 291bf84

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

‎providers/tesla/tesla-agent.ts‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -706,12 +706,12 @@ export class TeslaAgent extends AbstractAgent {
706706

707707
private scheduleAuditIntervalMs(now: number): number | null {
708708
// Development-only schedule audit with a hard sunset so it cannot linger in release code.
709-
// Starting April 22, 2026:
710-
// - run every 10 minutes until July 22, 2026
711-
// - then every 30 minutes until October 22, 2026
709+
// Keep dates in the past so audit remains disabled unless explicitly reintroduced.
710+
// - run every 10 minutes until May 1, 2026
711+
// - then every 30 minutes until June 1, 2026
712712
// - then disable completely
713-
if (now < Date.UTC(2026, 6, 22)) return 10 * 60e3;
714-
if (now < Date.UTC(2026, 9, 22)) return 30 * 60e3;
713+
if (now < Date.UTC(2026, 4, 1)) return 10 * 60e3;
714+
if (now < Date.UTC(2026, 5, 1)) return 30 * 60e3;
715715
return null;
716716
}
717717

@@ -1414,6 +1414,12 @@ export class TeslaAgent extends AbstractAgent {
14141414
);
14151415
if (!teslaScheduleMatchesExactly(s, r)) {
14161416
hasInexactPurposeMatch = true;
1417+
scheduleUpdates.push({
1418+
...this.convertToTeslaSchedule(r, location),
1419+
id: s.scheduleID,
1420+
enabled: undefined,
1421+
comment: `adjusting existing schedule ${s.scheduleID}`
1422+
});
14171423
}
14181424
r.scheduleID = s.scheduleID;
14191425
usedScheduleIDs.add(s.scheduleID);
@@ -1526,13 +1532,15 @@ export class TeslaAgent extends AbstractAgent {
15261532
let findid = TeslaScheduleIDs.First;
15271533
freeScheduleIDs.push(...Object.keys(vehicleSchedules).map((s) => parseInt(s)).filter((s) => !usedScheduleIDs.has(s)));
15281534
for (const s of scheduleUpdates) {
1529-
if (freeScheduleIDs.length > 0) {
1530-
s.id = freeScheduleIDs.shift();
1531-
} else {
1532-
for (; findid <= TeslaScheduleIDs.Last; findid++) {
1533-
if (!usedScheduleIDs.has(findid)) {
1534-
s.id = findid;
1535-
break;
1535+
if (s.id === undefined) {
1536+
if (freeScheduleIDs.length > 0) {
1537+
s.id = freeScheduleIDs.shift();
1538+
} else {
1539+
for (; findid <= TeslaScheduleIDs.Last; findid++) {
1540+
if (!usedScheduleIDs.has(findid)) {
1541+
s.id = findid;
1542+
break;
1543+
}
15361544
}
15371545
}
15381546
}
@@ -1551,7 +1559,11 @@ export class TeslaAgent extends AbstractAgent {
15511559
await this.callTeslaAPI(job, teslaAPI.addChargeSchedule, vehicle.vin, s);
15521560
didMutateSchedules = true;
15531561
// Cache the newly set schedule with correct lat/long (only after successful API call)
1554-
vehicle.charge_schedules[s.id] = s;
1562+
const existingEnabled = vehicle.charge_schedules[s.id]?.enabled;
1563+
vehicle.charge_schedules[s.id] = {
1564+
...s,
1565+
enabled: s.enabled ?? existingEnabled ?? true,
1566+
};
15551567
logVehicle(LogLevel.Debug, vehicle, `${vehicle.vin} cached schedule ${s.id} @ [${s.latitude},${s.longitude}]`);
15561568
}
15571569
}

‎providers/tesla/tesla-api.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ interface TeslaSchedule {
5151
name?: string;
5252
days_of_week: number;
5353
one_time?: boolean;
54-
enabled: boolean;
54+
enabled?: boolean;
5555
latitude: number;
5656
longitude: number;
5757
}

0 commit comments

Comments
 (0)