|
1 | 1 | const Logger = require("../Logger");
|
| 2 | +const Tools = require("../utils/Tools"); |
2 | 3 | const ValetudoFanSpeedControlTimerPreAction = require("./pre_actions/ValetudoFanSpeedControlTimerPreAction");
|
3 | 4 | const ValetudoFullCleanupTimerAction = require("./actions/ValetudoFullCleanupTimerAction");
|
4 | 5 | const ValetudoNTPClientDisabledState = require("../entities/core/ntpClient/ValetudoNTPClientDisabledState");
|
@@ -32,15 +33,23 @@ class Scheduler {
|
32 | 33 | }
|
33 | 34 |
|
34 | 35 | evaluateTimers() {
|
35 |
| - if ( |
36 |
| - !( |
37 |
| - this.ntpClient.state instanceof ValetudoNTPClientSyncedState || |
38 |
| - this.ntpClient.state instanceof ValetudoNTPClientDisabledState |
39 |
| - ) && this.config.get("embedded") === true |
40 |
| - ) { |
41 |
| - // Since some robots have no rtc, we absolutely require a synced time when embedded |
42 |
| - // Therefore, we're aborting without it unless you explicitly disable the NTPClient |
43 |
| - // In that case you're on your own to provide the correct time to the robot |
| 36 | + const NTPClientStateIsValid = this.ntpClient.state instanceof ValetudoNTPClientSyncedState; |
| 37 | + const isEmbedded = this.config.get("embedded") === true; |
| 38 | + const hasBuildTimestamp = Tools.GET_BUILD_TIMESTAMP() > new Date(-1); |
| 39 | + const timeIsPlausible = Tools.GET_BUILD_TIMESTAMP() < new Date(); |
| 40 | + |
| 41 | + let shouldEvaluateTimers; |
| 42 | + if (isEmbedded) { |
| 43 | + shouldEvaluateTimers = NTPClientStateIsValid || (hasBuildTimestamp && timeIsPlausible); |
| 44 | + } else { |
| 45 | + if (hasBuildTimestamp) { |
| 46 | + shouldEvaluateTimers = timeIsPlausible; |
| 47 | + } else { // Probably dev env |
| 48 | + shouldEvaluateTimers = true; |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + if (!shouldEvaluateTimers) { |
44 | 53 | return;
|
45 | 54 | }
|
46 | 55 |
|
|
0 commit comments