Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time offset between tsync/tconnect record and NS time parse #47

Closed
jyaw opened this issue Aug 14, 2022 · 11 comments · Fixed by #51
Closed

time offset between tsync/tconnect record and NS time parse #47

jyaw opened this issue Aug 14, 2022 · 11 comments · Fixed by #51

Comments

@jyaw
Copy link
Contributor

jyaw commented Aug 14, 2022

Observed a couple problems with my initial tconnectsync attempts. I'll paste the full content of relevant errors in the next comment. Highlighting 2 items here...

  1. Calculated "5 hours" offset between the similar log time and CIQ time? Not sure why this is hapenning. My timezone on my linux system and the date command are set correctly (central time)... (e.g. 2022-08-13 20:38:42 INFO Last bolus from t:connect CIQ: 2022-08-13T19:46:15 (5 hours, 52 minutes ago) )
  2. NS latest entry update shows a ISO-8601 parsing error, note that the NS site is a brand new site with not records. Tried adding a fake bolus manually and that didn't seem to change the error.

raise ApiException(latest.status_code, "Nightscout last_uploaded_entry response: %s" % latest.text)
tconnectsync.api.common.ApiException: Nightscout last_uploaded_entry response:
Error: Cannot parse 2022-08-12+20:38:37 as a valid ISO-8601 date

@jyaw
Copy link
Contributor Author

jyaw commented Aug 14, 2022

Full error text:
2022-08-13 20:38:37 INFO Enabled features: BASAL, BOLUS
2022-08-13 20:38:37 INFO Logged in to AndroidApi successfully (expiration: 2022-08-14T09:38:37.657Z, in 7 hours, 59 minutes)
2022-08-13 20:38:37 INFO New reported t:connect data. (event index: 825914 last: None)
2022-08-13 20:38:37 INFO Downloading t:connect ControlIQ data
2022-08-13 20:38:37 INFO Logging in to ControlIQApi...
2022-08-13 20:38:38 INFO Reported tconnect software version: t:connect 7.14.0.1
2022-08-13 20:38:40 INFO Logged in to ControlIQApi successfully (expiration: 2022-08-14T09:38:38.752Z, in 7 hours, 59 minutes)
2022-08-13 20:38:41 INFO Downloading t:connect therapy_events
2022-08-13 20:38:42 WARNING No last CGM reading is able to be determined from CIQ
2022-08-13 20:38:42 INFO Last bolus from t:connect CIQ: 2022-08-13T19:46:15 (5 hours, 52 minutes ago)
2022-08-13 20:38:43 INFO Last basal event from CIQ: {'time': '2022-08-13 19:52:44-05:00', 'delivery_type': 'algorithmDelivery', 'duration_mins': 3.2, 'basal_rate': 1.383}
Traceback (most recent call last):
File "/home/pi/.local/bin/tconnectsync", line 8, in
sys.exit(main())
File "/home/pi/.local/lib/python3.9/site-packages/tconnectsync/init.py", line 87, in main
sys.exit(u.process(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features))
File "/home/pi/.local/lib/python3.9/site-packages/tconnectsync/autoupdate.py", line 48, in process
added = process_time_range(tconnect, nightscout, time_start, time_end, pretend, features=features)
File "/home/pi/.local/lib/python3.9/site-packages/tconnectsync/process.py", line 143, in process_time_range
added += ns_write_basal_events(nightscout, basalEvents, pretend=pretend, time_start=time_start, time_end=time_end)
File "/home/pi/.local/lib/python3.9/site-packages/tconnectsync/sync/basal.py", line 109, in ns_write_basal_events
last_upload = nightscout.last_uploaded_entry(BASAL_EVENTTYPE, time_start=time_start, time_end=time_end)
File "/home/pi/.local/lib/python3.9/site-packages/tconnectsync/nightscout.py", line 64, in last_uploaded_entry
raise ApiException(latest.status_code, "Nightscout last_uploaded_entry response: %s" % latest.text)
tconnectsync.api.common.ApiException: Nightscout last_uploaded_entry response:

<title>Error: Cannot parse 2022-08-12+20:38:37 as a valid ISO-8601 date</title> <style>* { margin: 0; padding: 0; outline: 0; }

