arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.73k stars 4.72k forks source link

Deep sleep with timers can wake multiple times due to clock drift. #21423

Closed smhc closed 3 weeks ago

smhc commented 1 month ago

PROBLEM DESCRIPTION

Having a WakeUp rule and timer of "6:30" can wake at 6:28 due to clock drift. It will then sync the clock and calculate the next wake up to be 6:30 and wake again in 2 minutes, waking twice instead of just once at roughly 6:30. (In my particular case I am using 'sunrise', but the same issue applies). Note that I am performing an explicit "Restart 9" a few seconds after booting.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

- [ ] If using rules, provide the output of this command: `Backlog Rule1; Rule2; Rule3`:
```lua
  Rules output here:
- [ ] Set `weblog` to 4 and then, when you experience your issue, provide the output of the Console log:
```lua
  Console output here:

TO REPRODUCE

Steps to reproduce the behavior:

  1. Create 6:30am timer with Rule 1 Wakeup
  2. Create a rule to immediately "Restart 9" after boot (can check other conditions to disable this)
  3. Monitor wake-ups over a period of days

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

Should only wake once at roughly 6:30am each day.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

I believe the code at: https://github.com/arendst/Tasmota/blob/development/tasmota/tasmota_xdrv_driver/xdrv_29_deepsleep.ino#L161

should be taking the 'slip' into account. Alternatively, perhaps it could calculate the repeat period of each timer and only consider it a target if it's more than 10% to the next trigger. e.g if it's a 24hr repeat timer, it will only wake for the timer if it's 2.4hrs or greater away. (sunrise/sunset would need to use 10% of 12hrs).

Otherwise, maybe the "5%" fix needs to be re-instated, as per: https://github.com/arendst/Tasmota/discussions/21295 This would ensure you wake after the target and won't have the issue of re-waking for the same timer. But I disagree a blanket "5%" is a good idea.. as this can throw out the target time by quite a bit for long sleeps.

(Please, remember to close the issue when the problem has been addressed)

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it hasn't any activity in last few weeks. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 3 weeks ago

This issue was automatically closed because of being stale. Feel free to open a new one if you still experience this problem.