tconnectsync 2.1.9__tar.gz → 2.2.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.
Files changed (78) hide show
  1. {tconnectsync-2.1.9/tconnectsync.egg-info → tconnectsync-2.2.2}/PKG-INFO +1 -1
  2. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/setup.cfg +1 -1
  3. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/__init__.py +1 -1
  4. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/eventparser/events.py +1 -1
  5. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/eventparser/transforms.py +1 -1
  6. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/nightscout.py +12 -0
  7. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/parser/nightscout.py +4 -2
  8. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/autoupdate.py +7 -2
  9. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_device_status.py +1 -1
  10. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/update_profiles.py +4 -4
  11. {tconnectsync-2.1.9 → tconnectsync-2.2.2/tconnectsync.egg-info}/PKG-INFO +1 -1
  12. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/LICENSE.md +0 -0
  13. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/README.md +0 -0
  14. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/pyproject.toml +0 -0
  15. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/setup.py +0 -0
  16. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/api/__init__.py +0 -0
  17. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/api/android.py +0 -0
  18. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/api/common.py +0 -0
  19. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/api/controliq.py +0 -0
  20. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/api/tandemsource.py +0 -0
  21. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/api/webui.py +0 -0
  22. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/api/ws2.py +0 -0
  23. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/autoupdate.py +0 -0
  24. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/check.py +0 -0
  25. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/domain/__init__.py +0 -0
  26. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/domain/bolus.py +0 -0
  27. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/domain/device_settings.py +0 -0
  28. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/domain/tandemsource/__init__.py +0 -0
  29. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/domain/tandemsource/event_class.py +0 -0
  30. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/domain/tandemsource/pump_settings.py +0 -0
  31. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/domain/therapy_event.py +0 -0
  32. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/domain/utility.py +0 -0
  33. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/eventparser/__init__.py +0 -0
  34. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/eventparser/build_events.py +0 -0
  35. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/eventparser/generic.py +0 -0
  36. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/eventparser/raw_event.py +0 -0
  37. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/eventparser/static_dicts.py +0 -0
  38. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/eventparser/utils.py +0 -0
  39. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/features.py +0 -0
  40. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/parser/__init__.py +0 -0
  41. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/parser/ciq_therapy_events.py +0 -0
  42. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/parser/tconnect.py +0 -0
  43. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/process.py +0 -0
  44. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/secret.py +0 -0
  45. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/__init__.py +0 -0
  46. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/basal.py +0 -0
  47. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/bolus.py +0 -0
  48. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/cgm.py +0 -0
  49. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/iob.py +0 -0
  50. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/profile.py +0 -0
  51. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/pump_events.py +0 -0
  52. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/__init__.py +0 -0
  53. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/choose_device.py +0 -0
  54. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/cli_helpers.py +0 -0
  55. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/helpers.py +0 -0
  56. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/heroku_helpers.py +0 -0
  57. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process.py +0 -0
  58. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_alarm.py +0 -0
  59. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_basal.py +0 -0
  60. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_basal_resume.py +0 -0
  61. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_basal_suspension.py +0 -0
  62. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_bolus.py +0 -0
  63. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_cartridge.py +0 -0
  64. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_cgm_alert.py +0 -0
  65. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_cgm_reading.py +0 -0
  66. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_cgm_start_join_stop.py +0 -0
  67. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/sync/tandemsource/process_user_mode.py +0 -0
  68. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/util/__init__.py +0 -0
  69. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/util/cli.py +0 -0
  70. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync/util/constants.py +0 -0
  71. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync.egg-info/SOURCES.txt +0 -0
  72. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync.egg-info/dependency_links.txt +0 -0
  73. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync.egg-info/entry_points.txt +0 -0
  74. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync.egg-info/requires.txt +0 -0
  75. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tconnectsync.egg-info/top_level.txt +0 -0
  76. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tests/test_autoupdate.py +0 -0
  77. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tests/test_process.py +0 -0
  78. {tconnectsync-2.1.9 → tconnectsync-2.2.2}/tests/test_secret.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tconnectsync
3
- Version: 2.1.9
3
+ Version: 2.2.2
4
4
  Summary: Syncs Tandem Source (formerly t:connect) insulin 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.1.9
3
+ version = 2.2.2
4
4
  author = James Woglom
5
5
  author_email = j@wogloms.net
6
6
  description = Syncs Tandem Source (formerly t:connect) insulin pump data to Nightscout for the t:slim X2
@@ -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)
@@ -4495,7 +4495,7 @@ class LidDailyBasal(BaseEvent):
4495
4495
 
4496
4496
  @property
