tconnectsync 2.1.6__tar.gz → 2.2.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.
- {tconnectsync-2.1.6/tconnectsync.egg-info → tconnectsync-2.2.0}/PKG-INFO +1 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/setup.cfg +1 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/__init__.py +1 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/api/tandemsource.py +27 -6
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/domain/tandemsource/event_class.py +1 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/eventparser/build_events.py +20 -14
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/eventparser/events.py +420 -64
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/eventparser/generic.py +7 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/eventparser/raw_event.py +25 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/eventparser/transforms.py +12 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/features.py +2 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/nightscout.py +39 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/parser/nightscout.py +16 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/secret.py +3 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/autoupdate.py +13 -8
- tconnectsync-2.2.0/tconnectsync/sync/tandemsource/cli_helpers.py +20 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/heroku_helpers.py +1 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process.py +11 -13
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_alarm.py +11 -2
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_basal.py +2 -2
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_basal_resume.py +1 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_basal_suspension.py +1 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_bolus.py +4 -4
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_cartridge.py +3 -3
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_cgm_alert.py +3 -3
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_cgm_reading.py +1 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_cgm_start_join_stop.py +3 -3
- tconnectsync-2.2.0/tconnectsync/sync/tandemsource/process_device_status.py +77 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/process_user_mode.py +6 -6
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/update_profiles.py +4 -4
- {tconnectsync-2.1.6 → tconnectsync-2.2.0/tconnectsync.egg-info}/PKG-INFO +1 -1
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync.egg-info/SOURCES.txt +4 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/LICENSE.md +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/README.md +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/pyproject.toml +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/setup.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/api/__init__.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/api/android.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/api/common.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/api/controliq.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/api/webui.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/api/ws2.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/autoupdate.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/check.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/domain/__init__.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/domain/bolus.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/domain/device_settings.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/domain/tandemsource/__init__.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/domain/tandemsource/pump_settings.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/domain/therapy_event.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/domain/utility.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/eventparser/__init__.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/eventparser/static_dicts.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/eventparser/utils.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/parser/__init__.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/parser/ciq_therapy_events.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/parser/tconnect.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/process.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/__init__.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/basal.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/bolus.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/cgm.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/iob.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/profile.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/pump_events.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/__init__.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/choose_device.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/sync/tandemsource/helpers.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/util/__init__.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/util/cli.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync/util/constants.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync.egg-info/dependency_links.txt +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync.egg-info/entry_points.txt +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync.egg-info/requires.txt +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tconnectsync.egg-info/top_level.txt +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tests/test_autoupdate.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tests/test_process.py +0 -0
- {tconnectsync-2.1.6 → tconnectsync-2.2.0}/tests/test_secret.py +0 -0
|
@@ -120,7 +120,7 @@ def main(*args, **kwargs):
|
|
|
120
120
|
sys.exit(u.process(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features))
|
|
121
121
|
else:
|
|
122
122
|
tconnectDevice = TandemSourceChooseDevice(secret, tconnect).choose()
|
|
123
|
-
added, last_event_id = TandemSourceProcessTimeRange(tconnect, nightscout, tconnectDevice, pretend=args.pretend, features=args.features).process(time_start, time_end)
|
|
123
|
+
added, last_event_id = TandemSourceProcessTimeRange(tconnect, nightscout, tconnectDevice, pretend=args.pretend, secret=secret, features=args.features).process(time_start, time_end)
|
|
124
124
|
|
|
125
125
|
# return exit code 0 if processed events
|
|
126
126
|
sys.exit(0 if added>0 else 1)
|
|
@@ -19,6 +19,7 @@ from jwt.algorithms import RSAAlgorithm
|
|
|
19
19
|
from ..util import timeago, cap_length
|
|
20
20
|
from .common import parse_ymd_date, base_headers, base_session, ApiException, ApiLoginException
|
|
21
21
|
from ..secret import CACHE_CREDENTIALS, CACHE_CREDENTIALS_PATH
|
|
22
|
+
from ..eventparser.generic import Events, decode_raw_events, EVENT_LEN
|
|
22
23
|
|
|
23
24
|
logger = logging.getLogger(__name__)
|
|
24
25
|
|
|
@@ -357,22 +358,42 @@ class TandemSourceApi:
|
|
|
357
358
|
def pump_event_metadata(self):
|
|
358
359
|
return self.get('api/reports/reportsfacade/%s/pumpeventmetadata' % (self.pumperId), {})
|
|
359
360
|
|
|
361
|
+
DEFAULT_EVENT_IDS = [229,5,28,4,26,99,279,3,16,59,21,55,20,280,64,65,66,61,33,371,171,369,460,172,370,461,372,399,256,213,406,394,212,404,214,405,447,313,60,14,6,90,230,140,12,11,53,13,63,203,307,191]
|
|
362
|
+
|
|
360
363
|
"""
|
|
361
364
|
Returns raw unparsed string for pump events
|
|
362
365
|
tconnect_device_id is "tconnectDeviceId" from pump_event_metadata()
|
|
363
366
|
"""
|
|
364
|
-
def pump_events_raw(self, tconnect_device_id, min_date=None, max_date=None):
|
|
367
|
+
def pump_events_raw(self, tconnect_device_id, min_date=None, max_date=None, event_ids_filter=DEFAULT_EVENT_IDS):
|
|
365
368
|
minDate = parse_ymd_date(min_date)
|
|
366
369
|
maxDate = parse_ymd_date(max_date)
|
|
367
|
-
logger.debug(f'pump_events_raw({minDate}, {maxDate})')
|
|
370
|
+
logger.debug(f'pump_events_raw({tconnect_device_id}, {minDate}, {maxDate})')
|
|
368
371
|
|
|
369
|
-
# 229,5,28,4,26,99,279,3,16,59,21,55,20,280,64,65,66,61,33,371,171,369,460,172,370,461,372,399,256,213,406,394,212,404,214,405,447,313,60,14,6,90,230,140,12,11,53,13,63,203,307,191
|
|
370
|
-
eventIdsFilter = '
|
|
371
|
-
return self.get('api/reports/reportsfacade/pumpevents/%s/%s?minDate=%s&maxDate=%s
|
|
372
|
+
# default: 229,5,28,4,26,99,279,3,16,59,21,55,20,280,64,65,66,61,33,371,171,369,460,172,370,461,372,399,256,213,406,394,212,404,214,405,447,313,60,14,6,90,230,140,12,11,53,13,63,203,307,191
|
|
373
|
+
eventIdsFilter = '%2C'.join(map(str, event_ids_filter)) if event_ids_filter else None
|
|
374
|
+
return self.get('api/reports/reportsfacade/pumpevents/%s/%s?minDate=%s&maxDate=%s%s' % (
|
|
372
375
|
self.pumperId,
|
|
373
376
|
tconnect_device_id,
|
|
374
377
|
minDate,
|
|
375
378
|
maxDate,
|
|
376
|
-
eventIdsFilter
|
|
379
|
+
'&eventIds=%s' % eventIdsFilter if eventIdsFilter else ''
|
|
377
380
|
), {})
|
|
378
381
|
|
|
382
|
+
"""
|
|
383
|
+
Fetch and decode pump events using eventparser.
|
|
384
|
+
Default of fetch_all_events=False will filter to the same eventids used in the Tandem Source backend.
|
|
385
|
+
If fetch_all_events=True, then all event types from the history log will be returned.
|
|
386
|
+
"""
|
|
387
|
+
def pump_events(self, tconnect_device_id, min_date=None, max_date=None, fetch_all_event_types=False):
|
|
388
|
+
pump_events_raw = self.pump_events_raw(
|
|
389
|
+
tconnect_device_id,
|
|
390
|
+
min_date,
|
|
391
|
+
max_date,
|
|
392
|
+
event_ids_filter=None if fetch_all_event_types else self.DEFAULT_EVENT_IDS
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
pump_events_decoded = decode_raw_events(pump_events_raw)
|
|
396
|
+
logger.info(f"Read {len(pump_events_decoded)} bytes (est. {len(pump_events_decoded)/EVENT_LEN} events)")
|
|
397
|
+
return Events(pump_events_decoded)
|
|
398
|
+
|
|
399
|
+
|
|
@@ -24,6 +24,7 @@ class EventClass(set, Enum):
|
|
|
24
24
|
CGM_START_JOIN_STOP = {*_CGM_START, *_CGM_JOIN, *_CGM_STOP}
|
|
25
25
|
CGM_READING = {events.LidCgmDataGxb, events.LidCgmDataG7, events.LidCgmDataFsl2}
|
|
26
26
|
USER_MODE = {events.LidAaUserModeChange}
|
|
27
|
+
DEVICE_STATUS = {events.LidDailyBasal}
|
|
27
28
|
|
|
28
29
|
@staticmethod
|
|
29
30
|
def for_event(evt):
|
|
@@ -3,18 +3,12 @@ import struct
|
|
|
3
3
|
import logging
|
|
4
4
|
from dataclasses import dataclass
|
|
5
5
|
from enum import Enum, IntFlag
|
|
6
|
-
from .raw_event import RawEvent
|
|
6
|
+
from .raw_event import RawEvent, BaseEvent
|
|
7
7
|
|
|
8
8
|
logger = logging.getLogger(__name__)
|
|
9
9
|
|
|
10
10
|
EVENT_LEN = 26
|
|
11
11
|
|
|
12
|
-
@dataclass
|
|
13
|
-
class BaseEvent:
|
|
14
|
-
@staticmethod
|
|
15
|
-
def build(raw):
|
|
16
|
-
raise NotImplemented
|
|
17
|
-
|
|
18
12
|
'''
|
|
19
13
|
|
|
20
14
|
TYPE_TO_STRUCT = {
|
|
@@ -67,9 +61,13 @@ class {name}(BaseEvent):
|
|
|
67
61
|
return self.raw.timestamp
|
|
68
62
|
|
|
69
63
|
@property
|
|
70
|
-
def
|
|
64
|
+
def seqNum(self):
|
|
71
65
|
return self.raw.seqNum
|
|
72
66
|
|
|
67
|
+
@property
|
|
68
|
+
def eventId(self):
|
|
69
|
+
return self.ID
|
|
70
|
+
|
|
73
71
|
'''
|
|
74
72
|
|
|
75
73
|
def firstLower(text):
|
|
@@ -85,13 +83,13 @@ def eventNameFormat(text):
|
|
|
85
83
|
def fieldNameFormat(text):
|
|
86
84
|
if not text or all([i.isupper() for i in text]):
|
|
87
85
|
return text
|
|
88
|
-
return firstLower(text.replace('_', ' ').title().replace(' ', ''))
|
|
86
|
+
return firstLower(text.replace('_', ' ').title().replace(' ', '')).replace('raw', 'Raw')
|
|
89
87
|
|
|
90
88
|
|
|
91
89
|
def build_fields(event_def):
|
|
92
90
|
ret = []
|
|
93
91
|
for name, field in event_def["data"].items():
|
|
94
|
-
suffix = 'Raw' if "transform" in field else ''
|
|
92
|
+
suffix = 'Raw' if "transform" in field and name[-3:] != 'Raw' else ''
|
|
95
93
|
f = f'{fieldNameFormat(name)}{suffix}: {TYPE_TO_PYOBJ[field["type"]]}'
|
|
96
94
|
if "uom" in field:
|
|
97
95
|
f += ' # ' + field['uom']
|
|
@@ -107,7 +105,7 @@ def build_decode(event_def):
|
|
|
107
105
|
p1 = f'{fieldNameFormat(name)}, = {unpack_command_for(field)}'
|
|
108
106
|
p1s.append(p1)
|
|
109
107
|
|
|
110
|
-
suffix = 'Raw' if "transform" in field else ''
|
|
108
|
+
suffix = 'Raw' if "transform" in field and name[-3:] != 'Raw' else ''
|
|
111
109
|
|
|
112
110
|
p2 = f'{fieldNameFormat(name)}{suffix} = {fieldNameFormat(name)},'
|
|
113
111
|
p2s.append(p2)
|
|
@@ -160,13 +158,21 @@ def build_events_map(events):
|
|
|
160
158
|
|
|
161
159
|
if __name__ == '__main__':
|
|
162
160
|
import json
|
|
161
|
+
merged_events = {}
|
|
163
162
|
|
|
164
163
|
output = f'{header}'
|
|
165
164
|
with open("events.json", "r") as f:
|
|
166
165
|
j = json.loads(f.read())
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
merged_events.update(j["events"])
|
|
167
|
+
|
|
168
|
+
with open("custom_events.json", "r") as f:
|
|
169
|
+
j = json.loads(f.read())
|
|
170
|
+
merged_events.update(j["events"])
|
|
171
|
+
|
|
172
|
+
for event_id, event_def in merged_events.items():
|
|
173
|
+
output += build_event(event_id, event_def)
|
|
174
|
+
|
|
175
|
+
output += build_events_map(merged_events)
|
|
169
176
|
|
|
170
|
-
output += build_events_map(j["events"])
|
|
171
177
|
|
|
172
178
|
print(output)
|