mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-25 15:27:17 +00:00
Restart 9 support deepsleep with TIMER based wakeup (#20165)
* Allow restart 9 to use TIMERS for wakeup * support for restart 9 allow restart 9 to use any defined TIMER to restart a a specific time.
This commit is contained in:
parent
728f91b602
commit
f19d15654c
@ -1168,7 +1168,12 @@ void EspRestart(void) {
|
||||
}
|
||||
}
|
||||
else if (TasmotaGlobal.restart_deepsleep) { // Restart 9
|
||||
#ifdef USE_DEEPSLEEP
|
||||
DeepSleepStart();
|
||||
// should never come to this line....
|
||||
#endif
|
||||
ESP.deepSleep(0); // Deep sleep mode with only hardware triggered wake up
|
||||
|
||||
}
|
||||
else {
|
||||
ESP_Restart();
|
||||
|
@ -149,7 +149,7 @@ void DeepSleepCalculate()
|
||||
// day_bitarray>0 otherwhise no weekday selected
|
||||
// rule keyword "Wakeup"
|
||||
// Timer action: rule
|
||||
if (xtimer.arm && day_bitarray && GetRule(0) == "Wakeup" && bitRead(Settings->rule_enabled | Settings->rule_once, 0) && POWER_BLINK == xtimer.power) {
|
||||
if (xtimer.arm && day_bitarray && GetRule(0) == "Wakeup" && (TasmotaGlobal.restart_deepsleep || bitRead(Settings->rule_enabled | Settings->rule_once, 0)) && POWER_BLINK == xtimer.power) {
|
||||
#ifdef USE_SUNRISE
|
||||
if ((1 == xtimer.mode) || (2 == xtimer.mode)) { // Sunrise or Sunset
|
||||
ApplyTimerOffsets(&xtimer);
|
||||
@ -210,7 +210,7 @@ void DeepSleepStart(void)
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("DSL: Time %ld, next %ld, slip %ld"), timeslip, RtcSettings.nextwakeup, RtcSettings.deepsleep_slip );
|
||||
// It may happen that wakeup in just <5 seconds in future
|
||||
// In this case also add deepsleep to nextwakeup
|
||||
if (RtcSettings.nextwakeup <= (LocalTime() + DEEPSLEEP_MIN_TIME)) {
|
||||
if (RtcSettings.nextwakeup <= (LocalTime() + DEEPSLEEP_MIN_TIME) && Settings->deepsleep > 0 ) {
|
||||
// ensure nextwakeup is at least in the future, and add 5%
|
||||
RtcSettings.nextwakeup += (((LocalTime() + DEEPSLEEP_MIN_TIME - RtcSettings.nextwakeup) / Settings->deepsleep) + 1) * Settings->deepsleep;
|
||||
//RtcSettings.nextwakeup += Settings->deepsleep * 0.05;
|
||||
@ -223,7 +223,9 @@ void DeepSleepStart(void)
|
||||
}
|
||||
// Limit sleeptime to DEEPSLEEP_MAX_CYCLE
|
||||
// uint32_t deepsleep_sleeptime = DEEPSLEEP_MAX_CYCLE < (RtcSettings.nextwakeup - LocalTime()) ? (uint32_t)DEEPSLEEP_MAX_CYCLE : RtcSettings.nextwakeup - LocalTime();
|
||||
deepsleep_sleeptime = tmin((uint32_t)DEEPSLEEP_MAX_CYCLE ,RtcSettings.nextwakeup - LocalTime());
|
||||
deepsleep_sleeptime = tmin((uint32_t)DEEPSLEEP_MAX_CYCLE ,RtcSettings.nextwakeup>0?RtcSettings.nextwakeup - LocalTime():0);
|
||||
|
||||
|
||||
|
||||
// Sending Deepsleep parameters to automation for react
|
||||
Response_P(PSTR("{\"" D_PRFX_DEEPSLEEP "\":{\"" D_JSON_TIME "\":\"%s\",\"" D_PRFX_DEEPSLEEP "\":%d,\"Wakeup\":%d}}"), (char*)dt.c_str(), LocalTime(), RtcSettings.nextwakeup);
|
||||
|
Loading…
x
Reference in New Issue
Block a user