Skip to content

Commit e84040f

Browse files
Merge pull request #142 from timoschlueter/release/2.6.1
Release 2.6.1
2 parents beb0566 + 50b3f0c commit e84040f

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The script takes the following environment variables
2424
| NIGHTSCOUT_DEVICE_NAME | Sets the device name used in Nightscout | nightscout-librelink-up | |
2525
| LOG_LEVEL | The setting of verbosity for logging, should be one of info or debug | info | |
2626
| SINGLE_SHOT | Disables the scheduler and runs the script just once | true | |
27+
| ALL_DATA | Upload 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 | |
2728

2829
## Usage
2930

@@ -34,7 +35,7 @@ There are different options for using this script.
3435
- Click on [![Deploy](https://www.herokucdn.com/deploy/button.svg)][heroku]
3536
- Login to Heroku if not already happened
3637
- Provide proper values for the `environment variables`
37-
- **Important: make sure that yor Nightscout API token is hashed with SHA1**
38+
- **Important: make sure that yor Nightscout API token is [hashed with SHA1](#hashing-api-token)**
3839
- Click `Deploy` to deploy the app
3940

4041
### Variant 2: Local
@@ -50,7 +51,7 @@ export LINK_UP_PASSWORD="mypassword"
5051
export LINK_UP_TIME_INTERVAL="5"
5152
export NIGHTSCOUT_URL="nightscout.yourdomain.com"
5253
# use `shasum` instead of `sha1sum` on Mac
53-
export NIGHTSCOUT_API_TOKEN=$(echo -n "foo-bar-baz" | sha1sum | cut -d ' ' -f 1)
54+
export NIGHTSCOUT_API_TOKEN=$(echo -n "librelinku-123456789abcde" | sha1sum | cut -d ' ' -f 1)
5455
export LOG_LEVEL="info"
5556

5657
npm start
@@ -68,7 +69,7 @@ docker run -e LINK_UP_USERNAME="[email protected]" \
6869
-e LINK_UP_TIME_INTERVAL="5" \
6970
-e LINK_UP_REGION="EU" \
7071
-e NIGHTSCOUT_URL="nightscout.yourdomain.com" \
71-
-e NIGHTSCOUT_API_TOKEN="librelinku-123456789abcde" \
72+
-e NIGHTSCOUT_API_TOKEN=$(echo -n "librelinku-123456789abcde" | sha1sum | cut -d ' ' -f 1) \
7273
-e LOG_LEVEL="info" \
7374
timoschlueter/nightscout-librelink-up
7475
```
@@ -91,10 +92,28 @@ services:
9192
LINK_UP_TIME_INTERVAL: "5"
9293
LINK_UP_REGION: "DE"
9394
NIGHTSCOUT_URL: "nightscout.yourdomain.com"
94-
NIGHTSCOUT_API_TOKEN: "librelinku-123456789abcde"
95+
NIGHTSCOUT_API_TOKEN: "14c779d01a34ad1337ab59c2168e31b141eb2de6"
9596
LOG_LEVEL: "info"
9697
```
9798
99+
### Hashing API token
100+
101+
`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`.
102+
103+
Obtain your hash with
104+
105+
```shell
106+
echo -n "librelinku-123456789abcde" | sha1sum | cut -d ' ' -f 1
107+
```
108+
(use `shasum` instead of `sha1sum` on Mac)
109+
110+
which will print the hash (40 characters in length):
111+
```
112+
14c779d01a34ad1337ab59c2168e31b141eb2de6
113+
```
114+
115+
You might also use an online tool to generate your hash, e.g. https://codebeautify.org/sha1-hash-generator
116+
98117
## ToDo
99118

100119
- **Integration into Nightscout**: I have not yet looked into the plugin architecture of Nightscout. Maybe this should

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nightscout-librelink-up",
3-
"version": "2.6.0",
3+
"version": "2.6.1",
44
"description": "Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout",
55
"main": "dist/index.js",
66
"scripts": {

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function readConfig()
5858

5959
logLevel: process.env.LOG_LEVEL || 'info',
6060
singleShot: process.env.SINGLE_SHOT === 'true',
61+
allData: process.env.ALL_DATA === 'true',
6162

6263
nightscoutApiV3: process.env.NIGHTSCOUT_API_V3 === 'true',
6364
nightscoutDisableHttps: process.env.NIGHTSCOUT_DISABLE_HTTPS === 'true',

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ export async function createFormattedMeasurements(measurementData: GraphData): P
285285
const formattedMeasurements: Entry[] = [];
286286
const glucoseMeasurement = measurementData.connection.glucoseMeasurement;
287287
const measurementDate = getUtcDateFromString(glucoseMeasurement.FactoryTimestamp);
288-
const lastEntry = await nightscoutClient.lastEntry();
289-
288+
const lastEntry = config.allData ? null : await nightscoutClient.lastEntry();
290289
// Add the most recent measurement first
291290
if (lastEntry === null || measurementDate > lastEntry.date)
292291
{

0 commit comments

Comments
 (0)