burnedikt / diasend-nightscout-bridge

Synchronize your diasend data to nightscout.
MIT License
18 stars 18 forks source link

Pump Settings synchronization fails if no data on diasend #24

Closed jay-beco closed 1 year ago

jay-beco commented 1 year ago

When Setting up NIGHTSCOUT_PROFILE_NAME the following message pops up:

yarn run v1.22.19 $ yarn build && node dist/run.js $ tsc Fetching diasend patient records between 2023-01-01T09:39:57.648Z and 2023-01-01T09:44:57.650Z Fetching diasend patient records between 2023-01-01T09:39:57.648Z and 2023-01-01T09:44:57.648Z Number of glucose records since 5 minutes ago (2023-01-01T09:39:57.648Z - 2023-01-01T09:44:57.650Z): 1 Sending 1 entries to nightscout Sending 0 treatments to nightscout Scheduling 0 records for processing in next run Next run (Treatments) will be in in 5 minutes... Next run (Entries) will be in in 5 minutes...

TypeError: Cannot read properties of undefined (reading 'toLowerCase') at /Users/janbeco/Documents/GitHub/diasend-nightscout-bridge/dist/diasend.js:158:65 at Generator.next () at fulfilled (/Users/janbeco/Documents/GitHub/diasend-nightscout-bridge/dist/diasend.js:5:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Next run (Pump Settings) will be in in 12 hours...

What is wrong?

muthijammy commented 1 year ago

Production environment detected, enabling Minify WARNING: express-minify cache directory is not writeable, fallback to memory cache. Listening on port 6282 railway Number of glucose records since an hour ago (2023-01-02T00:48:11.007Z - 2023-01-02T01:48:11.008Z): 0 Sending 0 entries to nightscout Next run (Entries) will be in in 2 minutes... Sending 0 treatments to nightscout Updating basal profile based on 0 records got data-received event, requesting reload (node:1) DeprecationWarning: collection.save is deprecated. Use insertOne, insertMany, updateOne, or updateMany instead. (Use node --trace-deprecation ... to show where the warning was created) Scheduling 0 records for processing in next run Next run (Treatments) will be in in 2 minutes... TypeError: Cannot read property 'toLowerCase' of undefined at /opt/app/node_modules/diasend-nightscout-bridge/dist/diasend.js:157:65 at Generator.next () at fulfilled (/opt/app/node_modules/diasend-nightscout-bridge/dist/diasend.js:5:58) at processTicksAndRejections (internal/process/task_queues.js:93:5) Next run (Pump Settings) will be in in 12 hours... Load Complete: sgvs:3, profiles:1 data loaded: reloading sandbox data and updating plugins Prefs: { warn: 30, urgent: 60, enableAlerts: undefined } WS: emitted clear_alarm to all clients

burnedikt commented 1 year ago

I thnk this error was fixed already with version 1.1.1 of the library and this commit.

However, my nightscout fork isn't yet updated to use version 1.1.1, it's still running on 1.0.0. If you want to update to a newer version, you can manually update the version in package.json of your nightscout fork and run npm install, then commit the changes and push them back to github.

The error itself only happens on freshly started nightscout instances to the best of my knowledge, namely if no nightscout profile exists yet. It shouldn't happen if you started changing some settings within the nightscout profile editor or on subsequent runs, but I might be mistaken.

burnedikt commented 1 year ago

My bad, this seems to be unrelated to what I said and instead relates to the fact that the bridge tries to synchronize the lower and upper blood glucose target values from diasend. It seems like it cannot find the value within the pump settings at this url: https://international.diasend.com/reports/<diasend-user-id>/insulin/pump-settings (<diasend-user-id will be different for each user):

image

To debug this, would be interesting what the both of you see within their diasend account's pump settings. You can find the settings by loging into diasend, setting the lanugage to english at login and then navigating to "Insulin" -> "Pump Settings".

jay-beco commented 1 year ago

Morning - strangely enough > ?! > Ypsopump

Bildschirm­foto 2023-01-03 um 07 06 11

Not having any settings at all showing up explains at last part of the problem... ;)

burnedikt commented 1 year ago

At the very least, the bridge should probably handle this case more gracefully, but still weird that there are no pump settings in diasend.

burnedikt commented 1 year ago

One reason why there may be no pump settings available is because there are multiple pumps registered within diasend and the wrong one is set as active within the diasend patient profile, see also this comment. Can be configured at https://international.diasend.com/patient/profile.

burnedikt commented 1 year ago

Anyhow, the error should no longer appear with Version 1.1.5

jay-beco commented 1 year ago
image

Just one pump and no additional configs and still no Info in the pump settings?!

image

But that's an issue on my side i guess. Does it have any implications with how the bridge works or what data will be shown in Nightscout or can I just leave it as it is? ..

burnedikt commented 1 year ago

But that's an issue on my side i guess. Does it have any implications with how the bridge works or what data will be shown in Nightscout or can I just leave it as it is? ..

It will prevent the basal rate programmed into the pump from being shown. It'll also not import the Insulin:Carb-ratios and insulin sensitivity profiles. But those anyhow only make sense if you use nightscout's bolus calculator or other nightscout features. If you're just using nightscout for monitoring, I think it shouldn't be an issue. Still weird that the basal rate programmed into the pump does not show anywhere on diasend 😕