tconnectsync 2.0.2__tar.gz → 2.0.4__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 (75) hide show
  1. {tconnectsync-2.0.2/tconnectsync.egg-info → tconnectsync-2.0.4}/PKG-INFO +1 -1
  2. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/setup.cfg +1 -1
  3. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/__init__.py +7 -2
  4. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/eventparser/raw_event.py +8 -2
  5. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/autoupdate.py +9 -4
  6. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process.py +6 -2
  7. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_alarm.py +2 -2
  8. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_basal.py +6 -2
  9. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_basal_resume.py +2 -2
  10. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_basal_suspension.py +2 -2
  11. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_bolus.py +1 -1
  12. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_cartridge.py +2 -2
  13. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_cgm_alert.py +2 -2
  14. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_cgm_reading.py +2 -2
  15. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_cgm_start_join_stop.py +2 -2
  16. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/process_user_mode.py +2 -2
  17. {tconnectsync-2.0.2 → tconnectsync-2.0.4/tconnectsync.egg-info}/PKG-INFO +1 -1
  18. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/LICENSE.md +0 -0
  19. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/README.md +0 -0
  20. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/pyproject.toml +0 -0
  21. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/setup.py +0 -0
  22. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/api/__init__.py +0 -0
  23. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/api/android.py +0 -0
  24. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/api/common.py +0 -0
  25. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/api/controliq.py +0 -0
  26. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/api/tandemsource.py +0 -0
  27. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/api/webui.py +0 -0
  28. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/api/ws2.py +0 -0
  29. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/autoupdate.py +0 -0
  30. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/check.py +0 -0
  31. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/domain/__init__.py +0 -0
  32. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/domain/bolus.py +0 -0
  33. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/domain/device_settings.py +0 -0
  34. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/domain/tandemsource/__init__.py +0 -0
  35. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/domain/tandemsource/event_class.py +0 -0
  36. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/domain/tandemsource/pump_settings.py +0 -0
  37. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/domain/therapy_event.py +0 -0
  38. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/domain/utility.py +0 -0
  39. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/eventparser/__init__.py +0 -0
  40. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/eventparser/build_events.py +0 -0
  41. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/eventparser/events.py +0 -0
  42. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/eventparser/generic.py +0 -0
  43. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/eventparser/static_dicts.py +0 -0
  44. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/eventparser/transforms.py +0 -0
  45. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/eventparser/utils.py +0 -0
  46. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/features.py +0 -0
  47. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/nightscout.py +0 -0
  48. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/parser/__init__.py +0 -0
  49. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/parser/ciq_therapy_events.py +0 -0
  50. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/parser/nightscout.py +0 -0
  51. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/parser/tconnect.py +0 -0
  52. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/process.py +0 -0
  53. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/secret.py +0 -0
  54. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/__init__.py +0 -0
  55. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/basal.py +0 -0
  56. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/bolus.py +0 -0
  57. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/cgm.py +0 -0
  58. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/iob.py +0 -0
  59. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/profile.py +0 -0
  60. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/pump_events.py +0 -0
  61. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/__init__.py +0 -0
  62. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/choose_device.py +0 -0
  63. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/helpers.py +0 -0
  64. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/sync/tandemsource/update_profiles.py +0 -0
  65. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/util/__init__.py +0 -0
  66. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/util/cli.py +0 -0
  67. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync/util/constants.py +0 -0
  68. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync.egg-info/SOURCES.txt +0 -0
  69. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync.egg-info/dependency_links.txt +0 -0
  70. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync.egg-info/entry_points.txt +0 -0
  71. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync.egg-info/requires.txt +0 -0
  72. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tconnectsync.egg-info/top_level.txt +0 -0
  73. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tests/test_autoupdate.py +0 -0
  74. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tests/test_process.py +0 -0
  75. {tconnectsync-2.0.2 → tconnectsync-2.0.4}/tests/test_secret.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tconnectsync
