Tasmota icon indicating copy to clipboard operation
Tasmota copied to clipboard

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

Open smhc opened this issue 3 months ago • 0 comments

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!

  • [x] Read the Contributing Guide and Policy and the Code of Conduct
  • [x] Searched the problem in issues
  • [x] Searched the problem in discussions
  • [x] Searched the problem in the docs
  • [x] Searched the problem in the chat
  • [x] Device used (e.g., Sonoff Basic): esp32-c3
  • [x] Tasmota binary firmware version number used: v13.4.0
    • [x] Pre-compiled
    • [ ] Self-compiled
  • [x] Flashing tools used: web
  • [ ] Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:


  • [ ] If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:


  • [ ] Provide the output of this command: Status 0:
  STATUS 0 output here:


  • [ ] Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
  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)

smhc avatar May 17 '24 04:05 smhc