tconnectsync 1.0.0__tar.gz → 2.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tconnectsync-1.0.0/tconnectsync.egg-info → tconnectsync-2.0.2}/PKG-INFO +29 -34
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/README.md +28 -33
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/setup.cfg +1 -1
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/__init__.py +22 -8
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/api/__init__.py +12 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/api/common.py +7 -2
- tconnectsync-2.0.2/tconnectsync/api/tandemsource.py +378 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/autoupdate.py +9 -9
- tconnectsync-2.0.2/tconnectsync/domain/tandemsource/event_class.py +39 -0
- tconnectsync-2.0.2/tconnectsync/domain/tandemsource/pump_settings.py +52 -0
- tconnectsync-2.0.2/tconnectsync/eventparser/build_events.py +172 -0
- tconnectsync-2.0.2/tconnectsync/eventparser/events.py +4388 -0
- tconnectsync-2.0.2/tconnectsync/eventparser/generic.py +15 -0
- tconnectsync-2.0.2/tconnectsync/eventparser/raw_event.py +35 -0
- tconnectsync-2.0.2/tconnectsync/eventparser/static_dicts.py +144 -0
- tconnectsync-2.0.2/tconnectsync/eventparser/transforms.py +121 -0
- tconnectsync-2.0.2/tconnectsync/eventparser/utils.py +23 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/features.py +7 -4
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/nightscout.py +6 -6
- tconnectsync-2.0.2/tconnectsync/parser/__init__.py +0 -0
- tconnectsync-2.0.2/tconnectsync/parser/nightscout.py +325 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/secret.py +5 -0
- tconnectsync-2.0.2/tconnectsync/sync/__init__.py +0 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/__init__.py +0 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/autoupdate.py +170 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/choose_device.py +48 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/helpers.py +8 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process.py +96 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_alarm.py +73 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_basal.py +86 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_basal_resume.py +66 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_basal_suspension.py +67 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_bolus.py +112 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_cartridge.py +100 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_cgm_alert.py +92 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_cgm_reading.py +76 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_cgm_start_join_stop.py +96 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/process_user_mode.py +244 -0
- tconnectsync-2.0.2/tconnectsync/sync/tandemsource/update_profiles.py +210 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2/tconnectsync.egg-info}/PKG-INFO +29 -34
- tconnectsync-2.0.2/tconnectsync.egg-info/SOURCES.txt +134 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tests/test_process.py +15 -15
- tconnectsync-1.0.0/tconnectsync/parser/nightscout.py +0 -184
- tconnectsync-1.0.0/tconnectsync.egg-info/SOURCES.txt +0 -78
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/LICENSE.md +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/pyproject.toml +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/setup.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/api/android.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/api/controliq.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/api/webui.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/api/ws2.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/check.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/domain/__init__.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/domain/bolus.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/domain/device_settings.py +0 -0
- {tconnectsync-1.0.0/tconnectsync/parser → tconnectsync-2.0.2/tconnectsync/domain/tandemsource}/__init__.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/domain/therapy_event.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/domain/utility.py +0 -0
- {tconnectsync-1.0.0/tconnectsync/sync → tconnectsync-2.0.2/tconnectsync/eventparser}/__init__.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/parser/ciq_therapy_events.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/parser/tconnect.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/process.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/sync/basal.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/sync/bolus.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/sync/cgm.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/sync/iob.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/sync/profile.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/sync/pump_events.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/util/__init__.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/util/cli.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync/util/constants.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync.egg-info/dependency_links.txt +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync.egg-info/entry_points.txt +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync.egg-info/requires.txt +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tconnectsync.egg-info/top_level.txt +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tests/test_autoupdate.py +0 -0
- {tconnectsync-1.0.0 → tconnectsync-2.0.2}/tests/test_secret.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tconnectsync
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: Syncs Tandem t:connect pump data to Nightscout for the t:slim X2
|
|
5
5
|
Home-page: https://github.com/jwoglom/tconnectsync
|
|
6
6
|
Author: James Woglom
|
|
@@ -23,29 +23,29 @@ Requires-Dist: python-dotenv
|
|
|
23
23
|

