timoschlueter / nightscout-librelink-up

Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout.
MIT License
189 stars 246 forks source link

Added ALL_DATA configuration option to allow uploading all available historic data to Nightscout. #140

Closed johannes-martin closed 1 month ago

johannes-martin commented 1 month ago

Librelink Up sometimes lags behind in reporting historical values, i.e. it reports the current CGM reading and those dating more than 30 minutes back, but not the ones that were collected within the last 30 minutes.

ALL_DATA=true now gets nightscout-linklink-up to resend all historic data to nightscout. Nightscout seems to detect duplicate data, so re-uploading data that nighscout already knows about is not a problem.

I run the script with ALL_DATA=true once an hour in addition to using cron to run it every minute.

stncttr908 commented 1 month ago

Thank you for this enhancement! If running the docker image with one minute updates, how do I set it to run ALL_DATA once per day as suggested?

johannes-martin commented 1 month ago

Thank you for this enhancement! If running the docker image with one minute updates, how do I set it to run ALL_DATA once per day as suggested?

I'm afraid that's difficult with docker and the current implementation. You could use the following to run the complete update once an hour:

docker run -e LINK_UP_USERNAME="mail@example.com" \
           -e LINK_UP_PASSWORD="mypassword" \
           -e LINK_UP_TIME_INTERVAL="60" \
           -e LINK_UP_REGION="EU" \
           -e ALL_DATA="true" \
           -e NIGHTSCOUT_URL="nightscout.yourdomain.com" \
           -e NIGHTSCOUT_API_TOKEN="librelinku-123456789abcde" \
           -e LOG_LEVEL="info" \
           timoschlueter/nightscout-librelink-up

It may happen that both the partly and complete update run concurrently at the full hour then which might cause problems in librelink our nightscout.

If your host OS is Linux, you could use cron:

1-59/1 * * * * docker run -e SINGLE_SHOT="true" ...
0 * * * * docker run -e SINGLE_SHOT="true" -e ALL_DATA="true" ...
stncttr908 commented 1 month ago

Thank you for this enhancement! If running the docker image with one minute updates, how do I set it to run ALL_DATA once per day as suggested?

I'm afraid that's difficult with docker and the current implementation. You could use the following to run the complete update once an hour:

docker run -e LINK_UP_USERNAME="mail@example.com" \
           -e LINK_UP_PASSWORD="mypassword" \
           -e LINK_UP_TIME_INTERVAL="60" \
           -e LINK_UP_REGION="EU" \
           -e ALL_DATA="true" \
           -e NIGHTSCOUT_URL="nightscout.yourdomain.com" \
           -e NIGHTSCOUT_API_TOKEN="librelinku-123456789abcde" \
           -e LOG_LEVEL="info" \
           timoschlueter/nightscout-librelink-up

It may happen that both the partly and complete update run concurrently at the full hour then which might cause problems in librelink our nightscout.

If your host OS is Linux, you could use cron:

1-59/1 * * * * docker run -e SINGLE_SHOT="true" ...
0 * * * * docker run -e SINGLE_SHOT="true" -e ALL_DATA="true" ...

Thank you, I think either will work just fine! I was not sure I could run two instances which is why I hesitated using another instance with SINGLE_SHOT.

stncttr908 commented 1 month ago

Just to follow up, this seems to be working as expected. I've got it setup to run ALL_DATA and SINGLE_SHOT every 24 hours via crontab. I did add --rm=true so I don't end up with a mess of single-use containers to clean up periodically. Thanks again for your help!

> nightscout-librelink-up@2.6.1 start-heroku
> node dist/index.js

[info]: renew token
[info]: Logged in to LibreLink Up
[info]: Found 1 LibreLink Up connection.
[info]: -> The following connection will be used: <redacted> (Patient-ID: <redacted>)
[info]: Trying to upload 142 glucose measurement items to Nightscout
[info]: Upload of 142 measurements to Nightscout succeeded
npm notice 
npm notice New minor version of npm available! 10.5.2 -> 10.8.1
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.8.1>
npm notice Run `npm install -g npm@10.8.1` to update!
npm notice