tconnectsync 2.3.1__tar.gz → 3.0.0__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.
Files changed (74) hide show
  1. {tconnectsync-2.3.1/tconnectsync.egg-info → tconnectsync-3.0.0}/PKG-INFO +12 -12
  2. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/README.md +6 -8
  3. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/setup.cfg +6 -4
  4. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/__init__.py +5 -4
  5. tconnectsync-3.0.0/tconnectsync/api/__init__.py +26 -0
  6. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/api/tandemsource.py +321 -81
  7. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/check.py +16 -10
  8. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/domain/tandemsource/event_class.py +3 -3
  9. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/domain/tandemsource/pump_settings.py +17 -15
  10. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/eventparser/build_events.py +48 -1
  11. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/eventparser/events.py +2090 -979
  12. tconnectsync-3.0.0/tconnectsync/eventparser/generic.py +41 -0
  13. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/eventparser/raw_event.py +17 -0
  14. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/eventparser/static_dicts.py +13 -2
  15. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/eventparser/transforms.py +30 -4
  16. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/nightscout.py +22 -17
  17. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/parser/nightscout.py +2 -75
  18. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/autoupdate.py +7 -5
  19. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/choose_device.py +28 -12
  20. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/cli_helpers.py +1 -1
  21. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process.py +17 -5
  22. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_alarm.py +14 -8
  23. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_basal.py +16 -9
  24. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_basal_resume.py +11 -5
  25. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_basal_suspension.py +12 -6
  26. tconnectsync-3.0.0/tconnectsync/sync/tandemsource/process_bolus.py +134 -0
  27. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_cartridge.py +22 -10
  28. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_cgm_alert.py +20 -12
  29. tconnectsync-3.0.0/tconnectsync/sync/tandemsource/process_cgm_reading.py +133 -0
  30. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_cgm_start_join_stop.py +16 -11
  31. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_device_status.py +29 -9
  32. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/process_user_mode.py +38 -32
  33. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/update_profiles.py +15 -11
  34. {tconnectsync-2.3.1 → tconnectsync-3.0.0/tconnectsync.egg-info}/PKG-INFO +12 -12
  35. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync.egg-info/SOURCES.txt +0 -22
  36. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync.egg-info/requires.txt +10 -2
  37. tconnectsync-2.3.1/tconnectsync/api/__init__.py +0 -80
  38. tconnectsync-2.3.1/tconnectsync/api/android.py +0 -175
  39. tconnectsync-2.3.1/tconnectsync/api/controliq.py +0 -206
  40. tconnectsync-2.3.1/tconnectsync/api/webui.py +0 -296
  41. tconnectsync-2.3.1/tconnectsync/api/ws2.py +0 -174
  42. tconnectsync-2.3.1/tconnectsync/domain/bolus.py +0 -25
  43. tconnectsync-2.3.1/tconnectsync/domain/device_settings.py +0 -44
  44. tconnectsync-2.3.1/tconnectsync/domain/therapy_event.py +0 -483
  45. tconnectsync-2.3.1/tconnectsync/domain/utility.py +0 -24
  46. tconnectsync-2.3.1/tconnectsync/eventparser/generic.py +0 -21
  47. tconnectsync-2.3.1/tconnectsync/parser/ciq_therapy_events.py +0 -27
  48. tconnectsync-2.3.1/tconnectsync/parser/tconnect.py +0 -221
  49. tconnectsync-2.3.1/tconnectsync/process.py +0 -202
  50. tconnectsync-2.3.1/tconnectsync/sync/tandemsource/process_bolus.py +0 -112
  51. tconnectsync-2.3.1/tconnectsync/sync/tandemsource/process_cgm_reading.py +0 -76
  52. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/LICENSE.md +0 -0
  53. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/pyproject.toml +0 -0
  54. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/setup.py +0 -0
  55. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/__main__.py +0 -0
  56. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/api/common.py +0 -0
  57. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/domain/__init__.py +0 -0
  58. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/domain/tandemsource/__init__.py +0 -0
  59. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/eventparser/__init__.py +0 -0
  60. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/eventparser/utils.py +0 -0
  61. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/features.py +0 -0
  62. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/parser/__init__.py +0 -0
  63. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/secret.py +0 -0
  64. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/__init__.py +0 -0
  65. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/__init__.py +0 -0
  66. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/helpers.py +0 -0
  67. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/sync/tandemsource/heroku_helpers.py +0 -0
  68. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/util/__init__.py +0 -0
  69. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/util/cli.py +0 -0
  70. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync/util/constants.py +0 -0
  71. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync.egg-info/dependency_links.txt +0 -0
  72. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync.egg-info/entry_points.txt +0 -0
  73. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tconnectsync.egg-info/top_level.txt +0 -0
  74. {tconnectsync-2.3.1 → tconnectsync-3.0.0}/tests/test_secret.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tconnectsync