3
- Version: 2.0.2
3
+ Version: 2.0.4
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
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = tconnectsync
3
- version = 2.0.2
3
+ version = 2.0.4
4
4
  author = James Woglom
5
5
  author_email = j@wogloms.net
6
6
  description = Syncs Tandem t:connect pump data to Nightscout for the t:slim X2
@@ -111,9 +111,14 @@ def main(*args, **kwargs):
111
111
 
112
112
  if args.auto_update:
113
113
  u = TandemSourceAutoupdate(secret)
114
- sys.exit(u.process(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features))
114
+ changed, last_event_id = u.process(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features)
115
+
116
+ # return exit code 0 if processed events
117
+ sys.exit(0 if changed>0 else 1)
115
118
  else:
116
119
  tconnectDevice = TandemSourceChooseDevice(secret, tconnect).choose()
117
120
  added = TandemSourceProcessTimeRange(tconnect, nightscout, tconnectDevice, pretend=args.pretend, features=args.features).process(time_start, time_end)
118
- sys.exit(added)
121
+
122
+ # return exit code 0 if processed events
123
+ sys.exit(0 if added>0 else 1)
119
124
 
@@ -1,6 +1,8 @@
1
1
  import struct
2
2
  import arrow
3
3
 
4
+ from ..secret import TIMEZONE_NAME
5
+
4
6
  from dataclasses import dataclass
5
7
 
6
8
  EVENT_LEN = 26
@@ -29,7 +31,11 @@ class RawEvent:
29
31
  seqNum = seqNum,
30
32
  raw = raw
31
33
  )
32
-
34
+
33
35
  @property
34
36
  def timestamp(self):
35
- return arrow.get(TANDEM_EPOCH + self.timestampRaw)
37
+ # Event timestamps do not have TZ data attached to them when parsed,
38
+ # but represent the user's time zone setting. So we keep the time
39
+ # referenced on them, but force the timezone to what the user
40
+ # requests via the TZ secret.
41
+ return arrow.get(TANDEM_EPOCH + self.timestampRaw, tzinfo=TIMEZONE_NAME)
@@ -18,6 +18,7 @@ class TandemSourceAutoupdate:
18
18
  self.last_max_date_with_events = None
19
19
  self.last_event_time = 0
20
20
  self.last_attempt_time = 0
21
+ self.last_event_index = None
21
22
  self.time_diffs_between_attempts = []
22
23
  self.time_diffs_between_updates = []
23
24
 
@@ -41,15 +42,17 @@ class TandemSourceAutoupdate:
41
42
 
42
43
  tconnectDevice = ChooseDevice(self.secret, tconnect).choose()
43
44
 
44
- cur_max_date_with_events = arrow.get(tconnectDevice['maxDateWithEvents'])
45
- if not self.last_max_date_with_events or cur_max_date_with_events > self.cur_max_date_with_events:
45
+ event_id = None
46
+ cur_max_date_with_events = arrow.get(tconnectDevice['maxDateWithEvents']).float_timestamp
47
+ if not self.last_max_date_with_events or cur_max_date_with_events > self.last_max_date_with_events:
46
48
  logger.info('New reported tandemsource data. (cur_max_date: %s last_max_date: %s)' % (cur_max_date_with_events, self.last_max_date_with_events))
47
49
 
48
50
  if pretend:
49
51
  logger.info('Would update now if not in pretend mode')
50
52
  else:
51
- added = ProcessTimeRange(tconnect, nightscout, tconnectDevice, pretend, features=features).process(time_start, time_end)
53
+ added, event_id = ProcessTimeRange(tconnect, nightscout, tconnectDevice, pretend, features=features).process(time_start, time_end)
52
54
  logger.info('Added %d items from ProcessTimeRange' % added)
55
+ self.last_successful_process_time_range = now
53
56
 
54
57
  # Track the time it took to find a new event between runs,
55
58
  # but skip this calculation the first process cycle (since
