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

import change from #30 #36

Merged
merged 1 commit into from
Jan 6, 2023
Merged

import change from #30 #36

merged 1 commit into from
Jan 6, 2023

Conversation

bewest
Copy link
Member

@bewest bewest commented Nov 18, 2022

@sirKitKat volunteers these changes in issue #30.

@sirKitKat volunteers these changes in issue #30.
@mattster98
Copy link

Can this be integrated into a release so it will make it into the next docker build? I'm not getting carelink data at all I think because of this issue (it's getting the NaN error guessing the offset)

@bewest
Copy link
Member Author

bewest commented Jan 5, 2023

Howdy @mattster98, thanks for the input! Which region are you located in? Are you saying @sirKitKat's fixes worked for you, or reporting that it does not currently work at all?

I've been working on testing these changes for integration and release ASAP.

@mattster98
Copy link

No, I'm still trying to get a docker image built so I can try it out. I deployed the latest released build to my own kubernetes cluster and have not rolled my own before, so it's a bit of a struggle.

@mattster98
Copy link

OK - quite the journey to here, but I got my updated docker built that points to my custom npm for minimed-connect-to-nightscout that has this change in it, aaaaand it is still failing. It DOES now show the correctly guessed offset (I'm in US/Eastern and it says -0500). However I still get the RangeError: Invalid time value

│ nightscout 2023-01-05T20:00:43.127Z [Arguments] {                                                                                                                                                                                           │
│ nightscout   '0': 'EU login 3 (url: https://mdtlogin.medtronic.com/mmcl/auth/oauth/v2/authorize/login?locale=en&countrycode=US)'                                                                                                            │
│ nightscout }                                                                                                                                                                                                                                │
│ nightscout 2023-01-05T20:00:43.406Z [Arguments] {                                                                                                                                                                                           │
│ nightscout   '0': 'EU login 4 (url: https://mdtlogin.medtronic.com/mmcl/auth/oauth/v2/authorize/consent, sessionID: aca9d16d-ab83-486a-926d-64130fe9fa39, sessionData: eyJ0eXAiOiJKV1QiLCJjdHkiOiJKV1QiLCJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JD │
│ nightscout }                                                                                                                                                                                                                                │
│ nightscout 2023-01-05T20:00:43.616Z [Arguments] {                                                                                                                                                                                           │
│ nightscout   '0': 'EU login 5 (url: https://carelink.minimed.com/patient/sso/auth?code=ac0e9bd6-cc51-4987-865d-ba391da70e23&state=auth)'                                                                                                    │
│ nightscout }                                                                                                                                                                                                                                │
│ nightscout 2023-01-05T20:00:44.397Z [Arguments] {                                                                                                                                                                                           │
│ nightscout   '0': 'GET data (as carepartner) https://clcloud.minimed.com/connect/v2/display/message'                                                                                                                                        │
│ nightscout }                                                                                                                                                                                                                                │
│ nightscout 2023-01-05T20:00:44.852Z [Arguments] {                                                                                                                                                                                           │
│ nightscout   '0': 'Guessed pump timezone -0500 (pump time: "2023-01-05T14:56:00.706-00:00"; server time: Thu Jan 05 2023 15:00:44 GMT-0500 (Eastern Standard Time))'                                                                        │
│ nightscout }                                                                                                                                                                                                                                │
│ nightscout (node:1) UnhandledPromiseRejectionWarning: RangeError: Invalid time value                                                                                                                                                        │
│ nightscout     at Date.toISOString (<anonymous>)                                                                                                                                                                                            │
│ nightscout     at timestampAsString (/opt/app/node_modules/minimed-connect-to-nightscout-mattster98/transform.js:50:30)                                                                                                                     │
│ nightscout     at deviceStatusEntry (/opt/app/node_modules/minimed-connect-to-nightscout-mattster98/transform.js:123:18)                                                                                                                    │
│ nightscout     at Object.module.exports [as transform] (/opt/app/node_modules/minimed-connect-to-nightscout-mattster98/transform.js:187:20)                                                                                                 │
│ nightscout     at handleCarelinkData (/opt/app/lib/plugins/mmconnect.js:61:33)                                                                                                                                                              │
│ nightscout     at Object.fetch (/opt/app/node_modules/minimed-connect-to-nightscout-mattster98/carelink.js:325:13)                                                                                                                          │
│ nightscout     at processTicksAndRejections (internal/process/task_queues.js:93:5)                                                                                                                                                          │
│ nightscout (Use `node --trace-warnings ...` to show where the warning was created)                                                                                                                                                          │
│ nightscout (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch( │
│ nightscout (node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.                         │

@mattster98
Copy link

I tried deploying a dev version so I could inspect as it was running to try and debug this, but that's beyond what's left of my capabilities today.. I'll keep trying tomorrow.

I have the following env variables.. that may mean I'm not getting all of the fix based on my interpretation of the code.

MMCONNECT_SERVER: US
MMCONNECT_COUNTRYCODE: US

@bewest bewest merged commit f850f89 into dev Jan 6, 2023
@mattster98
Copy link

OK - I managed to get a local server running on windows so I could more easily debug via probably the hackiest way possible (more logging to console) but the only way I could seem to get the runtime values that were triggering the error.

My sMedicalDeviceTime is 2023-01-06T12:56:01.582-00:00

That seems to be the problem since the non-EU fix in parsePumpTime looks to concatenate a timezone offset before date.parse instead of offsetting the resulting unix timestamp. I already have the offset, so it's generating an invalid input to date.parse.

It might make more sense to just try the first method, and if that fails, try the second. By forcing the EU method on my server, I begin to successfully download from carelink.

@@ -38,9 +38,9 @@ var CARELINK_TREND_TO_NIGHTSCOUT_TREND = {
}
};

function parsePumpTime(pumpTimeString, offset, medicalDeviceFamily) {
function parsePumpTime(pumpTimeString, offset, offsetMilliseconds, medicalDeviceFamily) {
if (process.env['MMCONNECT_SERVER'] === 'EU' || medicalDeviceFamily === 'GUARDIAN') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The offset issues were affecting me (with MCONNECT_SERVER: US) so I added "or US" to this to get the same fix. I'm troubleshooting intermittent other issues but I'm guessing those are related to deploying on kubernetes, since it seems fine running in dev.

mattster98@21e07ca

A more elegant solution (assuming appending the tz offset is still needed in some situations) might be to see if the first method works, and if so, go with it. If it doesn't, use the second method. I'm guessing medtronic changed how they're sending the device time out, but not sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think US and EU are doing the same thing, and the separation is a historical artifact we can ignore.

I've been meaning to more carefully to emulate what's happening in XDripCarelinkFollower: https://github.com/benceszasz/xDripCareLinkFollower/tree/master/app/src/main/java/com/eveningoutpost/dexdrip/cgm/carelinkfollow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also note, Sulka disabled some additional datetime munging just recently here: nightscout/cgm-remote-monitor@c1de8a5

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 this pull request may close these issues.

2 participants