@@ -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 }
0 commit comments