timoschlueter/nightscout-librelink-up

By timoschlueter

Updated 4 months ago

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

Image
Integration & delivery
4

100K+

timoschlueter/nightscout-librelink-up repository overview

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 to DigitalOcean Deploy to Heroku Deploy to Render

Configuration

The script takes the following environment variables

VariableDescriptionExampleRequired
LINK_UP_USERNAMELibreLink Up Login Email[email protected]X
LINK_UP_PASSWORDLibreLink Up Login PasswordmypasswordX
LINK_UP_CONNECTIONLibreLink Up Patient-ID. Can be received from the console output if multiple connections are available.123456abc-abcd-efgh-7891def
LINK_UP_TIME_INTERVALThe time interval of requesting values from libre link up5
LINK_UP_REGIONYour region. Used to determine the correct LibreLinkUp service (Possible values: AE, AP, AU, CA, DE, EU, EU2, FR, JP, US, LA, RU, CN)EU
LINK_UP_VERSIONLibreLink Up App Version. This may need to be updated if you are using a newer version of the LibreLink Up App4.16.0
NIGHTSCOUT_URLHostname of the Nightscout instance (without https://)nightscout.yourdomain.comX
NIGHTSCOUT_API_TOKENSHA1 Hash of Nightscout access token162f14de46149447c3338a8286223de407e3b2faX
NIGHTSCOUT_DISABLE_HTTPSDisables the HTTPS requirement for Nightscout URLstrue
NIGHTSCOUT_DEVICE_NAMESets the device name used in Nightscoutnightscout-librelink-up
LOG_LEVELThe setting of verbosity for logging, should be one of info or debuginfo
SINGLE_SHOTDisables the scheduler and runs the script just oncetrue
ALL_DATAUpload all available data from LibreLink Up instead of just data newer than last upload. LibreLinkUp sometimes lags behind in reporting recent historical data, so it is advised to run the script with ALL_DATA set to true at least once a day.true

Usage

There are different options for using this script.

Variant 1: On Digital Ocean App Platform
Variant 2: On Heroku
  • Click on Deploy to Heroku
  • 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 3: On Render
  • Click on Deploy to Render
  • Login to Render 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 Background Worker to deploy the app
Variant 4: 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 "librelinku-123456789abcde" | sha1sum | cut -d ' ' -f 1)
export LOG_LEVEL="info"

npm start

Execute the script and check the console output.

Variant 5: 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=$(echo -n "librelinku-123456789abcde" | sha1sum | cut -d ' ' -f 1) \
           -e LOG_LEVEL="info" \
           timoschlueter/nightscout-librelink-up
Variant 6: 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: "14c779d01a34ad1337ab59c2168e31b141eb2de6"
      LOG_LEVEL: "info"
Hashing API token

NIGHTSCOUT_API_TOKEN must be a SHA1 hash of an Access Token from Nightscout (Add new subject first in Nightscout's Admin Tools if required), e.g. your Access Token for a subject named LibreLinkUp might be librelinku-123456789abcde.

Obtain your hash with

echo -n "librelinku-123456789abcde" | sha1sum | cut -d ' ' -f 1

(use shasum instead of sha1sum on Mac)

which will print the hash (40 characters in length):

14c779d01a34ad1337ab59c2168e31b141eb2de6

You might also use an online tool to generate your hash, e.g. https://codebeautify.org/sha1-hash-generator

If you enjoy using this project and would like to support its ongoing development, I would be truly grateful. You can help keep things moving forward by becoming a GitHub sponsor or by using one of the referral links for the hosting providers below.

Your support means a lot — thank you!

DigitalOcean Referral Badge

Tag summary

Content type

Image

Digest

sha256:258d6cecc

Size

70.9 MB

Last updated

4 months ago

docker pull timoschlueter/nightscout-librelink-up:dev