body {
padding: 80px 100px;
font: 13px "Helvetica Neue", "Lucida Grande", "Arial";
background: #ECE9E9 -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#ECE9E9));
background: #ECE9E9 -moz-linear-gradient(top, #fff, #ECE9E9);
background-repeat: no-repeat;
color: #555;
-webkit-font-smoothing: antialiased;
}
h1, h2 {
font-size: 22px;
color: #343434;
}
h1 em, h2 em {
padding: 0 5px;
font-weight: normal;
}
h1 {
font-size: 60px;
}
h2 {
margin-top: 10px;
}
ul li {
list-style: none;
}
#stacktrace {
margin-left: 60px;
}
</style>

Connect

500 Error: Cannot parse 2022-08-12+20:38:37 as a valid ISO-8601 date

  •    at /app/lib/server/query.js:71:17
  •    at Array.forEach (<anonymous>)
  •    at enforceDateFilter (/app/lib/server/query.js:62:28)
  •    at create (/app/lib/server/query.js:120:5)
  •    at query_for (/app/lib/server/treatments.js:121:12)
  •    at Function.list (/app/lib/server/treatments.js:115:13)
  •    at /app/lib/api/treatments/index.js:94:22
  •    at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
  •    at next (/app/node_modules/express/lib/router/route.js:137:13)
  •    at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
(HTTP 500)

@t1diotac
Copy link
Contributor

It appears I'm getting a similar error regarding parsing the date as a valid ISO-8601 date.

2022-08-18 20:38:23 INFO     Enabled features: BASAL, BOLUS, PUMP_EVENTS
Processing data between 2022-08-17 20:38:23.528173 and 2022-08-18 20:38:23.528173 
2022-08-18 20:38:23 INFO     Downloading t:connect ControlIQ data
2022-08-18 20:38:23 INFO     Logging in to ControlIQApi...
2022-08-18 20:38:23 INFO     Reported tconnect software version: t:connect 7.14.0.1
2022-08-18 20:38:27 INFO     Logged in to ControlIQApi successfully (expiration: 2022-08-19T10:38:24.005Z, in 7 hours, 59 minutes)
2022-08-18 20:38:28 INFO     Downloading t:connect therapy_events
2022-08-18 20:38:29 WARNING  No last CGM reading is able to be determined from CIQ
2022-08-18 20:38:29 INFO     Last bolus from t:connect CIQ: 2022-08-18T19:41:42 (6 hours, 56 minutes ago)
2022-08-18 20:38:29 INFO     Last basal event from CIQ: {'time': '2022-08-18 19:55:52-04:00', 'delivery_type': 'algorithmDelivery', 'duration_mins': 30.066666666666666, 'basal_rate': 0.25}
Traceback (most recent call last):
  File "/home/health/.local/bin/tconnectsync", line 8, in <module>
    sys.exit(main())
  File "/home/health/.local/lib/python3.9/site-packages/tconnectsync/__init__.py", line 90, in main
    added = process_time_range(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features)
  File "/home/health/.local/lib/python3.9/site-packages/tconnectsync/process.py", line 143, in process_time_range
    added += ns_write_basal_events(nightscout, basalEvents, pretend=pretend, time_start=time_start, time_end=time_end)
  File "/home/health/.local/lib/python3.9/site-packages/tconnectsync/sync/basal.py", line 109, in ns_write_basal_events
    last_upload = nightscout.last_uploaded_entry(BASAL_EVENTTYPE, time_start=time_start, time_end=time_end)
  File "/home/health/.local/lib/python3.9/site-packages/tconnectsync/nightscout.py", line 64, in last_uploaded_entry
    raise ApiException(latest.status_code, "Nightscout last_uploaded_entry response: %s" % latest.text)
tconnectsync.api.common.ApiException: Nightscout last_uploaded_entry response: <html>
  <head>
    <meta charset='utf-8'> 
    <title>Error: Cannot parse 2022-08-17+20:38:23 as a valid ISO-8601 date</title>
    <style>* {
  margin: 0;
  padding: 0;
  outline: 0;
}

