From 7b06f1c457c73140d5b3575d7ca4cc83b3feabbb Mon Sep 17 00:00:00 2001 From: James Woglom Date: Tue, 4 Jan 2022 20:54:53 -0500 Subject: [PATCH] secret: parse API_SECRET/TZ if NS_SECRET/TIMEZONE_NAME are missing --- Pipfile.lock | 6 +++--- README.md | 4 +++- tconnectsync/secret.py | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Pipfile.lock b/Pipfile.lock index cbf2783..53de670 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -46,11 +46,11 @@ }, "charset-normalizer": { "hashes": [ - "sha256:1eecaa09422db5be9e29d7fc65664e6c33bd06f9ced7838578ba40d58bdf3721", - "sha256:b0b883e8e874edfdece9c28f314e3dd5badf067342e42fb162203335ae61aa2c" + "sha256:876d180e9d7432c5d1dfd4c5d26b72f099d503e8fcc0feb7532c9289be60fcbd", + "sha256:cb957888737fc0bbcd78e3df769addb41fd1ff8cf950dc9e7ad7793f1bf44455" ], "markers": "python_version >= '3'", - "version": "==2.0.9" + "version": "==2.0.10" }, "idna": { "hashes": [ diff --git a/README.md b/README.md index 628a582..775bb80 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ The following synchronization feature is disabled by default, but can be enabled ## Setup The following setup instructions assume that you have a Linux, MacOS, or Windows (with WSL) machine that will run the application continuously. + If you've configured Nightscout before, you may be familiar with Heroku. [You can opt to run tconnectsync with Heroku by following these instructions.](https://github.com/jwoglom/tconnectsync-heroku) **To get started,** you need to choose whether to install the application on your computer via @@ -67,8 +68,9 @@ TCONNECT_PASSWORD='password' # Your pump's serial number (numeric) PUMP_SERIAL_NUMBER=11111111 -# URL and API secret for Nightscout +# URL of your Nightscout site NS_URL='https://yournightscouturl/' +# Your Nightscout API_SECRET value NS_SECRET='apisecret' # Current timezone of the pump diff --git a/tconnectsync/secret.py b/tconnectsync/secret.py index a6a6218..75f61c3 100644 --- a/tconnectsync/secret.py +++ b/tconnectsync/secret.py @@ -36,6 +36,10 @@ PUMP_SERIAL_NUMBER = get_number('PUMP_SERIAL_NUMBER', '11111111') NS_URL = get('NS_URL', 'https://yournightscouturl/') NS_SECRET = get('NS_SECRET', 'apisecret') +if not get('NS_SECRET') and get('API_SECRET'): + print('API_SECRET environment variable is set, overriding NS_SECRET') + NS_SECRET = get('API_SECRET') + TIMEZONE_NAME = get('TIMEZONE_NAME', 'America/New_York') if not get('TIMEZONE_NAME') and get('TZ'):