diff --git a/backend/lib/scheduler/Scheduler.js b/backend/lib/scheduler/Scheduler.js index 8a1f123a859..816759ac994 100644 --- a/backend/lib/scheduler/Scheduler.js +++ b/backend/lib/scheduler/Scheduler.js @@ -1,7 +1,7 @@ const Logger = require("../Logger"); +const Tools = require("../utils/Tools"); const ValetudoFanSpeedControlTimerPreAction = require("./pre_actions/ValetudoFanSpeedControlTimerPreAction"); const ValetudoFullCleanupTimerAction = require("./actions/ValetudoFullCleanupTimerAction"); -const ValetudoNTPClientDisabledState = require("../entities/core/ntpClient/ValetudoNTPClientDisabledState"); const ValetudoNTPClientSyncedState = require("../entities/core/ntpClient/ValetudoNTPClientSyncedState"); const ValetudoOperationModeControlTimerPreAction = require("./pre_actions/ValetudoOperationModeControlTimerPreAction"); const ValetudoSegmentCleanupTimerAction = require("./actions/ValetudoSegmentCleanupTimerAction"); @@ -32,15 +32,23 @@ class Scheduler { } evaluateTimers() { - if ( - !( - this.ntpClient.state instanceof ValetudoNTPClientSyncedState || - this.ntpClient.state instanceof ValetudoNTPClientDisabledState - ) && this.config.get("embedded") === true - ) { - // Since some robots have no rtc, we absolutely require a synced time when embedded - // Therefore, we're aborting without it unless you explicitly disable the NTPClient - // In that case you're on your own to provide the correct time to the robot + const NTPClientStateIsValid = this.ntpClient.state instanceof ValetudoNTPClientSyncedState; + const isEmbedded = this.config.get("embedded") === true; + const hasBuildTimestamp = Tools.GET_BUILD_TIMESTAMP() > new Date(-1); + const timeIsPlausible = Tools.GET_BUILD_TIMESTAMP() < new Date(); + + let shouldEvaluateTimers; + if (isEmbedded) { + shouldEvaluateTimers = NTPClientStateIsValid || (hasBuildTimestamp && timeIsPlausible); + } else { + if (hasBuildTimestamp) { + shouldEvaluateTimers = timeIsPlausible; + } else { // Probably dev env + shouldEvaluateTimers = true; + } + } + + if (!shouldEvaluateTimers) { return; } diff --git a/frontend/src/valetudo/timers/res/TimersHelp.ts b/frontend/src/valetudo/timers/res/TimersHelp.ts index ef2ed74790d..229c1d89b6d 100644 --- a/frontend/src/valetudo/timers/res/TimersHelp.ts +++ b/frontend/src/valetudo/timers/res/TimersHelp.ts @@ -3,16 +3,8 @@ export const TimersHelp = ` ## Timers Timers allow you to execute a task at a specified time (UTC).
-To operate, they require the system time to be synced using the NTP client built into Valetudo. -If it is unable to reach the configured NTP server, no timers will be -executed unless the NTP client was disabled explicitly which would -imply the user is responsible for providing time by other means. - -**Please note that timers are evaluated and stored as UTC. They are only displayed in your current browser timezone -for your convenience.** - -Timers in Valetudo are provided as a convenience feature.
-It is **highly recommended** to deploy a full-scale home automation system such as openHAB or Home Assistant to allow for -better scheduled operation taking into account e.g. whether or not a room is currently occupied, you're currently on vacation etc. +If the system time isn't plausible (e.g. like when it has never been synced), no timers will be executed. +Please note that timers are evaluated and stored as UTC. They are only displayed in your current browser timezone.
+This means that they will not follow any DST rules and thus will have to be updated manually if so required. `;