diff --git a/controller/boards/IntelliCenterBoard.ts b/controller/boards/IntelliCenterBoard.ts index b4c35d16..c753c51f 100644 --- a/controller/boards/IntelliCenterBoard.ts +++ b/controller/boards/IntelliCenterBoard.ts @@ -4814,7 +4814,7 @@ class IntelliCenterScheduleCommands extends ScheduleCommands { if (typeof c === 'undefined') { let cstate = state.circuits.getInterfaceById(ssched.circuit); c = { state: cstate, endTime: ssched.scheduleTime.endTime.getTime() }; - circs.push; + circs.push(c); } if (c.endTime < ssched.scheduleTime.endTime.getTime()) c.endTime = ssched.scheduleTime.endTime.getTime(); } diff --git a/controller/boards/SystemBoard.ts b/controller/boards/SystemBoard.ts index 996b084b..68aed067 100644 --- a/controller/boards/SystemBoard.ts +++ b/controller/boards/SystemBoard.ts @@ -3729,6 +3729,16 @@ export class ScheduleCommands extends BoardCommands { ssched.isOn = schedIsOn; sys.board.circuits.setEndTime(sys.circuits.getInterfaceById(ssched.circuit), scirc, scirc.isOn, true); } + else if (schedIsOn && scirc.isOn + && typeof scirc.endTime !== 'undefined' + && typeof ssched.scheduleTime.endTime !== 'undefined' + && ssched.scheduleTime.endTime.getTime() > scirc.endTime.toDate().getTime()) { + // The schedule's window has advanced past the cached circuit endTime + // (e.g. a continuous 24-hour schedule rolling over midnight). Without + // this refresh, checkCircuitEggTimerExpirationAsync would compare + // `now` against the stale endTime and force-turn-off the circuit. + sys.board.circuits.setEndTime(sys.circuits.getInterfaceById(ssched.circuit), scirc, scirc.isOn, true); + } ssched.emitEquipmentChange(); } } catch (err) { logger.error(`Error synchronizing schedule states`); }