3
- Version: 2.3.1
4
- Summary: Syncs Tandem Source (formerly t:connect) insulin pump data to Nightscout for the t:slim X2
3
+ Version: 3.0.0
4
+ Summary: Syncs Tandem Source (formerly t:connect) insulin pump data to Nightscout for the t:slim X2 and Tandem Mobi
5
5
  Home-page: https://github.com/jwoglom/tconnectsync
6
6
  Author: James Woglom
7
7
  Author-email: j@wogloms.net
@@ -22,11 +22,13 @@ Requires-Dist: pysocks
22
22
  Requires-Dist: urllib3
23
23
  Requires-Dist: requests
24
24
  Requires-Dist: requests-oidc
25
- Requires-Dist: PyJWT
26
- Requires-Dist: cryptography
25
+ Requires-Dist: PyJWT==2.8.0
26
+ Requires-Dist: cryptography==43.0.1; python_version < "3.9"
27
+ Requires-Dist: cryptography; python_version >= "3.9"
27
28
  Requires-Dist: dataclasses-json
28
29
  Requires-Dist: cffi
29
30
  Requires-Dist: typing-extensions
31
+ Requires-Dist: importlib-metadata; python_version < "3.8"
30
32
  Dynamic: license-file
31
33
 
32
34
  # tconnectsync
@@ -450,13 +452,11 @@ If main.py doesn't exist in `C:\Users\<USERNAME>\AppData\Local\Programs\Python\<
450
452
 
451
453
  ## Tandem APIs
452
454
 
