nightscout / nightscout-connect

Single entry point for bridging cloud resources containing diabetes data to Nightscout.
GNU Affero General Public License v3.0
31 stars 33 forks source link

Wrong time of SG on Nightscout with minimedcarelink source #16

Closed skritland closed 1 year ago

skritland commented 1 year ago

Hello,

I've started using nightscout with nightscout-connect plugin using docker. I've configured everything and no matter what combination of timezones I'm setting, I get always shifted data. It looks like mesurements time from CareLink is in local time but is treated like UTC time. Below more information:

docker-compose.yaml:

nightscout:
    image: nightscout/cgm-remote-monitor:latest_dev
    container_name: nightscout
    environment:
      TZ: Europe/Warsaw
      TIME_FORMAT: 24
      MONGO_CONNECTION: mongodb://mongo:27017/nightscoutdb
      API_SECRET: SECRET
      BG_HIGH: 200
      BG_LOW: 70
      BG_TARGET_TOP: 180
      BG_TARGET_BOTTOM: 70
      AUTH_DEFAULT_ROLES: readable devicestatus-upload
      ENABLE: careportal boluscalc food bwp cage sage iage iob cob basal ar2 rawbg pushover bgi pump openaps cors connect
      SHOW_FORECAST: openaps
      SHOW_PLUGINS: careportal openaps pump iob sage cage
      CUSTOM_TITTLE: Nightscout
      DISPLAY_UNITS: mg/dl
      INSECURE_USE_HTTP: "true"
      CONNECT_SOURCE: minimedcarelink
      CONNECT_CARELINK_REGION: eu
      CONNECT_COUNTRY_CODE: pl
      CONNECT_CARELINK_USERNAME: user
      CONNECT_CARELINK_PASSWORD: pass
    ports:
      - 1337:1337
    depends_on:
      - mongo
    volumes:
      - ./nightscout:/var/opt/ssl/:ro
    restart: unless-stopped

  mongo:
    image: mongo:4.4.23
    container_name: mongo
    environment:
      TZ: Europe/Warsaw
    volumes:
      - ./mongo/data:/data/db
    restart: unless-stopped

extract from docker logs:

   {
      lastSGTrend: 'UP',
      type: 'sgv',
      sgv: 174,
      date: 1691354760000,
      dateString: '2023-08-06T20:46:00.000Z',
      device: 'nightscout-connect://minimedcarelink/NGP',
      trend: 2,
      direction: 'SingleUp'
    }
  ],
  devicestatus: [
    {
      created_at: '2023-08-06T18:47:18.807Z',
      lastMedicalDeviceDataUpdateServerTime: 1691347606617,
      device: 'nightscout-connect://minimedcarelink/NGP',
      uploader: [Object],
      connect: [Object],
      pump: [Object]
    }
  ],
  treatments: []
}
got data-received event, requesting reload

obraz

AndyLow91 commented 1 year ago

@skritland - It seems it is normal to receive the data from CareLink in UTC, after all the data received, you should also see a key named 'lastConduitDateTime' and this should be in the correct timezone. If it isn't, this points to the wrong timezone being set in your CareLink account. It's worth checking this. It looks like this package uses that time formatting to transform the data into a way that Nightscout understands.

Another thing to check is that even though you have the correct TZ set in your docker-compose, do you have it set correctly in your Nightscout profile?

Note, I didn't write this package, I've just been tinkering a lot with it today and this is what I've come up with. Hopefully it's one of these things.

skritland commented 1 year ago

I'm using "Europe/Warsaw" timezone (it is now UTC+ 2 h) in both mongo and nightscout containers. The same is set in the nightscout profile (however, changing that to UTC changes nothing). I don't see any option to change timezone in my CareLink settings, but when I use xDrip+ with CareLink all is displayed correctly. The "lastConduitDateTime" in logs lokks OK: '2023-08-06T20:46:46.727+02:00'. For me the most suspicious is the part from the logs I attached in the first post: dateString: '2023-08-06T20:46:00.000Z', because in fact that measurement was taken at 18:46 UTC = 20:46 local time, but suffix 'Z' is suggesting UTC time. I've checked mongo database entries content and it also was '2023-08-06T20:46:00.000Z' instead of 18:46.

bewest commented 1 year ago

Please try again, and make sure that you are testing an up to date image; I think the publication to dockerhub takes some time. Moments before you submitted this Andy created a patch for this issue, so it's probably just a delayed publishing to dockerhub.

It would be great to check the medicalDeviceFamily and kind fields. https://github.com/nightscout/nightscout-connect/commit/9d0e0bef45cce74bb89d1aa4ef4083c80e814f55

https://github.com/nightscout/nightscout-connect/commit/cfa9a50e4de6447ae9c6f49b50811ecdd1f4bd78

skritland commented 1 year ago

Thanks, I didn't notice the update from yesterday. After pulling new docker image everything works ok.