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

Glooko returns 0 treatments #38

Open
rafaelgisbert opened this issue Jan 27, 2024 · 2 comments
Open

Glooko returns 0 treatments #38

rafaelgisbert opened this issue Jan 27, 2024 · 2 comments

Comments

@rafaelgisbert
Copy link

Hi,

I'm using nightscout-connect plugin to syng from glooko. Authorization is successuful but Heroku logs shows that zero treatments are returned:

2024-01-27T12:58:59.055619+00:00 app[web.1]: FETCHING
2024-01-27T12:58:59.055705+00:00 app[web.1]: GLOOKO passing batch for transforming
2024-01-27T12:58:59.055795+00:00 app[web.1]: GLOOKO data transformation complete, returning 0 treatments

What am I missing?

Thanks,
Rafael

@Qxlkdr
Copy link

Qxlkdr commented Dec 22, 2024

I'm getting the exact same issue:

FETCHING
GLOOKO passing batch for transforming
GLOOKO data transformation complete, returning 0 treatments

I'm running Nightscout in an LXD container on Ubuntu Server 22.04.5.

Here is my current my.env file:

ENABLE=connect%20bridge%20careportal%20iob%20delta%20timeago
CONNECT_SOURCE=glooko
CONNECT_GLOOKO_ENV=eu
CONNECT_GLOOKO_SERVER=eu.api.glooko.com
CONNECT_GLOOKO_EMAIL=HIDDEN
CONNECT_GLOOKO_PASSWORD='HIDDEN'
CONNECT_GLOOKO_TIMEZONE_OFFSET=1

I also had to modify the /node_modules/nightscout-connect/lib/sources/glooko/index.js file according to this:

function login_payload (opts) {
  var body = {
    "userLogin": {
      "email": opts.glookoEmail,
      "password": opts.glookoPassword
    },
    "deviceInformation": {
        "applicationType": "logbook",
        "os": "android",
        "osVersion": "33",
        "device": "Google Pixel 8 Pro",
        "deviceManufacturer": "Google",
        "deviceModel": "Pixel 8 Pro",
        "serialNumber": "HIDDEN",
        "clinicalResearch": false,
        "deviceId": "HIDDEN",
        "applicationVersion": "6.1.3",
        "buildNumber": "0",
        "gitHash": "g4fbed2011b"
     }
  };
  return body;
}

Before I got status code 422 or 401 depending on which server I used in the my.env file if I didn't changed the deviceInformation in the index.js file.

Here is my output when starting Nightscout:

GLOOKO FETCHER LOADING /api/v2/pumps/scheduled_basals?patient=eu-west-HIDDEN&startDate=2024-12-20T22:02:09.160Z&endDate=2024-12-22T22:02:09.160Z
GLOOKO FETCHER LOADING /api/v2/pumps/normal_boluses?patient=eu-west-HIDDEN&startDate=2024-12-20T22:02:09.160Z&endDate=2024-12-22T22:02:09.165Z
GLOOKO FETCHER LOADING /api/v2/cgm/readings?patient=eu-west-HIDDEN&startDate=2024-12-20T22:02:09.160Z&endDate=2024-12-22T22:02:09.168Z
FETCHING
GLOOKO passing batch for transforming
GLOOKO data transformation complete, returning 0 treatments
{
  context: {
    retries: 0,
    duration: 0,
    session: {
      cookies: '_logbook-web_session=HIDDEN; domain=.glooko.com; path=/; secure; HttpOnly; SameSite=Lax',
      user: [Object]
    },
    last_known: {
      entries: 2024-12-22T21:53:30.063Z,
      sgvs: [Object],
      treatments: 1970-01-01T00:00:00.000Z,
      devicestatus: 1970-01-01T00:00:00.000Z,
      profile: undefined
    },
    diagnostics: {},
    started: 1734904928840,
    startedWaiting: 1734904928840,
    endedWaiting: 1734904928842,
    elapsedWaiting: 2,
    data: { scheduledBasals: [], normalBoluses: [], readings: [] },
    transformed: { entries: [], treatments: [] }
  },
  event: {
    type: 'done.invoke.phase.Transforming:invocation[0]',
    data: { entries: [], treatments: [] },
    toString: [Function (anonymous)]
  }
}

Anyone with a nice/cool solution? I even tried changing all API endpoints from /api/v2 to api/v2/external in the index.js file, but that didn't work.

Thanks in advance.

@Qxlkdr
Copy link

Qxlkdr commented Dec 22, 2024

I've done some troubleshooting. I think it's a timestamp problem here:

var lastUpdatedAt = last_glucose_at.toISOString( );

When testing in Postman I don't see where startTime nor endTime is used.

So I console.log() the params and lastUpdatedAt was in fact the same time as now. Using that value didn't return anything. If I then used:

var lastUpdatedAt = new Date(two_days_ago);

I was able to get some treatments into Nightscout but I can see that a lot of data is still undefined.

I'm no programmer so help would be appreciated. :)

I will continue tomorrow or in a few days. Maybe the original developer might see the problem easier than me. I assume we get latestUpdatedAt dynamically for a reason.

My initial thought was that it only gets data from when the session was started. But I tried having my Nightscout instance running and then uploaded my pump to Glooko but nothing came up in Nightscout.

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

No branches or pull requests

2 participants