37 Commits
Author SHA1 Message Date
xannasavinandJames Woglom 823bb785ba Harden autoupdate against transient errors instead of exiting
get() retries only HTTP 401 and 500, so any other API error propagates out of
the autoupdate loop and exits the process. When Tandem retired the
reportsfacade endpoints and pumpeventmetadata began returning 404 (#146), a
container with a restart policy would crash-loop. That is the worst possible
response to an API outage: the credentials cache dies with the process, so
every restart performs a full login against sso.tandemdiabetes.com. In my EU
deployment that was a fresh login roughly every two minutes for hours from a
single IP, which seems a good way to earn a WAF ban while already broken.

Transient network errors (DNS failures, timeouts, mid-stream disconnects,
urllib3 retry-budget exhaustion) have the same problem.

This keeps both failure families inside the loop and backs off exponentially:
30s doubling to a cap of AUTOUPDATE_DEFAULT_SLEEP_SECONDS (300s default),
reset on any successful poll. The cap reuses the existing poll interval, so a
failing API is never contacted more often than a healthy one. After three
consecutive failures the log escalates from WARNING to ERROR.

Staying alive forever would make a real outage silent on deployments whose
only alarm is the container dying, so after AUTOUPDATE_API_FAILURE_MINUTES
(default 45) of unbroken failure the process gives up and exits non-zero.
That is roughly one restart per hour during a genuine outage instead of one
every two minutes, while short blips stay silent. Set 0 to disable.

This is deliberately not gated on AUTOUPDATE_RESTART_ON_FAILURE, which covers
the pump-not-uploading watchdog where restarting achieves nothing (as the
existing TODO notes) and which many users therefore disable. An unreachable
API is a different failure and gets its own knob.

ApiLoginException stays fatal: bad credentials are not transient, and
retrying them in-process would hammer the login endpoint with attempts that
cannot succeed.

Also included:

- A defensive clamp so a negative rolling-average entry can never reach
  time.sleep() and crash with ValueError.
- Tests covering the backoff sequence, reset-on-success, the sustained-failure
  exit, the opt-out, and that login failures and programming errors still
  propagate.
- README documentation for all nine AUTOUPDATE_* variables, none of which were
  documented outside secret.py.
2026-07-20 19:12:24 -04:00
ClaudeandJames Woglom ea7cc8f4ec Remove dead code for legacy pre-Tandem Source APIs
Since the 2.0 migration to Tandem Source, the live sync path
(api.tandemsource + sync/tandemsource/*) no longer references the
legacy t:connect APIs. This removes that now-unreachable code.

Removed modules:
- api/controliq.py, api/ws2.py, api/android.py, api/webui.py
  (the legacy controliq / tconnectws2 / android / webui clients)
- process.py (old process_time_range; already broken since it
  imported sync submodules that no longer exist)
- parser/ciq_therapy_events.py, parser/tconnect.py (TConnectEntry)
- domain/therapy_event.py, domain/bolus.py, domain/device_settings.py,
  domain/utility.py

Trimmed dead wiring from live modules:
- api/__init__.py: dropped the controliq/ws2/android/webui properties,
  keeping only the tandemsource accessor
- check.py: removed the unused TConnectEntry import
- parser/nightscout.py: removed the unused legacy profile_store() plus
  the now-orphaned tandem_to_ns_time / tandem_to_ns_time_seconds helpers
  and InvalidTimeException (the live path uses tandemsource_profile_store)

Tests: removed suites covering the deleted modules; pared tests/api/fake.py
down to the TConnectApi fake still used by the tandemsource tests. README
"Tandem APIs" sections updated to reflect the single Tandem Source API.

Full test suite passes (48 passed, 1 skipped).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LQNn3mBG1kXTAdQb9c2jfW
2026-06-30 19:12:44 -04:00
James Woglom 4837ac1e86 v2.3.0 2025-06-07 23:34:42 -04:00
James Woglom 34853dfb36 update readme and default sync features 2024-09-29 23:17:43 -04:00
James Woglom 68384caa04 remove tconnectpatcher ref 2024-09-19 00:16:27 -04:00
James Woglom 75260c6957 update readme 2024-09-19 00:14:41 -04:00
James WoglomandGitHub a781e458c3 Update README.md 2023-09-30 21:01:15 -04:00
James Woglom 166a142de5 Update README.md 2023-02-04 19:04:58 -05:00
jwalbergandJames Woglom b68425c5d3 Fixed typo in batch file instructions 2023-02-04 19:04:58 -05:00
jwalbergandJames Woglom 9ab6906e81 Update Readme.md for non-WSL Windows installation
This works in Windows, as-is. Updated the installation instructions with folder paths and scheduling instructions.
2023-02-04 19:04:58 -05:00
James Woglom 3b66718e1f update README with profile sync feature 2023-01-16 17:01:04 -05:00
t1diotacandJames Woglom dfc39d61bb Update README.md
- Added sections on creating a user-specific install and crontab.
- Added bullet points on installing on CentOS/RHEL/Rocky Linux 8
2022-08-19 10:31:39 -04:00
James Woglom 8f6d03797a update API section in readme, and check-login script to properly sanitize 2022-08-12 00:06:17 -04:00
James Woglom b4d0dad267 remove IOB feature in defaults because it is currently not displayed in the UI. document features in readme 2022-01-08 03:55:26 -05:00
James Woglom 8b1ece3ac3 readme: rephrase initial section 2022-01-04 21:23:18 -05:00
James Woglom 7b06f1c457 secret: parse API_SECRET/TZ if NS_SECRET/TIMEZONE_NAME are missing 2022-01-04 21:02:20 -05:00
James WoglomandGitHub b52006b3b0 Update README to include Heroku instructions 2022-01-03 16:52:11 -05:00
James WoglomandGitHub 59816225e0 Update README.md 2021-12-23 21:59:18 -05:00
James WoglomandGitHub be113e9cf7 Update README.md 2021-12-23 21:56:38 -05:00
James Woglom 27ba5d9a64 Update dotenv secret parsing logic, and read from .config/tconnectsync/.env path 2021-12-23 19:39:51 -05:00
James WoglomandGitHub 2140bd356e Update README.md with note about forking the repo 2021-12-15 15:31:33 -05:00
James Woglom b0ffe9bcfc update to 1.6 2021-12-04 22:00:56 -05:00
James WoglomandGitHub 99341c5443 README: use GitHub Registry instead of Docker Hub 2021-10-20 01:40:20 -04:00
James Woglom b53fb9c099 README: update with pip installation mechanism, and clarify installation steps 2021-10-20 01:28:43 -04:00
James WoglomandGitHub 9c8e5c150c Add codecov badge 2021-04-24 23:36:38 -04:00
James WoglomandGitHub 739c01f876 Merge pull request #4 from LegendaryGeek/master
Update README.md to correct the docker run commands
2021-04-03 23:30:19 -04:00
James WoglomandGitHub 8ce8b42bfc Update README.md 2021-04-03 23:26:38 -04:00
James WoglomandGitHub c14298384a Update README.md - clarify folder for .env 2021-04-03 23:21:54 -04:00
LegendaryGeekandGitHub 84067015e3 Update README.md to correct the docker run commands 2021-04-03 18:08:20 -04:00
James Woglom d804510633 .github/workflows: update workflow, add readme badge 2021-03-18 02:17:44 -04:00
James Woglom 3911da7d37 refactor: update file links in readme 2021-03-18 01:10:51 -04:00
James WoglomandGitHub 7ec4f96cba Update README.md - quote values in env file 2021-03-16 20:40:15 -04:00
James WoglomandGitHub c2674fcb1b Update README: Add Docker Hub repo 2021-03-15 22:52:00 -04:00
James Woglom b7e8dceef1 Add dockerfile and instructions in README 2021-03-15 20:42:13 -04:00
James WoglomandGitHub 1c09beb5c3 Update README.md 2021-03-15 00:45:30 -04:00
James WoglomandGitHub d841c3811a Update README.md 2021-03-15 00:39:29 -04:00
James Woglom dd77e07f50 add readme 2021-03-15 00:13:57 -04:00