Skip to content

0.11.0 – fewer requests for Intervals.icu, and a second review

Choose a tag to compare

@futureweb futureweb released this 13 Oct 21:14
· 32 commits to main since this release

Fewer requests for Intervals.icu – and a second review of the whole code

Adaptive polling (beta)

BRIDGE_POLL_MODE=adaptive (in Home Assistant: Adaptive polling; on the web page: Settings) tries to keep the load on Intervals.icu's API as low as it can without making you wait. It learns from your own archive when your activities usually end: per weekday and hour, over the last twelve weeks, with recent weeks counting most. It then checks at your full pace only at those times, every few minutes around them, and every 30 minutes at times you hardly ever upload. For an hour after a new activity it is fast again.

It never checks faster than BRIDGE_POLL_SECONDS, and never outside BRIDGE_POLL_HOURS. Until 15 activities are in the archive, it keeps the full pace. The log and the web page show what it learned. On my own account it comes to about 390 checks a day instead of 1,440.

It is still beta – feedback is very welcome in the forum thread.

Also new

  • Quiet hours with a slower pace: BRIDGE_POLL_QUIET_SECONDS. Outside BRIDGE_POLL_HOURS the bridge checks this often instead of not at all; unset, it doesn't check, as before.
  • Check now on the web page: checks at once, then at the full pace for the next hour.
  • The status page shows when the bridge checks and why. The settings page sets the pace, the hours, the quiet pace and the adaptive mode, and so do the Home Assistant app and the Unraid template.
  • watch decides itself when a check is due, so the shipped systemd timer starts it every minute again. A watch that isn't due ends without a request.
  • Each FIT file's CRC is checked once instead of three times: about 40 % less CPU per new activity (thanks @Michael.0000 – noticeable on a Raspberry Pi).

A second review

An independent AI code review (OpenAI Codex) went over the whole code base. I checked every finding against the code and reproduced it, then fixed it – about 30 fixes. Most are places where a rare failure could have cost data. None is known to have happened.

  • Swap mode:
    • Garmin's copy is deleted only once your values read back from the original.
    • Comments are checked again right before every delete, retries included.
    • An upload whose answer got lost is never sent twice.
  • Wellness:
    • A read in which one Garmin endpoint failed keeps what the archive had.
    • A write to Intervals that failed is tried again.
  • Rate limits: a 429 from Intervals pauses the whole run for as long as Intervals asks, and a failing full run backs off instead of retrying every minute.
  • Enriching:
    • A value you typed in by hand is never overwritten.
    • Custom stream scripts are only reproduced when they're the plain copy-one-field form.
    • New custom fields are picked up without a restart.
  • Web page and settings: request time limits and a connection cap, password checks one at a time, and no setting can be saved that the bridge couldn't start with.

The details are in the CHANGELOG.

Upgrading

  • pip install --upgrade garmin-intervals-bridge, pull the new image, or update the Home Assistant app.
  • systemd users: copy the watch timer again. To keep checking every minute: BRIDGE_POLL_SECONDS=60.