With permission from Jessie on the r/Diabetes Discord server, I’m posting this guide to my blog to help with providing a fun project for those with diabetes that use a CGM, already have Nightscout set up, and have an interest in smart home devices. If you have any questions, you can, generally, find either of us on the r/Diabetes Discord.
Jessie’s Guide on Nightscout & IFTTT with Smart Lamps
Hi guys! This little science experiment spawned as a result of me wanting a Glowcose lamp ( https://glowcose.com/ ) but: a) not being able to ship one to me (they won’t ship outside of US) and b) I did not want to pay $60 USD for a glorified smart lamp. Don’t get me wrong, I’m sure they’re great if you don’t want to figure out how to set up Nightscout and all that, but I’d rather spend an hour figuring it out myself than pay $60 USD :D
Special thanks to the folks over at the r/Diabetes Discord server (particularly DJ and Nimdae!) for guiding me to figure out how to get this working. Also thanks to the developer(s) of Nightscout for having such a great open source program running.
This guide will cover how to turn an IFTTT-compatible smart bulb (not sure if yours is compatible? Check IFTTT ) into a lamp that will change colour according to your continuous glucose monitor’s readings. I am a non-insulin dependent type 2 diabetic with a Dexcom G6, so this was totally just a vanity project for fun but I figure it may be more helpful for anyone who does treatments based on their CGM readings, or for kids to learn about diabetes.
DISCLAIMER: Nightscout and this project are all unofficial and not sponsored or endorsed in any way by Dexcom or any other CGM company. Use at your own risk and always verify readings with a fingerstick test if in doubt!
Project Requirements
- Nightscout (if you need to set up Nightscout, please see their GitHub .) For this guide, my Nightscout is set up using Railway, but the general steps should be fairly similar across platforms.
- IFTTT compatible smart bulb or smart light. Check their site here if you need to see if yours is compatible. Generally (but not always), bigger brands with their own dedicated app, like Philips Hue or Govee, will be compatible. For my guide I am using a Govee Glide light.
- The patience for figuring things out. I am not someone with a background in computer science, or coding, or anything like this. This project took a couple of hours of figuring stuff out and you may need to as well.
IFTTT Setup
Head on over to https://ifttt.com/join and sign up for an account or sign in with one of their supported services. You can start with their free plan with 5 Applets for now.
Hit “Create” after you login, found in the top right corner:
- Now the whole principle behind IFTTT is that it stands for “If This, Then That”, meaning that your “applet” functions based on if a specific action occurs, something else happens. Applets are what IFTTT uses to connect two services/devices together. We will be connecting Nightscout with your smart light. In our case, we want ours to trigger a lamp to change colour when a webhook detects that Nightscout sent out a warning or “event”. Click on “Add” and search up “Webhooks”.
- Click on “Receive a Web Request”. This will be the trigger action where it fetches data from Nightscout:
- Enter what kind of “event” should trigger this command to go off. Out of your 5 applets, depending on your own diabetes, you’ll probably need at least 2 or 3 separate applets set up. For me, I (thankfully) have never gone low (<4.0mmol / 72mg/dL) so I only have mine set up for highs and in-ranges. If you’re someone who does go low, you’ll probably want to set up an additional applet for lows. For now, let’s set up ns-allclear, which is what colour your lamp will be while you are in-range. Type in ns-allclear and then click Create Trigger.
Please see this list from Nightscout’s IFTTT guide on what events you can use:
- ns-event - This event is sent on all alarms and notifications. This is good catch-all event for general logging.
- ns-allclear - This event is sent when an alarm has been acknowledged or when the server starts up without triggering any alarms. (For example, you could use this event to turn a light to green.)
- ns-info - All notifications at the info level will cause this event to be triggered.
- ns-warning - All notifications at the warning level will cause this event to be triggered.
- ns-urgent - All notifications at the urgent level will cause this event to be triggered.
- ns-warning-high - This event is triggered when crossing the BG_TARGET_TOP threshold.
- ns-urgent-high - This event is triggered when crossing the BG_HIGH threshold.
- ns-warning-low - This event is triggered when crossing the BG_TARGET_BOTTOM threshold.
- ns-urgent-low - This event is triggered when crossing the BG_LOW threshold.
- ns-info-treatmentnotify - This event is triggered when a treatment is entered into the careportal.
- ns-warning-bwp - This event is triggered when the bwp plugin generates a warning alarm.
- ns-urgent-bwp - This event is triggered when the bwp plugin generates an urgent alarm.
- Click on Add then search up your smart light’s manufacturer. For me, it’s Govee.
- Once you have selected your smart light’s manufacturer, you’ll be prompted to login to authenticate your smart light’s app with IFTTT. After that, generally a list of possible options will pop up. You’ll have a bit of freedom to pick what you want your light to do. For me, I’m picking select light colour, and picking the colour green for when I am in range. Click create action after selecting the colour:
- You’ll have the option of renaming your applet, or you can keep it as whatever it generates. I name mine based on what it does (High Warning, Low Warning, In-Range, etc). Click finish.
- Go back to Webhooks from “Explore” in the top right and select the settings in the corner. We will be grabbing your Maker key, which is what Nightscout will use to connect to IFTTT. Your Maker key should appear as a string of letters and characters after the /use/ part of your URL. Copy it to your clipboard.
Nightscout Integration
- Now that you’ve grabbed your Maker key from IFTTT, we will be moving over to Nightscout. Open up your Nightscout host’s site and sign in. Find where the variables section is:
- You’ll want to add a new variable called “MAKER_KEY” then paste in your Maker key copied from IFTTT:
- After you’ve inserted the MAKER_KEY variable, go and enter “maker” into your ENABLE plugins line:
- Make sure your Nightscout alarms are on. As someone who isn’t on insulin, my glucose alarms were being snoozed automatically by Nightscout since it assumed I had insulin on board (IOB) based on my profile settings, which were all set to default numbers. This what was causing my IFTTT to not work, since Nightscout was not sending any events to IFTTT, given that any alarms that went off automatically got suppressed. I had to go into my Nightscout settings and remove or set any insulin-related settings/plugins to 0. I am not sure what to do here if you are insulin-dependent and rely on Nightscout for treatments - USE AT YOUR OWN RISK!
Update your variables and re-deploy your website. That’s it! Your smart light should (hopefully) be glowing green, or whatever colour for whatever applet event you set up. Here are some sample applet options you could use:
- ns-allclear - Green light
- ns-warning-low - Red light
- ns-warning-high - Orange or yellow light
- ns-urgent-low - Blue
- and so on…
If you want to check if your Nightscout and IFTTT are talking to each other properly, go into your latest deployment’s logs, and search for “maker”. If it worked properly, maker should be active and have some sort of status. For me, I’m in range while working on this document, so here’s how it looks when it set off “ns-allclear”. My lamp behind me is bright green!
Conclusion
I hope this guide was ok at explaining everything. The steps you see here were all for my version of figuring things out, with Nightscout set up on Railway and my preferred smart light being a Govee light.
Please let me know if you find any errors or other easy solutions/workarounds! I can be reached on Reddit at u/Skrubette, or wherever I had posted this link. Cheers and good luck!