body {
  padding: 80px 100px;
  font: 13px "Helvetica Neue", "Lucida Grande", "Arial";
  background: #ECE9E9 -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#ECE9E9));
  background: #ECE9E9 -moz-linear-gradient(top, #fff, #ECE9E9);
  background-repeat: no-repeat;
  color: #555;
  -webkit-font-smoothing: antialiased;
}
h1, h2 {
  font-size: 22px;
  color: #343434;
}
h1 em, h2 em {
  padding: 0 5px;
  font-weight: normal;
}
h1 {
  font-size: 60px;
}
h2 {
  margin-top: 10px;
}
ul li {
  list-style: none;
}
#stacktrace {
  margin-left: 60px;
}
</style>
  </head>
  <body>
    <div id="wrapper">
      <h1>Connect</h1>
      <h2><em>500</em> Error: Cannot parse 2022-08-17+20:38:23 as a valid ISO-8601 date</h2>
      <ul id="stacktrace"><li> &nbsp; &nbsp;at /app/lib/server/query.js:71:17</li><li> &nbsp; &nbsp;at Array.forEach (&lt;anonymous&gt;)</li><li> &nbsp; &nbsp;at enforceDateFilter (/app/lib/server/query.js:62:28)</li><li> &nbsp; &nbsp;at create (/app/lib/server/query.js:120:5)</li><li> &nbsp; &nbsp;at query_for (/app/lib/server/treatments.js:121:12)</li><li> &nbsp; &nbsp;at Function.list (/app/lib/server/treatments.js:115:13)</li><li> &nbsp; &nbsp;at /app/lib/api/treatments/index.js:94:22</li><li> &nbsp; &nbsp;at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)</li><li> &nbsp; &nbsp;at next (/app/node_modules/express/lib/router/route.js:137:13)</li><li> &nbsp; &nbsp;at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)</li></ul>
    </div>
  </body>
</html>
 (HTTP 500)

@rstutsman
Copy link
Contributor

rstutsman commented Aug 20, 2022

I'm running into the same issue on Ubuntu 20.04 but it is working on macos. The issue seems to stem from urljoin of the dateFilter returned by time_range in last_uploaded_activity. This is just a guess, but it looks like the space in put into the date format in time_range is getting encoded as a +. It seems like ISO-8601 doesn't specify the space anyway, so maybe it makes sense to remove it?

@jyaw
Copy link
Contributor Author

jyaw commented Aug 20, 2022

Thanks @rstutsman! I figured it had to do with the date filter... will give this a check on my instance sometime today.

@jyaw
Copy link
Contributor Author

jyaw commented Aug 20, 2022

Hey I'm getting a different unknown therapy event error now before I hit the previous iso format time error, can't really verify yet. Will update if I'm able to check it out, hopefully soon.

@ramboozer
Copy link

ramboozer commented Aug 21, 2022

pi@magicmirroros:~ $ tconnectsync --auto-update
2022-08-20 20:17:19 INFO     Enabled features: BASAL, BOLUS
Starting auto-update between 2022-08-19 20:17:19.923273 and 2022-08-20 20:17:19.923273
2022-08-20 20:17:20 INFO     Logged in to AndroidApi successfully (expiration: 2022-08-21T08:17:20.401Z, in 7 hours, 59 minutes)
2022-08-20 20:17:20 INFO     New reported t:connect data. (event index: 817956 last: None)
2022-08-20 20:17:20 INFO     Downloading t:connect ControlIQ data
2022-08-20 20:17:20 INFO     Logging in to ControlIQApi...
2022-08-20 20:17:21 INFO     Reported tconnect software version: t:connect 7.14.0.1
2022-08-20 20:17:24 INFO     Logged in to ControlIQApi successfully (expiration: 2022-08-21T08:17:21.513Z, in 7 hours, 59 minutes)
2022-08-20 20:17:25 INFO     Downloading t:connect therapy_events
Traceback (most recent call last):
  File "/usr/local/bin/tconnectsync", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/tconnectsync/__init__.py", line 87, in main
    sys.exit(u.process(tconnect, nightscout, time_start, time_end, args.pretend, features=args.features))
  File "/usr/local/lib/python3.7/dist-packages/tconnectsync/autoupdate.py", line 48, in process
    added = process_time_range(tconnect, nightscout, time_start, time_end, pretend, features=features)
  File "/usr/local/lib/python3.7/dist-packages/tconnectsync/process.py", line 67, in process_time_range
    ciqBolusData, ciqReadingData = split_therapy_events(ciqTherapyEventsData)
  File "/usr/local/lib/python3.7/dist-packages/tconnectsync/parser/ciq_therapy_events.py", line 12, in split_therapy_events
    event = TConnectEntry.parse_therapy_event(e)
  File "/usr/local/lib/python3.7/dist-packages/tconnectsync/parser/tconnect.py", line 204, in parse_therapy_event
    raise UnknownTherapyEventException(data)
