Tconnectsync
Syncs data from Tandem Source (formerly t:connect) to Nightscout for the t:slim X2 and Mobi insulin pumps
Install / Use
/learn @jwoglom/TconnectsyncREADME
tconnectsync
Tconnectsync synchronizes data one-way from Tandem Source to Nightscout.
[!IMPORTANT] Tandem has announced that t:connect will be shut down in favor of Tandem Source in the US beginning September 30, 2024. tconnectsync has undergone major changes to support Tandem Source. For Tandem Source support, you MUST upgrade to tconnectsync version 2.0 or above.
If you have a t:slim X2 pump with the companion t:connect mobile Android or iOS app, this will allow your pump bolus and basal data to be uploaded to Nightscout automatically. Together with a CGM uploader, such as xDrip+ or the official Dexcom mobile app plus Dexcom Share, this allows your CGM and pump data to be automatically uploaded to Nightscout!
How It Works
At a high level, tconnectsync works by querying Tandem's undocumented APIs to receive basal and bolus data from Tandem Source, and then uploads that data as treatment objects to Nightscout. It contains features for checking for new Tandem pump data continuously, and updating that data to Nightscout whenever there is new data.
When you run the program with no arguments, it performs a single cycle of the following, and exits after completion:
- Logs in to Tandem Source
- Fetches your list of pumps, and unless overridden by an environment variable, fetches the event data for the pump which was most recently used
- Processes the internal pump event metadata to extract basal, bolus, CGM, and other pump event data
- Queries Nightscout to find the most recent data which was uploaded to it for each event category
- Uploads any missing data to Nightscout
If run with the --auto-update flag, then the application periodically looks for new data and synchronizes it to Nightscout in a loop every few minutes.
What Gets Synced
Tconnectsync is composed of individual so-called synchronization features, which are elements of data that can be synchronized between t:connect data from the pump and Nightscout. When setting up tconnectsync, you can choose to configure which synchronization features are enabled and disabled.
Here are a few examples of reasons why you might want to adjust the enabled synchronization features:
- If you currently input boluses into Nightscout manually with comments, then you may wish to disable the
BOLUSsynchronization feature so that there are no duplicated boluses in Nightscout. - If you want to see Sleep and Exercise Mode data appear in Nightscout, then you may wish to enable the
PUMP_EVENTSsynchronization feature. - If you want to automatically update your Nightscout insulin profile settings from your pump, then you may wish to enable the
PROFILESsynchronization feature.
These synchronization features are enabled by default:
BASAL: Basal dataBOLUS: Bolus dataPUMP_EVENTS: Events reported by the pump. Includes support for the following:- Alarms, like cartridge out-of-insulin or pump malfunction
- Basal suspension (user or pump-initiated) and resume
- Cartridge, cannula, and tubing filled
- Sleep and exercise modes
PROFILES: Insulin profile information, including segments, basal rates, correction factors, carb ratios, and the profile which is active.
The following synchronization features can be optionally enabled:
CGM: Adds Dexcom CGM readings from the pump to Nightscout as SGV (sensor glucose value) entries. This should only be used in a situation where xDrip/Dexcom Share/etc. is not used and the pump connection to the CGM will be the only source of CGM data to Nightscout. THIS WILL DELIVER CGM DATA WITH A SIGNIFICANT (>30 MINUTE) LAG AND SHOULD NOT BE USED AS A REPLACEMENT FOR DEXCOM SHARE OR OTHER REAL TIME MONITORING.
To specify custom synchronization features, pass the names of the desired features to the --features flag, e.g.:
$ tconnectsync --features BASAL BOLUS PUMP_EVENTS PROFILES
If you're using tconnectsync-heroku, see this section in its README.
Setup
The following setup instructions assume that you have a Linux, MacOS, or Windows (with WSL) machine that will run the application continuously.
If you've configured Nightscout before, you may be familiar with Heroku. You can opt to run tconnectsync with Heroku by following these instructions.
To get started, you need to choose whether to install the application on your computer via Pip, Pipenv, or Docker.
After that, you can choose to run the program continuously via Supervisord or on a regular interval with Cron.
NOTE: If you fork the tconnectsync repository on GitHub, do not commit your .env file. If pushed to GitHub, this will make your tconnect and Nightscout passwords publicly visible and put your data at risk.
Installation
First, you need to create a file containing configuration values.
The name of this file will be .env, and its location will be dependent on which
method of installation you choose.
You should specify the following parameters:
# Your credentials for t:connect
TCONNECT_EMAIL='email@email.com'
TCONNECT_PASSWORD='password'
# OPTIONAL: Your region (US or EU)
TCONNECT_REGION=US
# URL of your Nightscout site
NS_URL='https://yournightscouturl/'
# Your Nightscout API_SECRET value
NS_SECRET='apisecret'
# Current timezone of the pump
TIMEZONE_NAME='America/New_York'
# OPTIONAL: Your pump's serial number (numeric)
PUMP_SERIAL_NUMBER=11111111
This file contains your t:connect username and password, Tandem pump serial number (which is utilized in API calls to t:connect), your Nightscout URL and secret token (for uploading data to Nightscout), and local timezone (the timezone used in t:connect). When specifying the timezone, enter a TZ database name value.
(Alternatively, these values can be specified via environment variables.)
Installation via Pip
This is the easiest method to install.
First, ensure that you have Python 3 with Pip installed:
- On MacOS: Open Terminal. Install Homebrew, and then run
brew install python3 - On Linux: Follow your distribution's specific instructions.
- For Debian/Ubuntu based distros,
sudo apt install python3 python3-pip - For CentOS/Rocky Linux 8:
sudo dnf install python39-pipsudo alternatives --set python /usr/bin/python3.9
- For Debian/Ubuntu based distros,
- On Windows:
- With WSL: Install Ubuntu under the Windows Subsystem for Linux.
Open the Ubuntu Terminal, then run
sudo apt install python3 python3-pip. Perform the remainder of the steps under the Ubuntu environment. - Native: Alternatively, you can run tconnectsync in native Windows with no modifications. However, this is less well-tested (open a GitHub issue if you experience any problems).
- With WSL: Install Ubuntu under the Windows Subsystem for Linux.
Open the Ubuntu Terminal, then run
Now install the tconnectsync package with pip:
$ pip3 install tconnectsync
To install into a user environment instead of system-wide for a more contained install:
$ pip3 install --user tconnectsync
- This will place the tconnectsync binary file at
/home/<username>/.local/bin/tconnectsync - For non-WSL Windows, it will be in
<PYTHON DIRECTORY>\Lib\site-packages\tconnectsync
If the pip3 command is not found, run python3 -m pip install tconnectsync instead.
After this, you should be able to view tconnectsync's help with:
$ tconnectsync --help
usage: tconnectsync [-h] [--version] [--pretend] [-v] [--start-date START_DATE] [--end-date END_DATE] [--days DAYS] [--auto-update] [--check-login]
[--features {BASAL,BOLUS,IOB,PUMP_EVENTS} [{BASAL,BOLUS,IOB,PUMP_EVENTS} ...]]
Syncs bolus, basal, and IOB data from Tandem Diabetes t:connect to Nightscout.
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
--pretend Pretend mode: do not upload any data to Nightscout.
-v, --verbose Verbose mode: show extra logging details
--start-date START_DATE
The oldest date to process data from. Must be specified with --end-date.
--end-date END_DATE The newest date to process data until (inclusive). Must be specified with --start-date.
--days DAYS The number of days of t:connect data to read in. Cannot be used with --from-date and --until-date.
--auto-update If set, continuously checks for updates from t:connect and syncs with Nightscout.
--check-login If set, checks that the provided t:connect credentials can be used to log in.
--features {BASAL,BOLUS,IOB,PUMP_EVENTS} [{BASAL,BOLUS,IOB,PUMP_EVENTS} ...]
Specifies what data should be synchronized between tconnect and Nightscout.
Move the .env file you created to the following folder:
- MacOS:
/Users/<username>/.config/tconnectsync/.env - Linux:
$HOME/.config/tconnectsync/.env - Windows:
$HOME/.config/tconnectsync/.env(inside WSL) ORC:\Users\<username>\.config\tconnectsync(native Windows)
$ tconnectsync --check-login
If you receive no errors, then you can move on to the Running Tconnectsync Continuously section.
Installing with Pipenv
You can run the application using Pipenv.
First, ensure you have Python 3 and pip installed, then install pipenv with pip3 install pipenv.
Clone the Git repository for tconnectsync and cd into it with:
$ git clone https://github.com/jwoglom/tconnectsync
$ cd tconnectsync
Then i
Related Skills
node-connect
352.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