4497
4497
  def batteryChargePercent(self):
4498
- return (256*(self.batterychargepercentmsbRaw%2)+self.batterychargepercentlsbRaw)/512
4498
+ return (256*(self.batterychargepercentmsbRaw-14)+self.batterychargepercentlsbRaw)/(3*256)
4499
4499
 
4500
4500
  @staticmethod
4501
4501
  def build(raw):
@@ -116,7 +116,7 @@ def transform_battery_charge_percent(event_def, name, name_fmt, field, tx):
116
116
  out += [
117
117
  '@property',
118
118
  f'def batteryChargePercent(self):',
119
- f' return (256*(self.batterychargepercentmsbRaw%2)+self.batterychargepercentlsbRaw)/512',
119
+ f' return (256*(self.batterychargepercentmsbRaw-14)+self.batterychargepercentlsbRaw)/(3*256)',
120
120
  ''
121
121
  ]
122
122
 
@@ -71,6 +71,9 @@ class NightscoutApi:
71
71
  'api-secret': hashlib.sha1(self.secret.encode()).hexdigest()
72
72
  }, verify=self.verify)
73
73
  if latest.status_code != 200:
74
+ if 'as a valid ISO-8601 date' in latest.text:
75
+ logger.warning("Nightscout last_uploaded_entry %s could not process ISO-8601 date: start=%s end=%s dateFilter=%s" % (eventType, time_start, time_end, dateFilter))
76
+ return None
74
77
  raise ApiException(latest.status_code, "Nightscout last_uploaded_entry %s response: %s" % (latest.status_code, latest.text))
75
78
 
76
79
  j = latest.json()
@@ -106,6 +109,9 @@ class NightscoutApi:
106
109
  'api-secret': hashlib.sha1(self.secret.encode()).hexdigest()
107
110
  }, verify=self.verify)
108
111
  if latest.status_code != 200:
112
+ if 'as a valid ISO-8601 date' in latest.text:
113
+ logger.warning("Nightscout last_uploaded_bg_entry could not process ISO-8601 date: start=%s end=%s dateFilter=%s" % (time_start, time_end, dateFilter))
114
+ return None
109
115
  raise ApiException(latest.status_code, "Nightscout last_uploaded_bg_entry %s response: %s" % (latest.status_code, latest.text))
110
116
 
111
117
  j = latest.json()
@@ -134,6 +140,9 @@ class NightscoutApi:
134
140
  'api-secret': hashlib.sha1(self.secret.encode()).hexdigest()
135
141
  }, verify=self.verify)
136
142
  if latest.status_code != 200:
143
+ if 'as a valid ISO-8601 date' in latest.text:
144
+ logger.warning("Nightscout activity %s could not process ISO-8601 date: start=%s end=%s dateFilter=%s" % (activityType, time_start, time_end, dateFilter))
145
+ return None
137
146
  raise ApiException(latest.status_code, "Nightscout activity %s response: %s" % (latest.status_code, latest.text))
138
147
 
139
148
  j = latest.json()
@@ -161,6 +170,9 @@ class NightscoutApi:
161
170
  'api-secret': hashlib.sha1(self.secret.encode()).hexdigest()
162
171
  }, verify=self.verify)
163
172
  if latest.status_code != 200:
173
+ if 'as a valid ISO-8601 date' in latest.text:
174
+ logger.warning("Nightscout devicestatus could not process ISO-8601 date: start=%s end=%s dateFilter=%s" % (time_start, time_end, dateFilter))
175
+ return None
164
176
  raise ApiException(latest.status_code, "Nightscout devicestatus %s response: %s" % (latest.status_code, latest.text))
165
177
 
166
178
  j = latest.json()
@@ -195,14 +195,16 @@ class NightscoutEntry:
195
195
  }
196
196
 
197
197
  @staticmethod
