GithubHelp home page GithubHelp logo

timoschlueter / nightscout-librelink-up Goto Github PK

View Code? Open in Web Editor NEW
173.0 21.0 237.0 186 KB

Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout.

License: MIT License

Dockerfile 1.39% JavaScript 1.82% Procfile 0.10% TypeScript 96.69%
freestyle-libre nightscout nightscout-cgm librelink cgm freestyle glucose-monitoring libre

nightscout-librelink-up's Introduction

Nightscout LibreLink Up Uploader/Sidecar

docker-image

Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout. The upload should work with at least Freestyle Libre 2 (FGM) and Libre 3 CGM sensors.

Deploy

Configuration

The script takes the following environment variables

Variable Description Example Required
LINK_UP_USERNAME LibreLink Up Login Email [email protected] X
LINK_UP_PASSWORD LibreLink Up Login Password mypassword X
LINK_UP_CONNECTION LibreLink Up Patient-ID. Can be received from the console output if multiple connections are available. 123456abc-abcd-efgh-7891def
LINK_UP_TIME_INTERVAL The time interval of requesting values from libre link up 5
LINK_UP_REGION Your region. Used to determine the correct LibreLinkUp service (Possible values: AE, AP, AU, CA, DE, EU2, EU2, FR, JP, US) EU
NIGHTSCOUT_URL Hostname of the Nightscout instance (without https://) nightscout.yourdomain.com X
NIGHTSCOUT_API_TOKEN SHA1 Hash of Nightscout access token 162f14de46149447c3338a8286223de407e3b2fa X
NIGHTSCOUT_DISABLE_HTTPS Disables the HTTPS requirement for Nightscout URLs true
NIGHTSCOUT_DEVICE_NAME Sets the device name used in Nightscout nightscout-librelink-up
LOG_LEVEL The setting of verbosity for logging, should be one of info or debug info
SINGLE_SHOT Disables the scheduler and runs the script just once true

Usage

There are different options for using this script.

Variant 1: On Heroku

  • Click on Deploy
  • Login to Heroku if not already happened
  • Provide proper values for the environment variables
  • Important: make sure that yor Nightscout API token is hashed with SHA1
  • Click Deploy to deploy the app

Variant 2: Local

The installation process can be started by running npm install in the root directory.

To start the process simply create a bash script with the set environment variables (start.sh):

#!/bin/bash
export LINK_UP_USERNAME="[email protected]"
export LINK_UP_PASSWORD="mypassword"
export LINK_UP_TIME_INTERVAL="5"
export NIGHTSCOUT_URL="nightscout.yourdomain.com"
# use `shasum` instead of `sha1sum` on Mac
export NIGHTSCOUT_API_TOKEN=$(echo -n "foo-bar-baz" | sha1sum | cut -d ' ' -f 1)
export LOG_LEVEL="info"

npm start

Execute the script and check the console output.

Variant 3: Docker

The easiest way to use this is to use the latest docker image:

docker run -e LINK_UP_USERNAME="[email protected]" \
           -e LINK_UP_PASSWORD="mypassword" \
           -e LINK_UP_TIME_INTERVAL="5" \
           -e LINK_UP_REGION="EU" \
           -e NIGHTSCOUT_URL="nightscout.yourdomain.com" \
           -e NIGHTSCOUT_API_TOKEN="librelinku-123456789abcde" \
           -e LOG_LEVEL="info" \
           timoschlueter/nightscout-librelink-up

Variant 4: Docker Compose

If you are already using a dockerized Nightscout instance, this image can be easily added to your existing docker-compose file. In this example, the region is set for germany ("DE"):

version: '3.7'

services:
  nightscout-libre-link:
    image: timoschlueter/nightscout-librelink-up
    container_name: nightscout-libre-link
    environment:
      LINK_UP_USERNAME: "[email protected]"
      LINK_UP_PASSWORD: "mypassword"
      LINK_UP_TIME_INTERVAL: "5"
      LINK_UP_REGION: "DE"
      NIGHTSCOUT_URL: "nightscout.yourdomain.com"
      NIGHTSCOUT_API_TOKEN: "librelinku-123456789abcde"
      LOG_LEVEL: "info"

ToDo

  • Integration into Nightscout: I have not yet looked into the plugin architecture of Nightscout. Maybe this should be converted into a plugin.

nightscout-librelink-up's People

Contributors

3timeslazy avatar andylow91 avatar dependabot[bot] avatar hanskre avatar joerg-schoemer avatar ninelore avatar sebdei avatar swhitt avatar timoschlueter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nightscout-librelink-up's Issues

Back-filling missed data

I have been using this software for a few days to stream Libre 3 data to Nightscout, and it is great. Thank you!

I have noticed a few times that when my son is away from his phone for an extended period (and therefore data is not flowing), that when he returns that this code will fill in some, but not all of the missing data. Both the LibreLink and XDip+ apps seem to fill in all of the missed data. The most items that I have seen this code fill in is 4 ("Upload of 4 measurements to Nightscout"). I am in the USA and using US endpoints.

I am wondering if the /graph API endpoint may need an additional parameter passed to request more data (further back into time) when data has been missed for a while?

High delta

If you compare the delta going up and down ( 5min) its alot higher when you compare with a libre 1 (miaomiao, xdrip4ios) the abbot libre 3 app is compensating down this afterwords a bit in the logged curve,

Is there a way to apply some average filter on the libre 3 bg values before sending it to nightscout

I think they use something like that in Xdrip4ios.

to prevent the curve to overreach actual bg that leads to sharp turns when changing directions

it will also help againt sudden compression drops and even them out a bit

If your looping it will also be easier for loop to regulate a more stable curve and not give to much and then take away basal all the time

It could be an optional feature

Upload Nightscout fail

I I installed the app on Heroku, but the log always shows the error "Upload to Nightscout Failed" The Nightscout URL and Api are correct.

Plan B to Heroku

If anyone is still looking for Plan B to Heroku, I have been using Azure for a little while now since it is back and both the NightScout website and this wonderful write app from Libre to NightScout works seamlessly.

Follow the same steps as migrating nightscout website from the link below and replace where necessary with librelink-up configurations
https://nightscout.github.io/vendors/azure/migrate/

[error]: {"message":"invalid or expired jwt"}

I haven't collected data from libreview for about a month. I redeployed from 1.9.0 to 1.9.1 and it's still the same - AuthFailureError .
I assume this happened after updating librelinkup to 4.5.0.

Log from rail.app:

[email protected] start
node index.js
[info]: Starting cron schedule: */5 * * * *
[info]: no authTicket.expires
[info]: renew token
[info]: Logged in to LibreLink Up
[error]: {"message":"invalid or expired jwt"}
[error]: getting libreLinkUpConnection: Cannot read properties of undefined (reading 'data')

Add config options for http/https and TCP-Port

Hi Timo,

I use you great tool to uplad my data into nightscout which is running on my own docker server and a swarm stack file/compose.
In this case librelink-up and nightscout talk together via a docker (swarm) network directly and i have no https.

Would it be possible to make http/https and the port configurable?

When it will be interesting, heare isma stack file:

version: "3.7"

services:
mongo:
image: mongo:4.4
container_name: mongo
domainname: mongo.localdomain.intra
hostname: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD:
networks:
- nightscout-net
volumes:
- /srv/docker/mongo/data:/data/db

nightscout:
image: nightscout/cgm-remote-monitor:latest
container_name: nightscout
domainname: nightscout.localdomain.intra
hostname: nightscout
restart: always
environment:
NODE_ENV: production
TZ: Europe/Berlin
API_SECRET:
MONGO_CONNECTION: mongodb://admin:@mongo
INSECURE_USE_HTTP: 'true'
TIME_FORMAT: 24h
LANGUAGE: de
ENABLE: careportal rawbg iob
AUTH_DEFAULT_ROLES: denied
HOSTNAME: 0.0.0.0 # required because of IP Service binding
labels:
- traefik.enable=true
- traefik.tags=public
- traefik.docker.network=traefik-net
# HTTP to HTTPS redirect
- traefik.http.routers.nightscout-http.entrypoints=web
- traefik.http.routers.nightscout-http.rule=Host(nightscout.localdomain.intra,nightscout,nightscout.publicdomain.de)
- traefik.http.routers.nightscout-http.service=nightscout-http
- traefik.http.services.nightscout-http.loadbalancer.server.port=1337
#- traefik.http.routers.nightscout-http.middlewares=nightscout-http # if https redirect shout be used
#- traefik.http.middlewares.nightscout-http.redirectscheme.scheme=https
# HTTPS
- traefik.http.routers.nightscout-https.entrypoints=websecure
- traefik.http.routers.nightscout-https.rule=Host(nightscout.publicdomain.de)
- traefik.http.routers.nightscout-https.tls=true
- traefik.http.routers.nightscout-https.tls.certresolver=myresolver
- traefik.http.routers.nightscout-https.service=nightscout-https
- traefik.http.services.nightscout-https.loadbalancer.server.port=1337
networks:
- traefik-net
- nightscout-net
depends_on:
- mongo

nightscout-libre-link:
image: timoschlueter/nightscout-librelink-up
container_name: nightscout-libre-link
hostname: nightscout-libre-link
restart: always
environment:
LINK_UP_USERNAME: ""
LINK_UP_PASSWORD: "
"
LINK_UP_TIME_INTERVAL: "5"
LINK_UP_REGION: "DE"
NIGHTSCOUT_URL: "nightscout"
NIGHTSCOUT_API_TOKEN: ""
LOG_LEVEL: "debug"
networks:
- nightscout-net

networks:
traefik-net:
external: true
nightscout-net:

Nightscout token in SHA1 really necessary?

I want to analyze the SHA1 requirement of the Nightscout token. Some users are confused about the hashing of the token. In my instance, I don't hash the token and the plugin still works. Maybe we should update the documentation again. The SHA1 requirement was introduces in PR #21.
@HansKre since I don't use Heroku: is the hashing something that is necessary on Heroku deployments? It does not seem to be required on local/docker deployments.

invalid or expired jwt

Hi Timo,

after the last update from llu on 2022-03-31 the jwt returned by login is rejected in the connections request.
I've added a lot of logging to figure out what's going on. Here is the current log file:

2022-04-02T08:42:30.830694+00:00 app[worker.1]: [info]: renew token
2022-04-02T08:42:31.267897+00:00 app[worker.1]: [info]: responseData {"status":4,"data":{"step":{"type":"tou","componentName":"AcceptDocument","props":{"reaccept":true,"titleKey":"Common.termsOfUse","type":"tou"}},"user":{"accountType":"pat","country":"DE","uiLanguage":"de-DE"},"authTicket":{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEyODVlZGU0LTBjZWYtMTFlYy1hZTQ1LTAyNDJhYzExMDAwNSIsImZpcnN0TmFtZSI6IkrDtnJnIiwibGFzdE5hbWUiOiJTY2jDtm1lciIsImNvdW50cnkiOiJERSIsInJlZ2lvbiI6ImV1Iiwicm9sZSI6InBhdGllbnQiLCJlbWFpbCI6ImpvZXJnQGpvZXJnLXNjaG9lbWVyLmRlIiwiYyI6MSwicyI6ImxsdS5pb3MiLCJleHAiOjE2NDg4OTI1NTF9.jB4HwFyxf5OpEOH94bB9R78GKb334SB1oaiGIGDZWmw","expires":1648892551,"duration":3600000}}}
2022-04-02T08:42:31.269625+00:00 app[worker.1]: [info]: Logged in to LibreLink Up
2022-04-02T08:42:31.269700+00:00 app[worker.1]: [info]: getLibreLinkUpConnection: headers: {"User-Agent":"FreeStyle LibreLink Up Nightscout Uploader","Content-Type":"application/json","version":"4.1.1","product":"llu.ios","authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjEyODVlZGU0LTBjZWYtMTFlYy1hZTQ1LTAyNDJhYzExMDAwNSIsImZpcnN0TmFtZSI6IkrDtnJnIiwibGFzdE5hbWUiOiJTY2jDtm1lciIsImNvdW50cnkiOiJERSIsInJlZ2lvbiI6ImV1Iiwicm9sZSI6InBhdGllbnQiLCJlbWFpbCI6ImpvZXJnQGpvZXJnLXNjaG9lbWVyLmRlIiwiYyI6MSwicyI6ImxsdS5pb3MiLCJleHAiOjE2NDg4OTI1NTF9.jB4HwFyxf5OpEOH94bB9R78GKb334SB1oaiGIGDZWmw"}
2022-04-02T08:42:31.578051+00:00 app[worker.1]: [error]: {"message":"invalid or expired jwt"}

Any ideas?

Kind regards
Jörg

504 Gateway Time-out

Since this morning I'm getting 504 Gateway Time-out when synchronizing data to my nightscout instance.

[info]: Upload of 0 measurements to NightScout succeeded
npm notice 
npm notice New minor version of npm available! 8.12.1 -> 8.19.2
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.19.2>
npm notice Run `npm install -g [email protected]` to update!
npm notice 
npm ERR! path /usr/src/app
npm ERR! command failed
npm ERR! signal SIGTERM
npm ERR! command sh -c node index.js
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-09-24T09_29_54_139Z-debug-0.log
> [email protected] start
> node index.js
...
[info]: -> The following connection will be used: XXX XXX (Patient-ID: xxxxxxxxx)
[info]: Received blood glucose measurement items
[error]: "<html>\r\n<head><title>504 Gateway Time-out</title></head>\r\n<body>\r\n<center><h1>504 Gateway Time-out</h1></center>\r\n<hr><center>openresty</center>\r\n</body>\r\n</html>\r\n"

All Services run on a self-hosted docker container based on docker-compose.yaml. I'm using the xDrip+ App together with Nighscout as well and synchronizing data from XDrip+ -> Nightscout still works. I did not make any recent changes or update that could have caused this.

Do you have any idea or need any further logs that could help you?

EDIT: I build a new librelink-up container on a different machine and received the same error message.

npm log file

0 verbose cli /usr/local/bin/node /usr/local/bin/npm
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/usr/src/app/.npmrc Completed in 0ms
10 timing config:load:project Completed in 4ms
11 timing config:load:file:/root/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 12ms
19 timing npm:load:configload Completed in 13ms
20 timing npm:load:mkdirpcache Completed in 1ms
21 timing npm:load:mkdirplogs Completed in 1ms
22 verbose title npm start
23 verbose argv "start"
24 timing npm:load:setTitle Completed in 1ms
25 timing config:load:flatten Completed in 3ms
26 timing npm:load:display Completed in 4ms
27 verbose logfile logs-max:10 dir:/root/.npm/_logs
28 verbose logfile /root/.npm/_logs/2022-09-24T09_29_54_139Z-debug-0.log
29 timing npm:load:logFile Completed in 5ms
30 timing npm:load:timers Completed in 0ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 25ms
33 silly logfile done cleaning log files
34 http fetch GET 200 https://registry.npmjs.org/npm 729ms (cache updated)
35 http fetch GET 200 https://registry.npmjs.org/npm 763ms (cache updated)
36 timing command:run-script Completed in 275221ms
37 timing command:start Completed in 275224ms
38 notice
38 notice New minor version of npm available! 8.12.1 -> 8.19.2
38 notice Changelog: <https://github.com/npm/cli/releases/tag/v8.19.2>
38 notice Run `npm install -g [email protected]` to update!
38 notice
39 verbose stack Error: command failed
39 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:63:27)
39 verbose stack     at ChildProcess.emit (node:events:537:28)
39 verbose stack     at maybeClose (node:internal/child_process:1091:16)
39 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
40 verbose pkgid [email protected]
41 verbose cwd /usr/src/app
42 verbose Linux 5.15.0-46-generic
43 verbose node v18.5.0
44 verbose npm  v8.12.1
45 error path /usr/src/app
46 error command failed
47 error signal SIGTERM
48 error command sh -c node index.js
49 verbose exit 1
50 timing npm Completed in 275256ms
51 verbose code 1
52 error A complete log of this run can be found in:
52 error     /root/.npm/_logs/2022-09-24T09_29_54_139Z-debug-0.log

docker-compose.yaml

version: '3'

volumes:
  data:

services:
  db:
    image: mongo:latest
    restart: always
    volumes:
      - data:/data/db
    networks:
      - npm-net
    
  app:
    image: nightscout/cgm-remote-monitor:latest
    container_name: nightscout
    restart: always
    networks:
      - npm-net
    depends_on:
      - db
    environment:
      ### Variables for the container
      NODE_ENV: production
      TZ: Etc/UTC

      INSECURE_USE_HTTP: 'true'
      MONGO_CONNECTION: mongodb://db:27017/nightscout
      API_SECRET: xxxxxxxxxxxxxxx

      ENABLE: careportal basal dbsize rawbg iob maker bridge cob bwp cage iage sage boluscalc pushover treatmentnotify mmconnect loop pump profile food openaps bage alexa override cors

      AUTH_DEFAULT_ROLES: denied
      TIME_FORMAT: 24
      
      
  libre-link:
    image: timoschlueter/nightscout-librelink-up
    container_name: nightscout-libre-link
    restart: always
    environment:
      LINK_UP_USERNAME: xxxxxx
      LINK_UP_PASSWORD: xxxxxxxx
      LINK_UP_TIME_INTERVAL: 1
      LINK_UP_REGION: DE
      NIGHTSCOUT_URL: xxxxxx
      NIGHTSCOUT_API_TOKEN: xxxxxxx
      LOG_LEVEL: "info"


networks:
  npm-net:
    external: true

Process exited with status 0

hello
I am getting the values at 11 minute intervals.
I couldn't understand the errors it gave. it gives this error every time a value is loaded..What should I do?

log:

2022-12-27T20:52:38.840149+00:00 heroku[worker.1]: Process exited with status 0
2022-12-27T20:52:38.885052+00:00 heroku[worker.1]: State changed from up to crashed
2022-12-27T21:03:33.880472+00:00 heroku[worker.1]: State changed from crashed to starting
2022-12-27T21:03:36.811904+00:00 heroku[worker.1]: Starting process with command npm start
2022-12-27T21:03:37.433165+00:00 heroku[worker.1]: State changed from starting to up
2022-12-27T21:03:39.490209+00:00 app[worker.1]:
2022-12-27T21:03:39.490231+00:00 app[worker.1]: > [email protected] start
2022-12-27T21:03:39.490231+00:00 app[worker.1]: > node index.js
2022-12-27T21:03:39.490232+00:00 app[worker.1]:
2022-12-27T21:03:39.635782+00:00 app[worker.1]: [info]: no authTicket.expires
2022-12-27T21:03:39.636195+00:00 app[worker.1]: [info]: renew token
2022-12-27T21:03:40.309196+00:00 app[worker.1]: [info]: Logged in to LibreLink Up
2022-12-27T21:03:40.708399+00:00 app[worker.1]: [info]: Found 1 LibreLink Up connection.

Add device name to entries

The "device" attribute is not yet filled. Maybe we can read sensor information from the LibreLink Up API. If not, we should at least fill the "device" attribute with something like freestyle-libre

Upload to NightScout failed

Hello, Sute I am doing something bad, but I dont know... If someone can help me.....

yml of the nightscout-librelink-up is:

version: '3.3'
#version: '3.3'

services:
nightscout-libre-link:
image: timoschlueter/nightscout-librelink-up
container_name: nightscout-libre-link
environment:
LINK_UP_USERNAME: "USERNAME_LIBRELINK_UP"
LINK_UP_PASSWORD: "PASSWORD_LIBRELINK_UP"
NIGHTSCOUT_DISABLE_HTTPS: "true"
LINK_UP_TIME_INTERVAL: "1"
LINK_UP_REGION: "EU"
NIGHTSCOUT_URL: "192.168.0.116" -> LOCAL IP
NIGHTSCOUT_API_TOKEN: "123456789123456789"
LOG_LEVEL: "info"

############
############
############
############

the yml of the /nightscout-docker
from the web: nightscout-docker

broker:
image: 'prologic/mosquitto:latest'
ports:
- '1883:1883'
database:
image: 'tutum/mongodb:latest'
environment:
- MONGODB_PASS=123456789123456789

Uncomment if you want to expose the MongoDB port directly

If you're using the API interface (highly recommended) then you can

safely leave this commented out

ports:
- '27017:27017'

nightscout:
image: 'nightscout/cgm-remote-monitor-development:latest'
environment:
- API_SECRET=123456789123456789
- 'MONGO_CONNECTION=mongodb://admin:123456789123456789@database/admin'
- 'MQTT_MONITOR=mqtt://123456789123456789@broker'
- PORT=1337
links:
- broker
- database
ports:
- '1337:1337'

############
############
############

The log is:

[info]: Starting cron schedule: */5 * * * *
[info]: no authTicket.expires
[info]: renew token
[info]: Logged in to LibreLink Up
[info]: Found 1 LibreLink Up connection.
[info]: -> The following connection will be used: NAMEXXXx (Patient-ID: XXXXXXXX)
[error]: self-signed certificate
[info]: Trying to upload 44 glucose measurement items to Nightscout
[error]: self-signed certificate
[error]: Upload to NightScout failed

Libre LinkUp maintenance/update breaks app connection.

Hello :)

after an mainenance windnow tonight (4.4./5.4.2023) breaks the webservice requests:

[email protected] start
npx ts-node --transpile-only src/index.ts
[info]: Starting cron schedule: */2 * * * *
[info]: renew token
[info]: Logged in to LibreLink Up
[error]: {"message":"invalid or expired jwt"}
[error]: getting libreLinkUpConnection: Cannot read properties of undefined (reading 'data')
[info]: renew token
[info]: Logged in to LibreLink Up
[error]: {"message":"invalid or expired jwt"}
[error]: getting libreLinkUpConnection: Cannot read properties of undefined (reading 'data')
[info]: renew token
[info]: Logged in to LibreLink Up
[error]: {"message":"invalid or expired jwt"}
[error]: getting libreLinkUpConnection: Cannot read properties of undefined (reading 'data')
[info]: renew token
[info]: Logged in to LibreLink Up
[error]: {"message":"invalid or expired jwt"}
[error]: getting libreLinkUpConnection: Cannot read properties of undefined (reading 'data')
[info]: renew token
[info]: Logged in to LibreLink Up
[error]: {"message":"invalid or expired jwt"}
[error]: getting libreLinkUpConnection: Cannot read properties of undefined (reading 'data')

Libre LinkUp App works well. So the data is available.

Thanks
Frank

No Data is being uploaded to Nightscout

After setting everything up, this log appears, no data is being uploaded to Nightscout.

Has anybody got an Idea what to do?

2022-08-31T08:10:01.281280+00:00 app[worker.1]: [info]: -> The following connection will be used: Fabian Birkert (Patient-ID: 3cd57fc6-***********-8126-02d09c370615)
2022-08-31T08:10:06.514459+00:00 app[worker.1]: [error]: {"status":401,"message":"Unauthorized","description":"Invalid/Missing"}
2022-08-31T08:10:06.514621+00:00 app[worker.1]: [info]: Upload of 139 measurements to NightScout succeeded

Cannot read properties of undefined (reading 'pop')

If you setup brand new nightscout server (I mean there is no data there) - you will have this error

nightscout-libre-link    | [error]: {"status":401,"message":"Unauthorized","description":"Invalid/Missing"}
nightscout-libre-link    | [error]: Error getting glucose measurements Cannot read properties of undefined (reading 'pop')

Stuck at LibreLink Up

@timoschlueter
I have a working nightscout with both heroku and azure, but cannot upload values from Libreview using your program.
When I try to use this, via heroku it is saying that the free dynos are no longer supported. I would be fine paying for the eco subscription, but I don't see a way to change the web or worker resources. Is it possible to 1.) change the resources for the subscription or 2.) integrate this as a plugin directly with Nightscout?
I am so close to making this work and I believe this will be the last step. Thanks in advance.

Docker container for Raspberry Pi

Hi Timo,

do you think it is possible to create the Docker container for arm64 in addition to the amd64 platform? Then you could run the whole thing very energy-efficiently on a Raspberry Pi.

Many greets
Dirk

integrate with Nightscout core

Howdy, I've been working on a centralized plugin for cloud-to-cloud synchronization plugins with Nightscout. This plugin is working great for people and I think it would be even better if people could run it inside Nightscout.
My new library for generalizing cloud connections with Nightscout is nightscout-connect and includes a prototype driver based on your code here.
https://github.com/bewest/nightscout-connect

Wants to say thanks for all the work and see if you might be interested in combining efforts.

Import trend/direction from LibreLink Up

The plugin does not import trend/direction information yet. The information is available via LibraLink Up, therefore we should import the values. There probably needs to be a mapping of some sort.

Nightscout accepts the following values:

Value Symbol
NONE
TripleUp
DoubleUp
SingleUp
FortyFiveUp
Flat
FortyFiveDown
SingleDown
DoubleDown
TripleDown
NOT COMPUTABLE -
RATE OUT OF RANGE

No data in Nightscout?

I just got a Libre 3 sensor and I'm trying to figure this Nightscout thing out. I've set up a Nightscout to eventually get my readings on my Garmin watch. I've created a Mongodb that seems to work as intended and the Nightscout through Railway. The thing is that I don't get any readings in Nightscout and I can't figure out what the problem is. I can't see any errors in the logs.

Upload seems fine but I don't see any values in Nightscout?

Deploy log

[email protected] start
node index.js
[info]: no authTicket.expires
[info]: renew token
[info]: Logged in to LibreLink Up
[info]: Found 1 LibreLink Up connection.
[info]: -> The following connection will be used: Kim XXX (Patient-ID: 184cdccd-xxx-xxxx-xxxx-0242xxxx0007)
[info]: Trying to upload 125 glucose measurement items to Nightscout
[info]: Upload of 125 measurements to Nightscout succeeded

Edit: I now finally got it to work. I deleted NIGHTSCOUT_DISABLE_HTTPS and SINGLE_SHOT as variables.

Thank you Timo for the tool, much appreciated.

Filter?

Wondering is there any possibility to add any filter.
Type average of 5 minutes which is then sent to Nightscout?

Cannot read properties of undefined (reading 'dateString')

Hi,

after setting up Nightscout via Heroku (successfully). I tried to set up libre link up, also via Heroku. But unfortunatily I receive always the following error.

2022-05-01T18:20:00.514429+00:00 app[worker.1]: [info]: no authTicket.expires 2022-05-01T18:20:00.514465+00:00 app[worker.1]: [info]: renew token 2022-05-01T18:20:01.164961+00:00 app[worker.1]: [info]: Logged in to LibreLink Up 2022-05-01T18:20:01.672330+00:00 app[worker.1]: [info]: Found 1 LibreLink Up connection. 2022-05-01T18:20:01.672344+00:00 app[worker.1]: [info]: -> The following connection will be used: XXXXXX (Patient-ID: ) 2022-05-01T18:20:02.254026+00:00 app[worker.1]: [info]: Received blood glucose measurement items 2022-05-01T18:20:02.394919+00:00 app[worker.1]: [error]: Error getting glucose measurements Cannot read properties of undefined (reading 'dateString')

Floating average

Hi me and my daughter would love to have a feature with floating average. You can have a variable on how many of the most recent values are calculated 2-6 maybe?

Libre is a bit sensitive if you lie on it, it quickly dips down 2-3 mmol and low alarms come unnecessarily.

Thanks

Cross Sync with Mysugr and others

The basic idea is interesting.
Some people prefer a nice App like mysugr that collects a few more data pieces.
Some doctors prefer Libreview, some other systems.
Are you intrested in creating a solution that pulls data from multiple sources, combines them, denoises them and uploads the merged data to connected services?
This would make it a lot easier to maintain data for the end user

Upload CGM Sensor changes to Nightscout

While looking at the Nightscout API I noticed that it is possible to log CGM sensor changes in the Nightscout GUI.
Since the LibreLink Up API offers Sensor data, it might be possible to upload this data into Nightscout.

Not yet working on it, but I will look into this in the future.

Error fetching the last entry date - TypeError: response.data.pop is not a function

I have successfully run the script for a few days, but now it stopped working. The log has an error while fetching the date information on the last entry:

2023-01-24T03:03:50.799022396Z stdout F [info]: Starting cron schedule: */1 * * * *
2023-01-24T03:04:00.916361167Z stdout F [info]: renew token
2023-01-24T03:04:02.395944038Z stdout F [info]: Logged in to LibreLink Up
2023-01-24T03:04:02.566096874Z stdout F [info]: -> The following connection will be used: First Last (Patient-ID: sssss-ssss-ssss-ssss-ssssssssssss)
2023-01-24T03:04:02.795578284Z stderr F /usr/src/app/src/index.ts:277
2023-01-24T03:04:02.795625673Z stderr F     return new Date(response.data.pop().dateString);
2023-01-24T03:04:02.795632456Z stderr F                                   ^
2023-01-24T03:04:02.799240445Z stderr F TypeError: response.data.pop is not a function
2023-01-24T03:04:02.799269675Z stderr F     at lastEntryDate (/usr/src/app/src/index.ts:277:35)
2023-01-24T03:04:02.799274363Z stderr F     at processTicksAndRejections (node:internal/process/task_queues:95:5)
2023-01-24T03:04:02.799277397Z stderr F     at async createFormattedMeasurements (/usr/src/app/src/index.ts:285:23)
2023-01-24T03:04:02.799280563Z stderr F     at async uploadToNightScout (/usr/src/app/src/index.ts:317:44)
2023-01-24T03:04:02.799283531Z stderr F     at async main (/usr/src/app/src/index.ts:152:5)
2023-01-24T03:04:03.797987551Z stderr F npm notice
2023-01-24T03:04:03.797667648Z stderr F npm notice Run `npm install -g [email protected]` to update!
2023-01-24T03:04:03.797664875Z stderr F npm notice Changelog: <https://github.com/npm/cli/releases/tag/v9.3.1>;
2023-01-24T03:04:03.797660378Z stderr F npm notice New major version of npm available! 8.19.2 -> 9.3.1
2023-01-24T03:04:03.797618615Z stderr F npm notice

Libre LinkUp app still shows the data correctly, so. apparently the Libre side is working.

Nightscout upload failed

[ image deleted as it had sensitive info ]
Nightscout upload fails. Just bought a server from https://www.t1pal.com/ and entered upload url and upload secret and it just fails. Any suggestions? Api secret and host value seems to be fine.

[error]: No LibreLink Up connection found

Hello I use the docker compose:

version: '3.3'
services:
nightscout-libre-link:
image: timoschlueter/nightscout-librelink-up
container_name: nightscout-libre-link
environment:
LINK_UP_USERNAME: "MYEMAIL"
LINK_UP_PASSWORD: "MYPASSWORD_LIBREVIEW"
LINK_UP_TIME_INTERVAL: "5"
LINK_UP_REGION: "EU"
NIGHTSCOUT_URL: "localhost"
NIGHTSCOUT_API_TOKEN: "123456789123456789"
LOG_LEVEL: "info"

And the error on logs is :

[email protected] start
node index.js

[info]: Starting cron schedule: */5 * * * *
[info]: no authTicket.expires
[info]: renew token
[info]: Logged in to LibreLink Up
[error]: No LibreLink Up connection found

Can someone help me?

Lot of thanks.

Error getting LibreLinkUp reading

After some update on libre link servers that happened on August 3 i am getting the error bellow once very 2-3 readings:

`
2022-08-03T13:52:00.501607+00:00 app[worker.1]: [info]: Found 1 LibreLink Up connection.
2022-08-03T13:52:00.501662+00:00 app[worker.1]: [info]: -> The following connection will be used: Alexandru Mihai (Patient-ID: XXX)
2022-08-03T13:52:00.674858+00:00 app[worker.1]: [info]: Received blood glucose measurement items

2022-08-03T13:52:31.138367+00:00 app[worker.1]: [error]: "\n\t\n\t \n\t\t<meta name="viewport" content="width=device-width, initial-scale=1">\n\t\t<meta charset="utf-8">\n\t\t<title>Application Error</title>\n\t\t<style media="screen">\n\t\t html,body,iframe {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t }\n\t\t html,body {\n\t\t\theight: 100%;\n\t\t\toverflow: hidden;\n\t\t }\n\t\t iframe {\n\t\t\twidth: 100%;\n\t\t\theight: 100%;\n\t\t\tborder: 0;\n\t\t }\n\t\t</style>\n\t \n\t \n\t\t<iframe src="//www.herokucdn.com/error-pages/application-error.html"></iframe>\n\t \n\t"
2022-08-03T13:52:31.138397+00:00 app[worker.1]: [info]: Upload of 0 measurements to NightScout succeeded

2022-08-03T13:53:00.576644+00:00 app[worker.1]: [info]: Found 1 LibreLink Up connection.
2022-08-03T13:53:00.576785+00:00 app[worker.1]: [info]: -> The following connection will be used: Alexandru Mihai (Patient-ID: XXX)
2022-08-03T13:53:00.742464+00:00 app[worker.1]: [info]: Received blood glucose measurement items
2022-08-03T13:53:01.280426+00:00 app[worker.1]: [info]: Upload of 1 measurements to NightScout succeeded
`

Calendar Events

Would it be possible to integrate something like the xDrip4iOS "Calendar Events" feature?
Especially for Apple Watch users, the best way to always have the latest blood glucose readings on the watch face is the calendar widget. Due to the lack of Libre3 support, it is currently only possible to configure xDrip as a follower so that it loads the data from nightscout and creates the "calendar event". It would be great if nightscout-librelink-up could take over this task by acting as a caldav client.

Data always missing last few measurements - method to get latest data as well?

First off I'm really impressed by this work.

I would like to adapt the code to display current measurements on a fitness band for Libre 3. However, when I run the code the result of the "/graph" GET-request is always missing the last few measurements. In other projects I saw people using "/glucoseHistory" but this somehow leads to error now.

Have you get any idea how to also fetch the latest data?

Thanks alot

Invalid credentials / 401

Hi, thank you very much for your project.

I used some parts in a private system (with iobroker) to get the glucose data of my son. Since yesterday evening, I cannot login any more. It seems to be a 401 response ("Request failed with status code 401"), I've already created another user to watch, but still the same. The login method is (nearly) identical to yours.

I just want to know, if the error/problem is on my side, or did Abbott changed anything? As I am using an iPhone with LibreLinkUp (where both accounts are working without any problems) I cannot watch the (encrypted) network traffic.

Change country

Hello everyone,

I live in Germany.

Thus "LINK_UP_REGION" is set to DE.

If I go to Italy, for example, do I have to change "LINK_UP_REGION" to EU?

Thanks

[error]: {"message":"invalid or expired jwt"}

Hello,

Dose any of you have this problem?

[error]: {"message":"invalid or expired jwt"}
[error]: getting libreLinkUpConnection: Cannot read properties of undefined (reading 'data')

Azure instead of Heroku

@timoschlueter Hello planning to move to Azure/Cosmo DB, Can you tell how to leverage ur code to read libre data and post it into Azure? Deploying to Heroku was very easy with a touch of a button/providing the env vars. How do I execute the same with now Azure bring the target instead of Heroku? Sorry not a tech savvy so your help will
mean a lot to my family. Thanks

No LibreLink Up connection found

I am running into an issue where no link up connection is detected. I believe that is login itself was successful.

I am based in the US and I using the Libre 3 app on Android to upload.

Any suggestions on what else to check or to explore are greatly appeciated.

2022-08-10T04:15:00.618200+00:00 app[worker.1]: [info]: Logged in to LibreLink Up
2022-08-10T04:15:00.641332+00:00 app[worker.1]: [error]: No LibreLink Up connection found

Using dedicated client and implement only bridge functionality for nightscout

Hi @timoschlueter,

Thanks for your excellent work and giving people the opportunity to feed there nightscout instance with Libre 3 data.

For this simple purpose I have also implemented a basic client to retrieve libre 3 data: https://github.com/DiaKEM/libre-link-up-api-client

Maybe it is an option for you to reuse it here and implement only the Middleware to pass data to nightscout to reduce the needed code. It is only an idea 😉.

Viele Grüße 😀

Selçuk

Nighscout Port 443/80

Is it possible to change the port numbers of the nightscout connection ?
I have nightscout running locally on a synology nas in docker port 80 and 443 are occupied by the nginx server
1337 is the port i use for web interface is it possible to use other ports to upload the data ?
i am new to this so forgive me, as i dont not fully understand everything.
my ultimate goal is to obtain the glucose data in home assistant so at night i can make some automations.

Gr.

Current Measurement doesnt show in nightscout

I have configured an instance of nightscout and this uploader since 2 weeks now. For the first week everything ran fine. The uploader was pushing the current measurement and the backfilled data to nightscout every minute.

After the first week I noticed during one day. that the dots would not appear every minute anymore. The uploader was still logging that it was pushing ~141 Measurements to Nightscout without fail. Nightscout would also not throw any errors but I can only see a dot every five minutes which should just be the backlogged data. Tha nightscout database shows the same.

This porblem was not solved by deleting the docker images of the uploader and nightscout and pulling new ones.

My Graph now looks like this:
Uploading 2022-03-21 06_44_14-97 +1 →.png…

I also have a simple ui script using the exact same code thatjust displays the number every minute which is running fine. So my asumption is that nightscout is not correctly saving the data. Do you have any idea if there is a limit of how many uploads a nightscout instance can handle at one time and the uploaded measurements get cut of with only the last few saving?

Many Thanks

Handling API timeouts

While porting this application to Go/Golang in order to use it as a input-plugin for Telegraf I noticed that there are periodically timeouts on the /connections endpoint of the LLU backend. Timeouts are not yet handled in this application and might have something to do with the errors in the logs as described in #58 and #28.

TypeError: Cannot read properties of null (reading 'FactoryTimestamp')

Hi, I have the following issue, right after starting the docker-container. It seems to be connected to nightscout and the librelink cloud correctly.

The error might occure because I have no recent blood glucose values in the libre cloud. (But I plan using it in the future, since I have to switch from libre2 to libre3).

nightscout-libre-link_1  | 
nightscout-libre-link_1  | > [email protected] start
nightscout-libre-link_1  | > node index.js
nightscout-libre-link_1  | 
nightscout-libre-link_1  | 2022-03-18T17:41:04.531Z [info]: Started
nightscout-libre-link_1  | 2022-03-18T17:42:07.692Z [info]: Logged in to LibreLink Up
nightscout-libre-link_1  | 2022-03-18T17:42:15.168Z [info]: Found 1 LibreLink Up connection.
nightscout-libre-link_1  | 2022-03-18T17:42:15.169Z [info]: -> The following connection will be used: XXX (Patient-ID: XXXXXX-XXXX-XXXXX-XXXX-XXXXXXXXXXXX)
nightscout-libre-link_1  | 2022-03-18T17:36:15.329Z [info]: Received blood glucose measurement                     
nightscout-libre-link_1  | /usr/src/app/index.js:186                                                               
nightscout-libre-link_1  |     const measurementDate = getUtcDateFromString(glucoseMeasurement.FactoryTimestamp);  
nightscout-libre-link_1  |                                                                     ^                   
nightscout-libre-link_1  |                                                                                         
nightscout-libre-link_1  | TypeError: Cannot read properties of null (reading 'FactoryTimestamp')                  
nightscout-libre-link_1  |     at uploadToNightscout (/usr/src/app/index.js:186:69)                                
nightscout-libre-link_1  |     at getGlucoseMeasurement (/usr/src/app/index.js:116:9)                              
nightscout-libre-link_1  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)               
nightscout-libre-link_1  |                                                                                         
nightscout-libre-link_1  | Node.js v17.7.1

connection problems

kann mir jemand bei meinen Problem helfen ???
ich bekomme folgende Meldung.
Danke.

[email protected] start
node index.js

[info]: Starting cron schedule: */1 * * * *
[info]: no authTicket.expires
[info]: renew token
[info]: Logged in to LibreLink Up
[error]: getting libreLinkUpConnection: Cannot read properties of undefined (reading 'token')

error code=H10 desc="App crashed"

Hi Timo,

First, thanks for having posted this script.

I have deployed it on Heroku, double checked variables, hashed Nightscout password as requested, but I keep on logging the following error:

2022-06-12T14:50:00.688125+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=POST path="/api/v1/entries" host=.herokuapp.com request_id=d2e00448-58fa-4726-abd4-7fce16876b3a fwd="54.228.36.199" dyno= connect= service= status=503 bytes= protocol=https

Any idea ?

Thanks

Andrea

last glucose dosnt read

Hello, I notice that the last glucose measure, the value of NOW, don't appear, the postbox glucose measures take 20 minutes of delay.
It is right?

Thanks.

Support for mmol/L units

Right now, the upload uses the ".Value"-Field from the response object. This is bad, since the value might either be in mmol/L or mg/dL, depending on the users LibreLink setup.

Fortunately, the value also returns an attribute called ".ValueInMgPerDl". This is always mg/dL, no matter what the use has configured. Therefore we should switch to this attribute.

[CRITICAL] No measurements for German users

As of 13 July, Abbott changed the API-Endpoint for LibreLink Up users in Germany.
We have to implement support for the new Endpoint, which can be set through the LINK_UP_REGION environment variable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.