jwoglom / tconnectsync

Syncs insulin pump data from Tandem t:connect to Nightscout for the t:slim X2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: support for multiple .env files

mylesamoran opened this issue · comments

My wife and I both have t:slim pumps running control IQ. I would like to be able to natively support 2 .env files to be able to run this for both of our setups (this way I can run everything off a raspberry pi instead of leaving my desktop on all day)

As a work around, I think for now I can script it with cron to copy the first .env into the proper directory, run tconnectsync, copy the second .env into the proper directory and run tconnectsync again. I'm not sure if changing out the .env file every time it runs will create any issue.

@mylesamoran Hey, thanks for the feature request. Given the current structure of the code it's most likely that the app will only support a single configuration in one config file. However, this situation might be easier to manage if you had two completely separate instances of the app on your filesystem, one for each person with their own .env file, rather than moving the .env file around. The exact way of doing this depends on how you're running tconnectsync currently (tconnectsync after a pip install vs. cloning the repo and running the .py script vs. running the docker image). But, with the clone-and-run approach it sounds like you're doing, it would more or less just be having a, e.g., /home/pi/user1/tconnectsync folder and a /home/pi/user2/tconnectsync folder, each with their own .env's. You could then also use the autoupdate feature on each and have them run concurrently for each user, rather than needing to run tconnectsync manually.

I did the install with pip, but if I'm following your suggestion, that would be to do the pipenv install with the git cloned to 2 different folders, so each of those folders would be able to run independent of the other and each would contain the different .env file? That makes sense and seems like a good solution.

Correct -- you can also install with pip3 install tconnectsync and then, instead of making a .env file, write a bash script which sets all of the environment variables for each person. This doesn't require you to have any checked out copies of the repo at all. The script would look something like:

#!/bin/bash
export TCONNECT_EMAIL='email@email.com'
export TCONNECT_PASSWORD='password'
export PUMP_SERIAL_NUMBER=11111111
export NS_URL='https://yournightscouturl/'
export NS_SECRET='apisecret'
export TIMEZONE_NAME='America/New_York'
tconnectsync --auto-update

then chmod +x ./run-tconnectsync.sh and run like ./run-tconnectsync.sh. And you could have two scripts which would run separately with their own separate environment variables.

Thanks, I set up two scripts as you said above and it has been uploading data for us now without any issues. As far as I'm concerned that implementation is a perfect solution to this.