Warning Heroku discontinued their Free Tier effective November 28, 2022.
The instructions below will still work on paid Heroku plans. For a free alternative, you can migrate to fly.io.
More detailed instructions for using Fly and other Heroku alternatives are not currently available but may be added at a later date.
If you need support, open an issue on tconnectsync with the
heroku
tag.
This project allows tconnectsync to run in Heroku. Unfortunately, the Heroku Free plan is no longer available, so you will need to configure billing in Heroku and pay $5/month (see Heroku pricing details).
Note: GitHub Issues have been disabled in this repository. To report or investigate issues, use the GitHub Issues page for tconnectsync.
Before beginning, make sure you have set up the t:connect Android, or iPhone/iOS application. If you have not used either, you can find more information or create an account [at the t:connect website](t:connect web.
You'll need the following information:
- Your t:connect username and password
- Your t:slim X2 pump serial number (visible in Settings > My Pump > Pump Info)
- Your Nightscout site URL
- Your Nightscout site secret
If you have not yet set up a Nightscout site, view the Nightscout documentation and set that up first, then come back to these instructions. Either log in to your existing Heroku account or create a new one.
Next, you'll be creating a new application inside your Heroku account. This will not be replacing your existing Heroku Nightscout app, if you have one; you will be creating a second app with a new name. Start by clicking the Deploy button below:
For App name, you can enter any value.
We recommend MyNightscoutSite-tconnect
.
The app name determines the URL to access your tconnectsync-heroku website, e.g. if you enter the app name MyNightscoutSite-tconnect
, then the URL for tconnectsync-heroku will be https://MyNightscoutSite-tconnect.herokuapp.com
.
The remainder of the options are tconnectsync environment variables:
TCONNECT_EMAIL
- Your t:connect emailTCONNECT_PASSWORD
- Your t:connect passwordNS_URL
- Your Nightscout site URL (e.g. https://yournightscoutsite.herokuapp.com)NS_SECRET
- Your NightscoutAPI_SECRET
valuePUMP_SERIAL_NUMBER
- The numeric serial number of your pump. Enter only the number, do not include '#'TIMEZONE_NAME
- The timezone code in which your phone and pump's time is set. (View a full list of valid values)
A new variable called TCONNECTSYNC_HEROKU_SECRET
will be automatically generated for you.
This secret password will be used to access API endpoints which trigger your pump data from tconnect
to be synchronized to Nightscout, as well as view the current status of synchronization.
(You can think of it like the tconnectsync equivalent to Nightscout's API_SECRET
.)
You can find its automatically generated value by going to Settings > Reveal Config Vars in your Heroku dashboard after setup.
Once you've filled out the Create New App form and pressed Deploy App, you'll be taken to the Heroku dashboard. From here, you can click on Open App to see whether the tconnectsync-heroku server is running.
If you see a page like the following, then you're ready to move on!
If you get an error, then jump to the instructions in the Testing section below.
Otherwise, continue reading below to set up tconnectsync-heroku by creating an account with a separate service, UptimeRobot.
Even though your Heroku app is already up and running, we need to set up a service called UptimeRobot which will send a request to your Heroku app to keep it alive so that it can continue to process your incoming t:connect data in the background.
Create an account at UptimeRobot by going to https://uptimerobot.com.
Once you register, you will be prompted to verify your email address. Click the link you receive from UptimeRobot in your email.
If you're asked to upgrade to the PRO plan, click Maybe later
Now that you have an account and are logged in, you should see a page like the following:
Click the Add New Monitor button. You'll see a popup like this:
Enter the following, one at a time:
- Monitor Type: HTTP(s)
- Friendly Name: tconnectsync
- Monitoring Interval: every 30 minutes
- Monitor Timeout: 1 minute
Enter the following as the URL:
https://MyNightscoutSite-tconnect.herokuapp.com/run?secret=YOUR_TCONNECTSYNC_HEROKU_SECRET_VALUE
MyNightscoutSite-tconnect is the App Name you provided for tconnectsync-heroku.
To get the value of YOUR_TCONNECTSYNC_HEROKU_SECRET_VALUE:
- Go into your Heroku dashboard (https://dashboard.heroku.com) and select the app you created for tconnectsync:
- Click on Settings > Reveal Config Vars.
- Now find the row which has
TCONNECTSYNC_HEROKU_SECRET
displayed on the left, and copy the value contained in the right-most text box next to it. This is the value of theTCONNECTSYNC_HEROKU_SECRET
environment variable.
(If you'd like, you can change the value here to a different password. If so, then save settings and then restart the app in heroku via More > Restart All Dynos.)
Your options should look similar to this within UptimeRobot (but with your actual tconnectsync-heroku URL and secret value):
Click Create Monitor.
You can optionally specify an alert contact to notify if you would like to receive an email whenever tconnectsync-heroku experiences an error. If you don't specify one, you'll have to hit the button again.
Now, every 30 minutes, tconnectsync will be triggered to synchronize your data between t:connect and Nightscout!
You can hit the following URL to verify that your tconnectsync options are specified correctly, and that both t:connect and Nightscout are accessible:
https://MyNightscoutSite-tconnect.herokuapp.com/check_login?secret=YOUR_TCONNECTSYNC_HEROKU_SECRET_VALUE
(Remember to replace MyNightscoutSite-tconnect
and YOUR_TCONNECTSYNC_HEROKU_SECRET_VALUE
with your own values like mentioned before.)
There is a lot of debugging output on this page, so scroll to the very bottom. If it says No API errors returned! then you are all good to go!
If the page doesn't load, you can also view the application-side error logs by going to the Heroku dashboard and clicking on More > View logs:
If you need help, you can do one of the following:
- Post in the CGM in the Cloud Facebook group
- Open a GitHub Issue at https://github.com/jwoglom/tconnectsync/issues/new/choose with the
heroku
tag.
When asking for help, please be ready to copy-and-paste the output of the check_login
URL
referenced above which contains diagnostic information which may help to solve your issue(s).
The remainder of the instructions below are for advanced use cases. Once you've gotten to this point, wait 30 minutes to see if pump data starts appearing in Nightscout!
View the application-side error logs by going to the Heroku dashboard and clicking on More > View logs:
Check if there are any errors about invalid configuration options. If the problem is something else, follow the If you need help instructions above.
The check_login
page gives a Received ApiException in ControlIQApi: ControlIQ API HTTP 404 response
error
Please verify that you've completed the following steps:
- Have you created an account on the tconnect website?
- With the tconnect credentials you've specified, can you:
- Log in to the Android or iOS app, with your pump paired and sending data
- Log in at https://tconnect.tandemdiabetes.com and see your pump information appear
If tconnectsync still gives this error, try:
- Downloading the Windows or MacOS TConnect Uploader application and plug your pump into your computer to upload your settings.
- Resetting your password at https://tconnect.tandemdiabetes.com and setting it to the same password you use in the Android or iOS app
If this doesn't help, follow the If you need help instructions above.
By default, tconnectsync-heroku will upload the following data from your pump to Nightscout:
- Basal events
- Bolus events
Tconnectsync supports additional so-called synchronization features which enable it to send additional pump data into Nightscout. You can see a list of these features here.
To set custom synchronization features, go into your Heroku Config Vars settings (Settings > Reveal Config Vars) and add a key and value with the following:
- Key:
TCONNECTSYNC_HEROKU_FEATURES
- Value: a comma-separated list of features, without spaces. e.g.,
BASAL,BOLUS,PUMP_EVENTS
If you don't set this value, tconnectsync-heroku will default to tconnectsync's default synchronization features (only basal and bolus data).
Updates are made frequently to tconnectsync to correct bugs or add new features. When some time has past after setting up tconnectsync-heroku and you want to ensure you are up to date, follow these instructions:
To update your Heroku instance of tconnectsync, perform the following steps. This is a tconnectsync specific version of the "Deploy using Heroku Git" instructions which are present in the "Deploy" tab of your Heroku console.
You should perform the following steps on a Linux or MacOS computer. If using Windows, install the Windows Subsystem for Linux and run these steps inside the Ubuntu Terminal.
- Install the Heroku CLI
- In a terminal, clone your Heroku repository and pull the latest version of tconnectsync-heroku:
heroku git:clone -a YOUR_HEROKU_SITE_NAME cd YOUR_HEROKU_SITE_NAME git remote add upstream https://github.com/jwoglom/tconnectsync-heroku git pull -r upstream main
- Deploy the updated app to Heroku:
git push heroku main
What follows is an alternate option, which may be easier to set up but may not work for all setups:
Go into your Heroku Config Vars settings (Settings > Reveal Config Vars) and add a key and value with the following:
- TCONNECTSYNC_HEROKU_INTERVAL_MINS - The interval at which a scheduled task should be performed for a synchronization. This will only function while the Flask application is running inside Heroku. (Heroku will occasionally shut down the app after some period of inactivity.)
For example:
- Key:
TCONNECTSYNC_HEROKU_INTERVAL_MINS
- Value:
30
When the Flask application is started, so long as it is running the tconnect synchronization task will run at the given interval.
Note that Heroku may shut down your dyno if it has not processed requests in 30 minutes.
You should ideally set up UptimeRobot to ping your application at the index URL (not the run endpoint, since that will cause the synchronization to happen both triggered by UptimeRobot and the background task daemon itself). This would reflect a URL such as:
https://YOUR-TCONNECTSYNC-APP-NAME.herokuapp.com/