|
|
24
24
|
[](https://codecov.io/gh/jwoglom/tconnectsync)
|
|
25
25
|
|
|
26
|
-
Tconnectsync synchronizes data one-way from
|
|
26
|
+
Tconnectsync synchronizes data one-way from Tandem Source to Nightscout.
|
|
27
|
+
|
|
28
|
+
> [!IMPORTANT]
|
|
29
|
+
> Tandem has announced that t:connect will be shut down in favor of Tandem Source in the US beginning September 30, 2024.
|
|
30
|
+
> tconnectsync has undergone major changes to support Tandem Source. **For Tandem Source support, you MUST upgrade to tconnectsync version 2.0 or above.**
|
|
27
31
|
|
|
28
32
|
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](https://github.com/nightscout/cgm-remote-monitor) automatically.
|
|
29
33
|
Together with a CGM uploader, such as [xDrip+](https://github.com/NightscoutFoundation/xDrip) or the official Dexcom mobile app plus Dexcom Share, this allows your CGM _and_ pump data to be automatically uploaded to Nightscout!
|
|
30
34
|
|
|
31
|
-
If you have an Android phone, you can use [tconnectpatcher](https://github.com/jwoglom/tconnectpatcher) to modify the t:connect Android app to upload more frequently. By default, pump data is uploaded to Tandem's servers every hour, but with tconnectpatcher the frequency can be brought down to **as low as every five minutes**! This allows for nearly real-time (albeit not fully instantaneous) pump data updates, almost like your pump uploads data directly to Nightscout!
|
|
32
35
|
|
|
33
36
|
## How It Works
|
|
34
37
|
|
|
35
|
-
At a high level, tconnectsync works by querying Tandem's undocumented APIs to receive basal and bolus data from
|
|
38
|
+
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.
|
|
36
39
|
|
|
37
40
|
When you run the program with no arguments, it performs a single cycle of the following, and exits after completion:
|
|
38
41
|
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* Queries Nightscout
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
If run with the `--auto-update` flag, then the application performs the following steps:
|
|
42
|
+
* Logs in to Tandem Source
|
|
43
|
+
* Fetches your list of pumps, and unless overridden by an environment variable, fetches the event data for the pump which was most recently used
|
|
44
|
+
* Processes the internal pump event metadata to extract basal, bolus, CGM, and other pump event data
|
|
45
|
+
* Queries Nightscout to find the most recent data which was uploaded to it for each event category
|
|
46
|
+
* Uploads any missing data to Nightscout
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
* Whenever the internal event ID changes (denoting that the mobile app uploaded new data to synchronize), perform all of the above mentioned steps to synchronize data.
|
|
48
|
+
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.
|
|
49
49
|
|
|
50
50
|
## What Gets Synced
|
|
51
51
|
|
|
@@ -56,28 +56,23 @@ When setting up tconnectsync, you can choose to configure which synchronization
|
|
|
56
56
|
Here are a few examples of reasons why you might want to adjust the enabled synchronization features:
|
|
57
57
|
|
|
58
58
|
* If you currently input boluses into Nightscout manually with comments, then you may wish to _disable the `BOLUS` synchronization feature_ so that there are no duplicated boluses in Nightscout.
|
|
59
|
-
* If you want to see Sleep and Exercise Mode data appear in Nightscout, then you may
|
|
60
|
-
* If you want to automatically update your Nightscout insulin profile settings from your pump, then you may
|
|
59
|
+
* If you want to see Sleep and Exercise Mode data appear in Nightscout, then you may wish to _enable the `PUMP_EVENTS` synchronization feature_.
|
|
60
|
+
* If you want to automatically update your Nightscout insulin profile settings from your pump, then you may wish to _enable the `PROFILES` synchronization feature_.
|
|
61
61
|
|
|
62
62
|
These synchronization features are enabled by default:
|
|
63
63
|
|
|
64
64
|
* `BASAL`: Basal data
|
|
65
65
|
* `BOLUS`: Bolus data
|
|
66
|
+
* `PUMP_EVENTS`: Events reported by the pump. Includes support for the following:
|
|
67
|
+
* Alarms, like cartridge out-of-insulin or pump malfunction
|
|
68
|
+
* Basal suspension (user or pump-initiated) and resume
|
|
69
|
+
* Cartridge, cannula, and tubing filled
|
|
70
|
+
* Sleep and exercise modes
|
|
71
|
+
* `PROFILES`: Insulin profile information, including segments, basal rates, correction factors, carb ratios, and the profile which is active.
|
|
66
72
|
|
|
67
73
|
The following synchronization features can be optionally enabled:
|
|
74
|
+
* `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.**
|
|
68
75
|
|
|
69
|
-
* `PROFILES`: Insulin profile information, including segments, basal rates, correction factors, carb ratios, and the profile which is active.
|
|
70
|
-
* `PUMP_EVENTS`: Events reported by the pump. Includes support for the following:
|
|
71
|
-
* Site/Cartridge Change (occurs for both a site change and a cartridge change)
|
|
72
|
-
* Empty Cartridge/Pump Shutdown (from my investigation, occurs either when the cartridge runs out of insulin OR you hard-shut off the pump)
|
|
73
|
-
* User Suspended (occurs when you manually disable insulin delivery)
|
|
74
|
-
* Exercise Mode (in Nightscout, appears with a start and end time)
|
|
75
|
-
* Sleep Mode (in Nightscout, appears with a start and end time)
|
|
76
|
-
* `IOB`: Insulin-on-board data. Only the most recent IOB entry is saved to Nightscout, as an "activity". The Nightscout UI does not currently display this information. In order to read this value, you need to query the Nightscout activity API endpoint. If you don't know what that means, then there is no reason to enable this option.
|
|
77
|
-
|
|
78
|
-
The following synchronization features are considered to be in alpha, and haven't been widely tested. If you want to use them, [set `ENABLE_TESTING_MODES=true` for them to show up](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/features.py#L29):
|
|
79
|
-
* `BOLUS_BG`: Adds BG readings which are associated with boluses on the pump into the Nightscout treatment object. It will determine whether the BG reading was automatically filled via the Dexcom connection on the pump or was manually entered by seeing if the BG reading matches the current CGM reading as known to the pump at that time. Support for this is nearly complete.
|
|
80
|
-
* `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 requires additional testing before it should be considered ready.
|
|
81
76
|
|
|
82
77
|
To specify custom synchronization features, pass the names of the desired features to the `--features` flag, e.g.:
|
|
83
78
|
|
|
@@ -114,9 +109,6 @@ You should specify the following parameters:
|
|
|
114
109
|
TCONNECT_EMAIL='email@email.com'
|
|
115
110
|
TCONNECT_PASSWORD='password'
|
|
116
111
|
|
|
117
|
-
# Your pump's serial number (numeric)
|
|
118
|
-
PUMP_SERIAL_NUMBER=11111111
|
|
119
|
-
|
|
120
112
|
# URL of your Nightscout site
|
|
121
113
|
NS_URL='https://yournightscouturl/'
|
|
122
114
|
# Your Nightscout API_SECRET value
|
|
@@ -124,6 +116,9 @@ NS_SECRET='apisecret'
|
|
|
124
116
|
|
|
125
117
|
# Current timezone of the pump
|
|
126
118
|
TIMEZONE_NAME='America/New_York'
|
|
119
|
+
|
|
120
|
+
# OPTIONAL: Your pump's serial number (numeric)
|
|
121
|
+
PUMP_SERIAL_NUMBER=11111111
|
|
127
122
|
```
|
|
128
123
|
|
|
129
124
|
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](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
|
@@ -139,10 +134,10 @@ First, ensure that you have **Python 3** with **Pip** installed:
|
|
|
139
134
|
* **On MacOS:** Open Terminal. Install [Homebrew](https://brew.sh/), and then run `brew install python3`
|
|
140
135
|
* **On Linux:** Follow your distribution's specific instructions.
|
|
141
136
|
- For Debian/Ubuntu based distros, `sudo apt install python3 python3-pip`
|
|
142
|
-
- For CentOS/Rocky Linux 8:
|
|
137
|
+
- For CentOS/Rocky Linux 8:
|
|
143
138
|
- `sudo dnf install python39-pip`
|
|
144
|
-
- `sudo alternatives --set python /usr/bin/python3.9`
|
|
145
|
-
* **On Windows:**
|
|
139
|
+
- `sudo alternatives --set python /usr/bin/python3.9`
|
|
140
|
+
* **On Windows:**
|
|
146
141
|
- **With WSL:** Install Ubuntu under the [Windows Subsystem for Linux](https://ubuntu.com/wsl).
|
|
147
142
|
Open the Ubuntu Terminal, then run `sudo apt install python3 python3-pip`.
|
|
148
143
|
Perform the remainder of the steps under the Ubuntu environment.
|
|
@@ -424,7 +419,7 @@ An example of a user crontab `crontab -e` if not running system-wide, which runs
|
|
|
424
419
|
|
|
425
420
|
You can use one of the same `run.sh` files referenced above, but remove the `--auto-update` flag since you are handling the functionality for running the script periodically yourself.
|
|
426
421
|
|
|
427
|
-
### For Native Windows
|
|
422
|
+
### For Native Windows
|
|
428
423
|
|
|
429
424
|
Create a batch file 'tconnectsync.bat' file containing:
|
|
430
425
|
|
|
@@ -3,29 +3,29 @@
|
|
|
3
3
|

|
|
4
4
|
[](https://codecov.io/gh/jwoglom/tconnectsync)
|
|
5
5
|
|
|
6
|
-
Tconnectsync synchronizes data one-way from
|
|
6
|
+
Tconnectsync synchronizes data one-way from Tandem Source to Nightscout.
|
|
7
|
+
|
|
8
|
+
> [!IMPORTANT]
|
|
9
|
+
> Tandem has announced that t:connect will be shut down in favor of Tandem Source in the US beginning September 30, 2024.
|
|
10
|
+
> tconnectsync has undergone major changes to support Tandem Source. **For Tandem Source support, you MUST upgrade to tconnectsync version 2.0 or above.**
|
|
7
11
|
|
|
8
12
|
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](https://github.com/nightscout/cgm-remote-monitor) automatically.
|
|
9
13
|
Together with a CGM uploader, such as [xDrip+](https://github.com/NightscoutFoundation/xDrip) or the official Dexcom mobile app plus Dexcom Share, this allows your CGM _and_ pump data to be automatically uploaded to Nightscout!
|
|
10
14
|
|
|
11
|
-
If you have an Android phone, you can use [tconnectpatcher](https://github.com/jwoglom/tconnectpatcher) to modify the t:connect Android app to upload more frequently. By default, pump data is uploaded to Tandem's servers every hour, but with tconnectpatcher the frequency can be brought down to **as low as every five minutes**! This allows for nearly real-time (albeit not fully instantaneous) pump data updates, almost like your pump uploads data directly to Nightscout!
|
|
12
15
|
|
|
13
16
|
## How It Works
|
|
14
17
|
|
|
15
|
-
At a high level, tconnectsync works by querying Tandem's undocumented APIs to receive basal and bolus data from
|
|
18
|
+
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.
|
|
16
19
|
|
|
17
20
|
When you run the program with no arguments, it performs a single cycle of the following, and exits after completion:
|
|
18
21
|
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* Queries Nightscout
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
If run with the `--auto-update` flag, then the application performs the following steps:
|
|
22
|
+
* Logs in to Tandem Source
|
|
23
|
+
* Fetches your list of pumps, and unless overridden by an environment variable, fetches the event data for the pump which was most recently used
|
|
24
|
+
* Processes the internal pump event metadata to extract basal, bolus, CGM, and other pump event data
|
|
25
|
+
* Queries Nightscout to find the most recent data which was uploaded to it for each event category
|
|
26
|
+
* Uploads any missing data to Nightscout
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
* Whenever the internal event ID changes (denoting that the mobile app uploaded new data to synchronize), perform all of the above mentioned steps to synchronize data.
|
|
28
|
+
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.
|
|
29
29
|
|
|
30
30
|
## What Gets Synced
|
|
31
31
|
|
|
@@ -36,28 +36,23 @@ When setting up tconnectsync, you can choose to configure which synchronization
|
|
|
36
36
|
Here are a few examples of reasons why you might want to adjust the enabled synchronization features:
|
|
37
37
|
|
|
38
38
|
* If you currently input boluses into Nightscout manually with comments, then you may wish to _disable the `BOLUS` synchronization feature_ so that there are no duplicated boluses in Nightscout.
|
|
39
|
-
* If you want to see Sleep and Exercise Mode data appear in Nightscout, then you may
|
|
40
|
-
* If you want to automatically update your Nightscout insulin profile settings from your pump, then you may
|
|
39
|
+
* If you want to see Sleep and Exercise Mode data appear in Nightscout, then you may wish to _enable the `PUMP_EVENTS` synchronization feature_.
|
|
40
|
+
* If you want to automatically update your Nightscout insulin profile settings from your pump, then you may wish to _enable the `PROFILES` synchronization feature_.
|
|
41
41
|
|
|
42
42
|
These synchronization features are enabled by default:
|
|
43
43
|
|
|
44
44
|
* `BASAL`: Basal data
|
|
45
45
|
* `BOLUS`: Bolus data
|
|
46
|
+
* `PUMP_EVENTS`: Events reported by the pump. Includes support for the following:
|
|
47
|
+
* Alarms, like cartridge out-of-insulin or pump malfunction
|
|
48
|
+
* Basal suspension (user or pump-initiated) and resume
|
|
49
|
+
* Cartridge, cannula, and tubing filled
|
|
50
|
+
* Sleep and exercise modes
|
|
51
|
+
* `PROFILES`: Insulin profile information, including segments, basal rates, correction factors, carb ratios, and the profile which is active.
|
|
46
52
|
|
|
47
53
|
The following synchronization features can be optionally enabled:
|
|
54
|
+
* `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.**
|
|
48
55
|
|
|
49
|
-
* `PROFILES`: Insulin profile information, including segments, basal rates, correction factors, carb ratios, and the profile which is active.
|
|
50
|
-
* `PUMP_EVENTS`: Events reported by the pump. Includes support for the following:
|
|
51
|
-
* Site/Cartridge Change (occurs for both a site change and a cartridge change)
|
|
52
|
-
* Empty Cartridge/Pump Shutdown (from my investigation, occurs either when the cartridge runs out of insulin OR you hard-shut off the pump)
|
|
53
|
-
* User Suspended (occurs when you manually disable insulin delivery)
|
|
54
|
-
* Exercise Mode (in Nightscout, appears with a start and end time)
|
|
55
|
-
* Sleep Mode (in Nightscout, appears with a start and end time)
|
|
56
|
-
* `IOB`: Insulin-on-board data. Only the most recent IOB entry is saved to Nightscout, as an "activity". The Nightscout UI does not currently display this information. In order to read this value, you need to query the Nightscout activity API endpoint. If you don't know what that means, then there is no reason to enable this option.
|
|
57
|
-
|
|
58
|
-
The following synchronization features are considered to be in alpha, and haven't been widely tested. If you want to use them, [set `ENABLE_TESTING_MODES=true` for them to show up](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/features.py#L29):
|
|
59
|
-
* `BOLUS_BG`: Adds BG readings which are associated with boluses on the pump into the Nightscout treatment object. It will determine whether the BG reading was automatically filled via the Dexcom connection on the pump or was manually entered by seeing if the BG reading matches the current CGM reading as known to the pump at that time. Support for this is nearly complete.
|
|
60
|
-
* `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 requires additional testing before it should be considered ready.
|
|
61
56
|
|
|
62
57
|
To specify custom synchronization features, pass the names of the desired features to the `--features` flag, e.g.:
|
|
63
58
|
|
|
@@ -94,9 +89,6 @@ You should specify the following parameters:
|
|
|
94
89
|
TCONNECT_EMAIL='email@email.com'
|
|
95
90
|
TCONNECT_PASSWORD='password'
|
|
96
91
|
|
|
97
|
-
# Your pump's serial number (numeric)
|
|
98
|
-
PUMP_SERIAL_NUMBER=11111111
|
|
99
|
-
|
|
100
92
|
# URL of your Nightscout site
|
|
101
93
|
NS_URL='https://yournightscouturl/'
|
|
102
94
|
# Your Nightscout API_SECRET value
|
|
@@ -104,6 +96,9 @@ NS_SECRET='apisecret'
|
|
|
104
96
|
|
|
105
97
|
# Current timezone of the pump
|
|
106
98
|
TIMEZONE_NAME='America/New_York'
|
|
99
|
+
|
|
100
|
+
# OPTIONAL: Your pump's serial number (numeric)
|
|
101
|
+
PUMP_SERIAL_NUMBER=11111111
|
|
107
102
|
```
|
|
108
103
|
|
|
109
104
|
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](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
|
@@ -119,10 +114,10 @@ First, ensure that you have **Python 3** with **Pip** installed:
|
|
|
119
114
|
* **On MacOS:** Open Terminal. Install [Homebrew](https://brew.sh/), and then run `brew install python3`
|
|
120
115
|
* **On Linux:** Follow your distribution's specific instructions.
|
|
121
116
|
- For Debian/Ubuntu based distros, `sudo apt install python3 python3-pip`
|
|
122
|
-
- For CentOS/Rocky Linux 8:
|
|
117
|
+
- For CentOS/Rocky Linux 8:
|
|
123
118
|
- `sudo dnf install python39-pip`
|
|
124
|
-
- `sudo alternatives --set python /usr/bin/python3.9`
|
|
125
|
-
* **On Windows:**
|
|
119
|
+
- `sudo alternatives --set python /usr/bin/python3.9`
|
|
120
|
+
* **On Windows:**
|
|
126
121
|
- **With WSL:** Install Ubuntu under the [Windows Subsystem for Linux](https://ubuntu.com/wsl).
|
|
127
122
|
Open the Ubuntu Terminal, then run `sudo apt install python3 python3-pip`.
|
|
128
123
|
Perform the remainder of the steps under the Ubuntu environment.
|
|
@@ -404,7 +399,7 @@ An example of a user crontab `crontab -e` if not running system-wide, which runs
|
|
|
404
399
|
|
|
405
400
|
You can use one of the same `run.sh` files referenced above, but remove the `--auto-update` flag since you are handling the functionality for running the script periodically yourself.
|
|
406
401
|
|
|
407
|
-
### For Native Windows
|
|
402
|
+
### For Native Windows
|
|
408
403
|
|
|
409
404
|
Create a batch file 'tconnectsync.bat' file containing:
|
|
410
405
|
|
|
@@ -8,6 +8,9 @@ import pkg_resources
|
|
|
8
8
|
from .api import TConnectApi
|
|
9
9
|
from .process import process_time_range
|
|
10
10
|
from .autoupdate import Autoupdate
|
|
11
|
+
from .sync.tandemsource.autoupdate import TandemSourceAutoupdate
|
|
12
|
+
from .sync.tandemsource.choose_device import ChooseDevice as TandemSourceChooseDevice
|
|
13
|
+
from .sync.tandemsource.process import ProcessTimeRange as TandemSourceProcessTimeRange
|
|
11
14
|
from .check import check_login
|
|
12
15
|
from .nightscout import NightscoutApi
|
|
13
16
|
from .features import DEFAULT_FEATURES, ALL_FEATURES
|
|
@@ -44,6 +47,7 @@ def parse_args(*args, **kwargs):
|
|
|
44
47
|
parser.add_argument('--auto-update', dest='auto_update', action='store_const', const=True, default=False, help='If set, continuously checks for updates from t:connect and syncs with Nightscout.')
|
|
45
48
|
parser.add_argument('--check-login', dest='check_login', action='store_const', const=True, default=False, help='If set, checks that the provided t:connect credentials can be used to log in.')
|
|
46
49
|
parser.add_argument('--features', dest='features', nargs='+', default=DEFAULT_FEATURES, choices=ALL_FEATURES, help='Specifies what data should be synchronized between tconnect and Nightscout.')
|
|
50
|
+
parser.add_argument('--tandem-source', dest='tandem_source', action='store_const', const=True, default=False, help='FOR TESTING: Use Tandem Source')
|
|
47
51
|
|
|
48
52
|
return parser.parse_args(*args, **kwargs)
|
|
49
53
|
|
|
@@ -83,23 +87,33 @@ def main(*args, **kwargs):
|
|
|
83
87
|
if NS_URL == 'https://yournightscouturl/':
|
|
84
88
|
logging.warn('NO NIGHTSCOUT URL WAS PROVIDED. Ensure your have set NS_URL appropriately.')
|
|
85
89
|
if PUMP_SERIAL_NUMBER == '11111111':
|
|
86
|
-
|
|
90
|
+
if args.tandem_source:
|
|
91
|
+
secret.PUMP_SERIAL_NUMBER = None
|
|
92
|
+
else:
|
|
93
|
+
logging.warn('NO PUMP SERIAL NUMBER WAS PROVIDED. Ensure you have set PUMP_SERIAL_NUMBER appropriately.')
|
|
87
94
|
|
|
88
95
|
tconnect = TConnectApi(TCONNECT_EMAIL, TCONNECT_PASSWORD)
|
|
89
96
|
|
|
90
97
|
nightscout = NightscoutApi(NS_URL, NS_SECRET, skip_verify=NS_SKIP_TLS_VERIFY, ignore_conn_errors=NS_IGNORE_CONN_ERRORS)
|
|
91
98
|
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
# NOT YET MIGRATED
|
|
100
|
+
# if args.check_login:
|
|
101
|
+
# return check_login(tconnect, time_start, time_end)
|
|
102
|
+
|
|
103
|
+
logging.warning("THIS VERSION OF TCONNECTSYNC READS DATA FROM TANDEM SOURCE, AND MAY CONTAIN BUGS!")
|
|
104
|
+
logging.info("You may notice different behavior compared to older versions which utilized t:connect data sources.")
|
|
105
|
+
logging.info("To report a bug or to get help, see https://github.com/jwoglom/tconnectsync/issues")
|
|
94
106
|
|
|
95
107
|
logging.info("Enabled features: " + ", ".join(args.features))
|
|
96
108
|
|
|
109
|
+
if args.check_login:
|
|
110
|
+
args.pretend = True
|
|
111
|
+
|
|
97
112
|
if args.auto_update:
|
|
98
|
-
|
|
99
|
-
u = Autoupdate(secret)
|
|
113
|
+
u = TandemSourceAutoupdate(secret)
|
|
100
114
|
sys.exit(u.process(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features))
|
|
101
115
|
else:
|
|
102
|
-
|
|
103
|
-
added =
|
|
104
|
-
|
|
116
|
+
tconnectDevice = TandemSourceChooseDevice(secret, tconnect).choose()
|
|
117
|
+
added = TandemSourceProcessTimeRange(tconnect, nightscout, tconnectDevice, pretend=args.pretend, features=args.features).process(time_start, time_end)
|
|
118
|
+
sys.exit(added)
|
|
105
119
|
|
|
@@ -4,6 +4,7 @@ from .android import AndroidApi
|
|
|
4
4
|
from .controliq import ControlIQApi
|
|
5
5
|
from .ws2 import WS2Api
|
|
6
6
|
from .webui import WebUIScraper
|
|
7
|
+
from .tandemsource import TandemSourceApi
|
|
7
8
|
|
|
8
9
|
logger = logging.getLogger(__name__)
|
|
9
10
|
|
|
@@ -19,6 +20,17 @@ class TConnectApi:
|
|
|
19
20
|
self._ws2 = None
|
|
20
21
|
self._android = None
|
|
21
22
|
self._webui = None
|
|
23
|
+
self._tandemsource = None
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def tandemsource(self):
|
|
27
|
+
if self._tandemsource and not self._tandemsource.needs_relogin():
|
|
28
|
+
return self._tandemsource
|
|
29
|
+
|
|
30
|
+
logger.debug("Instantiating new TandemSourceApi")
|
|
31
|
+
|
|
32
|
+
self._tandemsource = TandemSourceApi(self.email, self.password)
|
|
33
|
+
return self._tandemsource
|
|
22
34
|
|
|
23
35
|
|
|
24
36
|
@property
|
|
@@ -11,6 +11,11 @@ def parse_date(date):
|
|
|
11
11
|
return date
|
|
12
12
|
return (date or datetime.datetime.now()).strftime('%m-%d-%Y')
|
|
13
13
|
|
|
14
|
+
def parse_ymd_date(date):
|
|
15
|
+
if type(date) == str:
|
|
16
|
+
date = arrow.get(date)
|
|
17
|
+
return (date or datetime.datetime.now()).strftime('%Y-%m-%d')
|
|
18
|
+
|
|
14
19
|
def parsed_date_to_arrow(date):
|
|
15
20
|
return arrow.get(datetime.datetime.strptime(date, '%m-%d-%Y'))
|
|
16
21
|
|
|
@@ -117,11 +122,11 @@ def split_days_range(start_a, end_a, days: int = 5) -> List[Tuple[str, str]]:
|
|
|
117
122
|
if (cur - cur_s).days >= days-1:
|
|
118
123
|
ranges.append((cur_s, cur))
|
|
119
124
|
cur_s = cur + datetime.timedelta(days=1)
|
|
120
|
-
|
|
125
|
+
|
|
121
126
|
cur += datetime.timedelta(days=1)
|
|
122
127
|
if len(ranges) > 0 and (end - ranges[-1][-1]).days > 0:
|
|
123
128
|
ranges.append((cur_s, end))
|
|
124
|
-
|
|
129
|
+
|
|
125
130
|
return ranges
|
|
126
131
|
|
|
127
132
|
class ApiException(Exception):
|