@@ -59,8 +62,10 @@ class TandemSourceAutoupdate:
59
62
  logger.debug('Updating tracking of time since last update: %s' % self.time_diffs_between_updates)
60
63
 
61
64
  # Mark the last event index uploaded from the pump and timestamp
65
+ if event_id:
66
+ self.last_event_index = event_id
67
+ self.last_event_time = now
62
68
  self.last_max_date_with_events = cur_max_date_with_events
63
- self.last_event_time = now
64
69
  self.last_attempt_time = now
65
70
  self.time_diffs_between_attempts = []
66
71
  else:
@@ -55,14 +55,18 @@ class ProcessTimeRange:
55
55
 
56
56
  events_first_time = None
57
57
  events_last_time = None
58
+ last_event_id = None # aka seqnum
58
59
  for_eventclass = collections.defaultdict(list)
59
60
  for event in events:
60
61
  if not events_first_time:
61
62
  events_first_time = event.eventTimestamp
62
63
  if not events_last_time:
63
64
  events_last_time = event.eventTimestamp
65
+ if not last_event_id:
66
+ last_event_id = event.eventId
64
67
  events_first_time = min(events_first_time, event.eventTimestamp)
65
68
  events_last_time = max(events_last_time, event.eventTimestamp)
69
+ last_event_id = max(event.eventId, last_event_id)
66
70
 
67
71
  clazz = EventClass.for_event(event)
68
72
  if clazz:
@@ -91,6 +95,6 @@ class ProcessTimeRange:
91
95
  else:
92
96
  logger.info("Skipping %s, is not enabled from features %s" % (updater_class.__name__, self.features))
93
97
 
94
- logger.info("Processed %d events" % processed_count)
95
- return processed_count
98
+ logger.info("Processed %d events. Last event ID seen: %d" % (processed_count, last_event_id))
99
+ return processed_count, last_event_id
96
100
 
@@ -35,9 +35,9 @@ class ProcessAlarm:
35
35
 
36
36
  ns_entries = []
37
37
  for event in sorted(events, key=lambda x: x.eventTimestamp):
38
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
38
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
39
39
  if self.pretend:
