Deduplicate code from xdrv_10_rules.ino

Turns out this code was already done in xdrv_09_timers.ino
This commit is contained in:
cybermaus 2022-10-25 22:34:08 +02:00 committed by GitHub
parent 89d4e87195
commit 0eebdf8620
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 13 deletions

View File

@ -1458,19 +1458,7 @@ bool findNextVariableValue(char * &pVarname, float &value)
} else if (sVarName.startsWith(F("TIMER"))) {
uint32_t index = sVarName.substring(5).toInt();
if (index > 0 && index <= MAX_TIMERS) {
value = Settings->timer[index -1].time;
#if defined(USE_SUNRISE)
// Correct %timerN% values for sunrise/sunset timers
if ((1 == Settings->timer[index -1].mode) || (2 == Settings->timer[index -1].mode)) {
// in this context, time variable itself is merely an offset, with <720 being negative
value += -720 + SunMinutes(Settings->timer[index -1].mode -1);
if (2 == Settings->timer[index -1].mode) {
// To aid rule comparative statements, sunset past midnight (high lattitudes) is expressed past 24h00
// So sunset at 00h45 is at 24h45
if (value < 360) { value += 1440; }
}
}
#endif // USE_SUNRISE
value = TimerGetTimeOfDay(index -1);
}
#if defined(USE_SUNRISE)
} else if (sVarName.equals(F("SUNRISE"))) {