198
- def devicestatus(created_at, batteryVoltage, batteryString, pump_event_id=""):
198
+ def devicestatus(created_at, batteryVoltage, batteryPercent, pump_event_id=""):
199
199
  return {
200
200
  "device": ENTERED_BY,
201
201
  "created_at": created_at,
202
202
  "pump": {
203
+ "clock": created_at,
203
204
  "battery": {
204
205
  "voltage": float(batteryVoltage),
205
- "string": batteryString
206
+ "percent": int(batteryPercent) if batteryPercent else None,
207
+ "status": "%.0f%s" % (batteryPercent, '%')
206
208
  },
207
209
  },
208
210
  "pump_event_id": pump_event_id
@@ -69,7 +69,12 @@ class TandemSourceAutoupdate:
69
69
  self.last_attempt_time = now
70
70
  self.time_diffs_between_attempts = []
71
71
  else:
72
- logger.info('No new reported tandemsource data. (cur_max_date: %s)' % cur_max_date_with_events)
72
+ logger.info('No new reported tandemsource data. cur_max_date: %s (%dm ago) last_event_time: %s (%dm ago)' % (
73
+ arrow.get(cur_max_date_with_events) if cur_max_date_with_events else None,
74
+ (now - cur_max_date_with_events)//60 if cur_max_date_with_events else None,
75
+ arrow.get(self.last_event_time) if self.last_event_time else None,
76
+ (now - self.last_event_time)//60 if self.last_event_time else None
77
+ ))
73
78
 
74
79
  # If we haven't seen the pump event index update in AUTOUPDATE_NO_DATA_FAILURE_MINUTES,
75
80
  # then trigger an error and potentially restart.
@@ -93,7 +98,7 @@ class TandemSourceAutoupdate:
93
98
  # above no indexes warning.
94
99
  elif self.last_successful_process_time_range and (now - self.last_successful_process_time_range) >= 60 * self.secret.AUTOUPDATE_FAILURE_MINUTES:
95
100
  logger.error(AutoupdateNoNewDataDetectedError(
96
- "%s: No new data has been detected via the API for %d minutes. " % (datetime.datetime.now(), (now - self.last_successful_process_time_range)//60) +
101
+ "%s: No new data has been detected via the API for %d minutes (last: %s). " % (datetime.datetime.now(), (now - self.last_successful_process_time_range)//60, self.last_successful_process_time_range) +
97
102
  "tconnectsync might not be functioning properly."))
98
103
 
99
104
  if self.secret.AUTOUPDATE_RESTART_ON_FAILURE:
@@ -59,7 +59,7 @@ class ProcessDeviceStatus:
59
59
  return NightscoutEntry.devicestatus(
60
60
  created_at=event.eventTimestamp.format(),
61
61
  batteryVoltage=(float(event.batterylipomillivolts or 0)/1000),
62
- batteryString="%.0f%s" % (100*event.batteryChargePercent, '%'),
62
+ batteryPercent=int(100*event.batteryChargePercent),
63
63
  pump_event_id = "%s" % event.seqNum
64
64
  )
65
65
 
@@ -49,7 +49,7 @@ class UpdateProfiles:
49
49
  logger.info("Current pump settings: %s" % pump_settings)
50
50
 
51
51
  ns_profile_obj = self.nightscout.current_profile()
52
- logger.info("Current Nightscout profile: %s" % ns_profile_obj)
52
+ logger.debug("Current Nightscout profile: %s" % ns_profile_obj)
53
53
  if ns_profile_obj is None:
54
54
  ns_profile_obj = {}
55
55
 
@@ -95,7 +95,7 @@ class UpdateProfiles:
95
95
 
96
96
  ns = ns_profile_obj.get('store', {})
97
97
 
98
- logger.info("compare_profiles profile names: device: %s ns: %s", device.keys(), ns.keys())
98
+ logger.debug("compare_profiles profile names: device: %s ns: %s", device.keys(), ns.keys())
99
99
 
100
100
  new_ns_profile = copy.deepcopy(ns_profile_obj)
101
101
  if not 'store' in new_ns_profile:
@@ -113,12 +113,12 @@ class UpdateProfiles:
113
113
 
114
114
  existent_profiles_in_ns = set(device.keys()) & set(ns.keys())
115
115
  for profile_name in existent_profiles_in_ns:
116
- logger.debug("Checking for differences for %s profile between pump and nightscout", profile_name)
116
+ #logger.debug("Checking for differences for %s profile between pump and nightscout", profile_name)
117
117
  pump_configured_profile = device[profile_name]
118
118
  ns_translated_profile = NightscoutEntry.tandemsource_profile_store(pump_configured_profile, pump_settings)
119
119
  ns_configured_profile = ns[profile_name]
120
120
 
121
- logger.debug("Comparing %s profile from pump: %s to nightscout: %s", profile_name, ns_translated_profile, ns_configured_profile)
121
+ #logger.debug("Comparing %s profile from pump: %s to nightscout: %s", profile_name, ns_translated_profile, ns_configured_profile)
122
122
  if self.nightscout_profiles_identical(ns_configured_profile, ns_translated_profile):
123
123
  logger.info("Profile %s identical between pump and nightscout", profile_name)
124
124
  continue
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tconnectsync
3
- Version: 2.1.9
3
+ Version: 2.2.2
4
4
  Summary: Syncs Tandem Source (formerly t:connect) insulin 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