Skip to content

Commit

Permalink
Merge pull request #36 from Joerg-Schoemer/main
Browse files Browse the repository at this point in the history
add LINK_UP_TIME_INTERVAL to environment
  • Loading branch information
timoschlueter authored Apr 7, 2022
2 parents 440d748 + fa2befc commit 5aac65e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 21 deletions.
57 changes: 38 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
# Nightscout LibreLink Up Uploader/Sidecar
Simple Script written in JavaScript (Node) that uploads CGM readings from LibreLink Up to Nightscout. The upload happens every minute and should work with at least Freestyle Libre 2 and Libre 3 CGM sensors.

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/timoschlueter/nightscout-librelink-up)
Simple Script written in JavaScript (Node) 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](https://www.herokucdn.com/deploy/button.svg)][heroku]

## 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 ||
|NIGHTSCOUT_URL| Hostname of the Nightscout instance (without https://) | nightscout.yourdomain.com |X|
|NIGHTSCOUT_API_TOKEN| SHA1 Hash of Nightscout access token | 162f14de46149447c3338a8286223de407e3b2fa |X|
|LOG_LEVEL| The setting of verbosity for logging should be info or debug | info |X|
| Variable | Description | Example | Required |
|-----------------------|---------------------------------------------------------------------------------------------------------|------------------------------------------|----------|
| LINK_UP_TIME_INTERVAL | The time interval of requesting values from libre link up | 5 | X |
| 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 | |
| NIGHTSCOUT_URL | Hostname of the Nightscout instance (without https://) | nightscout.yourdomain.com | X |
| NIGHTSCOUT_API_TOKEN | SHA1 Hash of Nightscout access token | 162f14de46149447c3338a8286223de407e3b2fa | X |
| LOG_LEVEL | The setting of verbosity for logging, should be one of info or debug | info | X |

## Usage

There are different options for using this script.

### Variant 1: On Heroku

- Click [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/timoschlueter/nightscout-librelink-up)
- Click on [![Deploy](https://www.herokucdn.com/deploy/button.svg)][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**
Expand All @@ -32,33 +37,41 @@ The installation process can be startetd by running `npm install` in the root di

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

```
```shell
#!/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:

```
```shell
docker run -e LINK_UP_USERNAME="[email protected]" \
-e LINK_UP_PASSWORD="mypassword" \
-e NIGHTSCOUT_URL="nightscout.yourdomain.com" \
-e NIGHTSCOUT_API_TOKEN="librelinku-123456789abcde" timoschlueter/nightscout-librelink-up
-e LINK_UP_PASSWORD="mypassword" \
-e LINK_UP_TIME_INTERVAL="5" \
-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:

```
If you are already using a dockerized Nightscout instance, this image can be easily added to your existing
docker-compose file:

```yaml
version: '3.7'

services:
Expand All @@ -68,9 +81,15 @@ services:
environment:
LINK_UP_USERNAME: "[email protected]"
LINK_UP_PASSWORD: "mypassword"
LINK_UP_TIME_INTERVAL: "5"
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.
- **Integration into Nightscout**: I have not yet looked into the plugin architecture of Nightscout. Maybe this should
be converted into a plugin.
[heroku]: https://heroku.com/deploy?template=https://github.com/timoschlueter/nightscout-librelink-up
5 changes: 5 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
"description": "The log-level to use.",
"value": "info",
"required": true
},
"LINK_UP_TIME_INTERVAL": {
"description": "The time interval (in minutes) in which the values should be retrieved from Libre Link Up",
"value": "5",
"required": true
}
}
}
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const logger = createLogger({
logFormat
),
transports: [
new transports.Console({level: process.env.LOG_LEVEL}),
new transports.Console({level: process.env.LOG_LEVEL || "info"}),
]
});

Expand Down Expand Up @@ -71,7 +71,7 @@ const nightScoutHttpHeaders = {
"Content-Type": "application/json",
}

const schedule = "*/5 * * * *";
const schedule = "*/" + (process.env.LINK_UP_TIME_INTERVAL || 5) + " * * * *";
logger.info("Starting cron schedule: " + schedule)
cron.schedule(schedule, () => {main();}, {});

Expand Down

0 comments on commit 5aac65e

Please sign in to comment.