Skip to content

Commit

Permalink
Merge pull request #142 from timoschlueter/release/2.6.1
Browse files Browse the repository at this point in the history
Release 2.6.1
  • Loading branch information
timoschlueter authored May 27, 2024
2 parents beb0566 + 50b3f0c commit e84040f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The script takes the following environment variables
| 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 | |
| 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 | |

## Usage

Expand All @@ -34,7 +35,7 @@ There are different options for using this script.
- 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**
- **Important: make sure that yor Nightscout API token is [hashed with SHA1](#hashing-api-token)**
- Click `Deploy` to deploy the app

### Variant 2: Local
Expand All @@ -50,7 +51,7 @@ 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 NIGHTSCOUT_API_TOKEN=$(echo -n "librelinku-123456789abcde" | sha1sum | cut -d ' ' -f 1)
export LOG_LEVEL="info"

npm start
Expand All @@ -68,7 +69,7 @@ docker run -e LINK_UP_USERNAME="[email protected]" \
-e LINK_UP_TIME_INTERVAL="5" \
-e LINK_UP_REGION="EU" \
-e NIGHTSCOUT_URL="nightscout.yourdomain.com" \
-e NIGHTSCOUT_API_TOKEN="librelinku-123456789abcde" \
-e NIGHTSCOUT_API_TOKEN=$(echo -n "librelinku-123456789abcde" | sha1sum | cut -d ' ' -f 1) \
-e LOG_LEVEL="info" \
timoschlueter/nightscout-librelink-up
```
Expand All @@ -91,10 +92,28 @@ services:
LINK_UP_TIME_INTERVAL: "5"
LINK_UP_REGION: "DE"
NIGHTSCOUT_URL: "nightscout.yourdomain.com"
NIGHTSCOUT_API_TOKEN: "librelinku-123456789abcde"
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

```shell
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

## ToDo

- **Integration into Nightscout**: I have not yet looked into the plugin architecture of Nightscout. Maybe this should
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nightscout-librelink-up",
"version": "2.6.0",
"version": "2.6.1",
"description": "Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout",
"main": "dist/index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function readConfig()

logLevel: process.env.LOG_LEVEL || 'info',
singleShot: process.env.SINGLE_SHOT === 'true',
allData: process.env.ALL_DATA === 'true',

nightscoutApiV3: process.env.NIGHTSCOUT_API_V3 === 'true',
nightscoutDisableHttps: process.env.NIGHTSCOUT_DISABLE_HTTPS === 'true',
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ export async function createFormattedMeasurements(measurementData: GraphData): P
const formattedMeasurements: Entry[] = [];
const glucoseMeasurement = measurementData.connection.glucoseMeasurement;
const measurementDate = getUtcDateFromString(glucoseMeasurement.FactoryTimestamp);
const lastEntry = await nightscoutClient.lastEntry();

const lastEntry = config.allData ? null : await nightscoutClient.lastEntry();
// Add the most recent measurement first
if (lastEntry === null || measurementDate > lastEntry.date)
{
Expand Down

0 comments on commit e84040f

Please sign in to comment.