40
- logger.info("Skipping Alarm event before last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
40
+ logger.info("Skipping Alarm event not after last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
41
41
  continue
42
42
 
43
43
  ns_entries.append(self.alarm_to_nsentry(event))
@@ -36,13 +36,17 @@ class ProcessBasal:
36
36
 
37
37
  with_duration = []
38
38
  for event in sorted(events, key=lambda x: x.eventTimestamp):
39
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
39
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
40
40
  if self.pretend:
41
- logger.info("Skipping basal event before last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
41
+ logger.info("Skipping basal event not after last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
42
42
  continue
43
43
 
44
44
  with_duration.append([event.eventTimestamp, None, event])
45
45
 
46
+ if not with_duration:
47
+ logger.info("No basal events found to process")
48
+ return []
49
+
46
50
  for i in range(len(with_duration)-1):
47
51
  with_duration[i][1] = with_duration[i+1][0] - with_duration[i][0]
48
52
 
@@ -35,9 +35,9 @@ class ProcessBasalResume:
35
35
 
36
36
  ns_entries = []
37
37
  for event in sorted(events, key=lambda x: x.eventTimestamp):
38
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
38
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
39
39
  if self.pretend:
40
- logger.info("Skipping BasalResume event before last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
40
+ logger.info("Skipping BasalResume event not after last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
41
41
  continue
42
42
 
43
43
  ns_entries.append(self.resume_to_nsentry(event))
@@ -35,9 +35,9 @@ class ProcessBasalSuspension:
35
35
 
36
36
  ns_entries = []
37
37
  for event in sorted(events, key=lambda x: x.eventTimestamp):
38
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
38
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
39
39
  if self.pretend:
40
- logger.info("Skipping basalsuspension event before last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
40
+ logger.info("Skipping basalsuspension event not after last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
41
41
  continue
42
42
 
43
43
  ns_entries.append(self.suspension_to_nsentry(event))
@@ -44,7 +44,7 @@ class ProcessBolus:
44
44
  bolusEventsForId[event.bolusid][type(event)] = event
45
45
 
46
46
  if type(event) == eventtypes.LidBolusCompleted:
47
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
47
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
48
48
  if self.pretend:
49
49
  logger.info("Skipping bolusCompletedEvent before last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
50
50
  continue
@@ -37,9 +37,9 @@ class ProcessCartridge:
37
37
  cannulaFilledEvents = []
38
38
  tubingFilledEvents = []
39
39
  for event in sorted(events, key=lambda x: x.eventTimestamp):
40
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
40
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
41
41
  if self.pretend:
42
- logger.info("Skipping %s before last upload time: %s (time range: %s - %s)" % (type(event), event, time_start, time_end))
42
+ logger.info("Skipping %s not after last upload time: %s (time range: %s - %s)" % (type(event), event, time_start, time_end))
43
43
  continue
44
44
 
45
45
  if type(event) == eventtypes.LidCartridgeFilled:
@@ -35,9 +35,9 @@ class ProcessCGMAlert:
35
35
 
36
36
  alertEvents = []
37
37
  for event in sorted(events, key=lambda x: x.eventTimestamp):
38
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
38
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
39
39
  if self.pretend:
40
- logger.info("Skipping %s before last upload time: %s (time range: %s - %s)" % (type(event), event, time_start, time_end))
40
+ logger.info("Skipping %s not after last upload time: %s (time range: %s - %s)" % (type(event), event, time_start, time_end))
41
41
  continue
42
42
 
43
43
  alertEvents.append(event)
@@ -38,9 +38,9 @@ class ProcessCGMReading:
38
38
 
39
39
  readings = []
40
40
  for event in sorted(events, key=lambda x: self.timestamp_for(x)):
41
- if last_upload_time and self.timestamp_for(event) < last_upload_time:
41
+ if last_upload_time and self.timestamp_for(event) <= last_upload_time:
42
42
  if self.pretend:
43
- logger.info("ProcessCGMReading: Skipping %s before last upload time: %s (time range: %s - %s)" % (type(event), event, time_start, time_end))
43
+ logger.info("ProcessCGMReading: Skipping %s not after last upload time: %s (time range: %s - %s)" % (type(event), event, time_start, time_end))
44
44
  continue
45
45
 
46
46
  readings.append(event)
@@ -48,9 +48,9 @@ class ProcessCGMStartJoinStop:
48
48
 
49
49
  allEvents = []
50
50
  for event in sorted(events, key=lambda x: x.eventTimestamp):
51
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
51
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
52
52
  if self.pretend:
53
- logger.info("ProcessCGMStartJoinStop: Skipping %s before last upload time: %s (time range: %s - %s)" % (type(event), event, time_start, time_end))
53
+ logger.info("ProcessCGMStartJoinStop: Skipping %s not after last upload time: %s (time range: %s - %s)" % (type(event), event, time_start, time_end))
54
54
  continue
55
55
 
56
56
  allEvents.append(event)
@@ -72,9 +72,9 @@ class ProcessUserMode:
72
72
  start_sleep = None
73
73
  start_exercise = None
74
74
  for event in sorted(events, key=lambda x: x.eventTimestamp):
75
- if last_upload_time and arrow.get(event.eventTimestamp) < last_upload_time:
75
+ if last_upload_time and arrow.get(event.eventTimestamp) <= last_upload_time:
76
76
  if self.pretend:
77
- logger.info("ProcessUserMode: Skipping usermode event before last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
77
+ logger.info("ProcessUserMode: Skipping usermode event not after last upload time: %s (time range: %s - %s)" % (event, time_start, time_end))
78
78
  continue
79
79
 
80
80
  if self.is_start_sleep(event):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tconnectsync
3
- Version: 2.0.2
3
+ Version: 2.0.4
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
File without changes
File without changes
File without changes