453
- This application utilizes three separate Tandem APIs for obtaining t:connect data, referenced here by the identifying part of their URLs:
455
+ As of version 2.0, tconnectsync retrieves all of its data from a single Tandem API, [**tandemsource**](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/api/tandemsource.py), which powers [Tandem Source](https://source.tandemdiabetes.com/). After logging in, tconnectsync fetches the list of pumps on the account along with a stream of raw pump event data, which is decoded locally (see [`tconnectsync/eventparser`](https://github.com/jwoglom/tconnectsync/tree/master/tconnectsync/eventparser)) to extract basal, bolus, CGM, and other pump events.
454
456
 
455
- * [**controliq**](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/api/controliq.py) - Contains Control:IQ related data, namely a timeline of all Basal events uploaded by the pump, separated by type (temp basals, algorithmically-updated basals, or profile-updated basals). Additionally includes CGM and Bolus data.
456
- * [**android**](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/api/android.py) - Used internally by the t:connect Android app, these API endpoints were discovered by reverse-engineering the Android app. Most of the API endpoints are used for uploading pump data, and tconnectsync uses one endpoint which returns the most recent event ID uploaded by the pump, so we know when more data has been uploaded.
457
- * [**tconnectws2**](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/api/ws2.py) - More legacy than the others, this seems to power the bulk of the main t:connect website. It is used as a last resort due to severe performance issues with this API (see https://github.com/jwoglom/tconnectsync/issues/43). We can use it to retrieve a CSV export of non-ControlIQ basal data, as well as bolus and IOB data. It is only used for bolus data as a fallback, and for pump-reported IOB data if requested. Full tracking of pump events also uses a limited version of this API.
457
+ > Earlier versions of tconnectsync (1.x) instead used three separate legacy t:connect APIs (`controliq`, `android`, and `tconnectws2`). Those APIs — and the code supporting them — were removed once t:connect was shut down in favor of Tandem Source.
458
458
 
459
- I have only tested tconnectsync with a Tandem pump set in the US Eastern timezone. Tandem's (to us, undocumented) APIs are [a bit loose with timezones](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/parser.py#L15), so please let me know if you notice any timezone-related bugs.
459
+ I have only tested tconnectsync with a Tandem pump set in the US Eastern timezone. Tandem's (to us, undocumented) APIs are a bit loose with timezones, so please let me know if you notice any timezone-related bugs.
460
460
  ## Backfilling t:connect Data
461
461
 
462
462
  To backfill existing t:connect data in to Nightscout, you can use the `--start-date` and `--end-date` options. For example, the following will upload all t:connect data between January 1st and March 1st, 2020 to Nightscout:
@@ -469,14 +469,14 @@ In order to bulk-import a lot of data, you may need to use shorter intervals, an
469
469
 
470
470
  One oddity when backfilling data is that the Control:IQ specific API endpoints return errors if they are queried before you updated your pump to utilize Control:IQ. This is [partially worked around in tconnectsync's code](https://github.com/jwoglom/tconnectsync/blob/d841c3811aeff3671d941a7d3ff4b80cce6a219e/main.py#L238), but you might need to update the logic if you did not switch to a Control:IQ enabled pump immediately after launch.
471
471
 
472
- ## t:connect API Testing
472
+ ## Tandem Source API Testing
473
473
 
474
- To test t:connect API endpoints in a Python shell, you can do something like the following:
474
+ To test Tandem Source API endpoints in a Python shell, you can do something like the following:
475
475
 
476
476
  ```python
477
477
  import tconnectsync
478
478
  tconnectsync.util.cli.enable_logging()
479
479
  api = tconnectsync.util.cli.get_api()
480
480
  # Make API calls, e.g.
481
- therapy_timeline = api.controliq.therapy_timeline('2022-08-01', '2022-08-10')
481
+ pumps = api.tandemsource.pump_event_metadata()
482
482
  ```
@@ -419,13 +419,11 @@ If main.py doesn't exist in `C:\Users\<USERNAME>\AppData\Local\Programs\Python\<
419
419
 
420
420
  ## Tandem APIs
421
421
 
422
- This application utilizes three separate Tandem APIs for obtaining t:connect data, referenced here by the identifying part of their URLs:
422
+ As of version 2.0, tconnectsync retrieves all of its data from a single Tandem API, [**tandemsource**](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/api/tandemsource.py), which powers [Tandem Source](https://source.tandemdiabetes.com/). After logging in, tconnectsync fetches the list of pumps on the account along with a stream of raw pump event data, which is decoded locally (see [`tconnectsync/eventparser`](https://github.com/jwoglom/tconnectsync/tree/master/tconnectsync/eventparser)) to extract basal, bolus, CGM, and other pump events.
423
423
 
424
- * [**controliq**](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/api/controliq.py) - Contains Control:IQ related data, namely a timeline of all Basal events uploaded by the pump, separated by type (temp basals, algorithmically-updated basals, or profile-updated basals). Additionally includes CGM and Bolus data.
425
- * [**android**](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/api/android.py) - Used internally by the t:connect Android app, these API endpoints were discovered by reverse-engineering the Android app. Most of the API endpoints are used for uploading pump data, and tconnectsync uses one endpoint which returns the most recent event ID uploaded by the pump, so we know when more data has been uploaded.
426
- * [**tconnectws2**](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/api/ws2.py) - More legacy than the others, this seems to power the bulk of the main t:connect website. It is used as a last resort due to severe performance issues with this API (see https://github.com/jwoglom/tconnectsync/issues/43). We can use it to retrieve a CSV export of non-ControlIQ basal data, as well as bolus and IOB data. It is only used for bolus data as a fallback, and for pump-reported IOB data if requested. Full tracking of pump events also uses a limited version of this API.
424
+ > Earlier versions of tconnectsync (1.x) instead used three separate legacy t:connect APIs (`controliq`, `android`, and `tconnectws2`). Those APIs — and the code supporting them — were removed once t:connect was shut down in favor of Tandem Source.
427
425
 
428
- I have only tested tconnectsync with a Tandem pump set in the US Eastern timezone. Tandem's (to us, undocumented) APIs are [a bit loose with timezones](https://github.com/jwoglom/tconnectsync/blob/master/tconnectsync/parser.py#L15), so please let me know if you notice any timezone-related bugs.
426
+ I have only tested tconnectsync with a Tandem pump set in the US Eastern timezone. Tandem's (to us, undocumented) APIs are a bit loose with timezones, so please let me know if you notice any timezone-related bugs.
429
427
  ## Backfilling t:connect Data
430
428
 
431
429
  To backfill existing t:connect data in to Nightscout, you can use the `--start-date` and `--end-date` options. For example, the following will upload all t:connect data between January 1st and March 1st, 2020 to Nightscout:
@@ -438,14 +436,14 @@ In order to bulk-import a lot of data, you may need to use shorter intervals, an
438
436
 
439
437
  One oddity when backfilling data is that the Control:IQ specific API endpoints return errors if they are queried before you updated your pump to utilize Control:IQ. This is [partially worked around in tconnectsync's code](https://github.com/jwoglom/tconnectsync/blob/d841c3811aeff3671d941a7d3ff4b80cce6a219e/main.py#L238), but you might need to update the logic if you did not switch to a Control:IQ enabled pump immediately after launch.
440
438
 
441
- ## t:connect API Testing
439
+ ## Tandem Source API Testing
442
440
 
443
- To test t:connect API endpoints in a Python shell, you can do something like the following:
441
+ To test Tandem Source API endpoints in a Python shell, you can do something like the following:
444
442
 
445
443
  ```python
446
444
  import tconnectsync
447
445
  tconnectsync.util.cli.enable_logging()
448
446
  api = tconnectsync.util.cli.get_api()
449
447
  # Make API calls, e.g.
450
- therapy_timeline = api.controliq.therapy_timeline('2022-08-01', '2022-08-10')
448
+ pumps = api.tandemsource.pump_event_metadata()
451
449
  ```
@@ -1,9 +1,9 @@
1
1
  [metadata]
2
2
  name = tconnectsync
3
- version = 2.3.1
3
+ version = 3.0.0
4
4
  author = James Woglom
5
5
  author_email = j@wogloms.net
6
- description = Syncs Tandem Source (formerly t:connect) insulin pump data to Nightscout for the t:slim X2
6
+ description = Syncs Tandem Source (formerly t:connect) insulin pump data to Nightscout for the t:slim X2 and Tandem Mobi
7
7
  long_description = file: README.md
8
8
  long_description_content_type = text/markdown
9
9
  url = https://github.com/jwoglom/tconnectsync
@@ -30,11 +30,13 @@ install_requires =
30
30
  urllib3
31
31
  requests
32
32
  requests-oidc
33
- PyJWT
34
- cryptography
33
+ PyJWT==2.8.0
34
+ cryptography==43.0.1; python_version < "3.9"
35
+ cryptography; python_version >= "3.9"
35
36
  dataclasses-json
36
37
  cffi
37
38
  typing-extensions
39
+ importlib-metadata; python_version < "3.8"
38
40
 
39
41
  [options.packages.find]
40
42
  where = .
@@ -3,13 +3,15 @@ import datetime
3
3
  import arrow
4
4
  import argparse
5
5
  import logging
6
- import pkg_resources
7
6
  import typing
8
7
 
9
8
  # Required for cryptography lib in python 3.7
10
9
  if sys.version_info < (3, 8):
11
10
  import typing_extensions
12
11
  typing.Protocol = typing_extensions.Protocol
12
+ from importlib_metadata import PackageNotFoundError, version
13
+ else:
14
+ from importlib.metadata import PackageNotFoundError, version
13
15
 
14
16
  from .api import TConnectApi
15
17
  from .sync.tandemsource.autoupdate import TandemSourceAutoupdate
@@ -37,8 +39,8 @@ except Exception as e:
37
39
 
38
40
 
39
41
  try:
40
- __version__ = pkg_resources.require("tconnectsync")[0].version
41
- except Exception:
42
+ __version__ = version("tconnectsync")
43
+ except PackageNotFoundError:
42
44
  __version__ = "UNKNOWN"
43
45
 
44
46
  def parse_args(*args, **kwargs):
@@ -126,4 +128,3 @@ def main(*args, **kwargs):
126
128
 
127
129
  # return exit code 0 if processed events
128
130
  sys.exit(0 if added>0 else 1)
129
-
@@ -0,0 +1,26 @@
1
+ import logging
2
+
3
+ from .tandemsource import TandemSourceApi
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+ """A wrapper for the Tandem Source API."""
8
+ class TConnectApi:
9
+ email = None
10
+ password = None
11
+
12
+ def __init__(self, email, password, region='US'):
13
+ self.email = email
14
+ self.password = password
15
+ self.region = region
16
+ self._tandemsource = None
17
+
18
+ @property
19
+ def tandemsource(self):
20
+ if self._tandemsource and not self._tandemsource.needs_relogin():
21
+ return self._tandemsource
22
+
23
+ logger.debug(f"Instantiating new TandemSourceApi for region {self.region}")
24
+
25
+ self._tandemsource = TandemSourceApi(self.email, self.password, self.region)
26
+ return self._tandemsource