tconnectsync.parser.tconnect.UnknownTherapyEventException: Unknown therapy event type:
pi@magicmirroros:~ $ tconnectsync --check-login
tconnectsync version 0.8.2
Python version 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0]
System platform linux
Running checks with time range 2022-08-19 20:25:44.715665 to 2022-08-20 20:25:44.715665
Current time: 2022-08-20 20:25:44.716097
time.tzname: ('EST', 'EDT')
Loading secrets...
TIMEZONE_NAME: America/New_York
-----
Logging in to t:connect ControlIQ API...
2022-08-20 20:25:44 INFO     Logging in to ControlIQApi...
2022-08-20 20:25:45 INFO     Reported tconnect software version: t:connect 7.14.0.1
2022-08-20 20:25:49 INFO     Logged in to ControlIQApi successfully (expiration: 2022-08-21T08:25:45.988Z, in 7 hours, 59 minutes)
tconnect_software_ver: t:connect 7.14.0.1
Querying ControlIQ therapy_timeline...
Last ControlIQ processed therapy_timeline event:
{'basal_rate': 1.2,
 'delivery_type': 'algorithmDelivery',
 'duration_mins': 102.95,
 'time': '2022-08-20 18:21:34-04:00'}
Querying ControlIQ therapy_events...
-----
Initializing t:connect WS2 API...
Querying WS2 therapy_timeline_csv...
Error occurred querying WS2 therapy_timeline_csv. This is okay so long as you are not using the PUMP_EVENTS or IOB sync features.
get() got an unexpected keyword argument 'timeout'
-----
Logging in to t:connect Android API...
2022-08-20 20:25:57 INFO     Logged in to AndroidApi successfully (expiration: 2022-08-21T08:25:57.110Z, in 7 hours, 59 minutes)
-----
Logging in to Nightscout...
-----
Last basal start time: 2022-08-20 18:21:34-04:00 (2:04:24.057615 ago)
Last basal duration: 102.95
Last reading time: None (n/a)
-----

@jyaw
Copy link
Contributor Author

jyaw commented Aug 21, 2022 via email

@jyaw
Copy link
Contributor Author

jyaw commented Aug 21, 2022

It looks like when process.py calls parse_therapy_event in parser/tconnect.py, the type for the first few of my events is 'BG', rather than 'Bolus' or 'CGM', so it throws a UnknownTherapyEventException... not related to this time issue, so I'll open a new issue if it doesnt exist yet...

@jyaw
Copy link
Contributor Author

jyaw commented Aug 21, 2022

Verified it works, will leave the issue open since the PR hasn't been approved...

jyaw pushed a commit to jyaw/tconnectsync that referenced this issue Aug 21, 2022
jwoglom pushed a commit that referenced this issue Aug 22, 2022
@rstutsman
Copy link
Contributor

@jyaw I ran into the UnknownTherapyEventException for the same reason as you (type == BG), but before I could track down what was the issue disappeared. If someone catches that issue in action, it would be great to capture it in an issue. I tweaked the output for UnknownTherapyEventException in a posted PR since it was missing a format string element that prevented it from outputting the full details of the event that triggered it.

@jyaw
Copy link
Contributor Author

jyaw commented Aug 26, 2022

I created an issue And fixed in issue #52 I think. Thanks for addressing the exception formatting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants