Constant Glucose Monitor API

Nice. I will play with it this week.

Apparently someone made one for HA. They have it setup so in the G7 app you send a invite for follower. (Follower is another app that allows a loved one to view you in realtime like a parent watching a kid or adult who cares for elderly.) This is 5 min updates in realtime. The HA instance becomes the "loved follower" which allows the realtime updates in 5-6 min intervals. It has two entities.... realtime glucose, and trend over time. The trend is basic like trend up, steady, trend down.

1 Like

Do you have a link to it? Might be something I could use to adapt this to a near-real time.

Even better, direct GitHub link:

1 Like

That says G6 but it works on G7 as well.

OMG, I have the exact same issue - will wake up (or not be able to wake up) with dangerous low sugars, especially on nights after intense exercise.

I will take a look at the other link, but yes, if it works for G6 it should work for G7. Having HA be a ā€œfollowerā€ is the easiest thing (and itā€™s also how it works with Freestyle Libre 3). I already have this working in Siri and Alexa via Sugarmate (app), but there is an open source diabetes management app (server side) called Nightscout that could also integrate with HA, and a lot of people use it.

Keep in mind though that CGM readings are constantly 5 minutes behind in Dexcom (1-2 minutes in Abbot Freestyle Libre). On top of that, the Dexcom API mandates another 5-15 min wait time (Libre LinkUp API too but a different amount of time). Then thereā€™s the physical CGM reading in your skin - those fluids between the cells that the CGM needle reads are also about 10-15 minutes behind your actual blood sugar value (CGM runs behind finger stick values). So you are probably looking at a total delay of anywhere from 15 minutes up to 45ā€¦ still very useful, but not for life saving or medication adjustment decisions.

I know this is old, but would like some assistance with adding the device. Have the code imported, but see no way to add the device. Thanks in advance. @thebearmay

I to have an interest in this.
Thank you.

Did you also import and instatiate the app? The app should go out and find/create the device if the correct credentials are given. That being said Dexcomm basically said that they werenā€™t interested in supporting the API in a manner that would make it useful for automation. So while the code should work(assuming the API hasnā€™t changed) the data it returns, while correct is never current because they donā€™t want the liability should someone use it to make a decision outside of their control.

I have this working with my freestyle libre 3. Happy to help if people are interested. I have it change the color of my office light based on my level, but really you can do whatever, alarms, etc..

1 Like

Iā€™m interested. Is this universal, or only in certain countries?

I'd be interested.

The other half looks after someone who uses Freestyle Libre 2.

Could you give a lowdown of how this works please? not necessarily a step-by-step, but a summary? that would be awesome. If I can demonstrate to them what's possible, that's another hubitat sale. :slight_smile:

ta

I am interested. My wife uses Freestyle Libre 3, and constantly checks it during the night. Would be great for all to put colors on vanity under color light strip. Please provide details.

Interested as well, I can also help develop the app. I have access to a Libre 3 stream and have it update every minute via a nightscout instance.

Warning for others: The reason Dexcom delays it by 3 hours and why Abbott does not provide the last 20 minutes of data in real time is because of liability and regulations. Using any integration to provide any individual data on their health in real time that they can rely on makes the hub a medical device that has not been FDA approved, so caution needs to be taken, and the users need to understand they cannot rely on the integration (aka a light color changing) for life or death situation decisions. This can be easily forgotten over time, especially when the integration seems reliable. It becomes an unattended process that can silently stop working and result in a catastrophe. Donā€™t want to be scaring anyone, but there is merit in what Dexcom and Abbott are doing to delay the real time data. Not taking their side either :smiling_imp:

2 Likes

Welcome to take what I've done and enhance, replace, etc. @ady624. I got far enough that I could see the values from the 3 hour delay in the test instance, but since I don't have access to a real device and Dexcom was adamant that they weren't going to support me further the code above was a far as I could take it. Had a few friends that had their lives severely impacted and shortened by this condition so if I can help further holler.

LATER EDIT: this driver provides real time measurement value every minute - still, do not use this for real time health decisions, you get it already

For all those using Freestyle Libre, here's the good news hot off the press: GitHub - ady624/hubitat-freestyle-libre: Freestyle Libre integration for Hubitat

I am new to Hubitat so yet to figure out how to make this available via HPM.

The bad news, I only have access to a Libre 3 user, so I have not tested this with Libre 2. Updates every one minute, has real time data - BUT PLEASE DO NOT RELY ON THIS FOR YOUR LIFE DECISIONS.

It relies on LinkUp - you need to add a connection from the Libre app to an account you create on LinkUp. Multiple users/sensors can be linked to the same LinkUp account - a device will be created for each connection/user/sensor.

2 Likes


The piston above sets the color for two sets of lights (Switch 35 is a lamp in a bedroom, Switches 46 and 47 are some overhanging lamps over the kitchen island) with a dynamic color from 70 (green) to 180 (red) based on the CGM value (Unknown Device 29). If using webcore, you can import this piston by using code 67fva and providing replacements for the devices. You can delete one of the inner IFs if you only have one bulb or one set of bulbs. Or duplicate them if you have more groups. :smiley: Feel free to change the range too, the rainbowValue function takes 5 parameters (value, minValue, minColor, maxValue, maxColor). Note that I picked this range because this user is not on insulin, so lows are not an issue, it's the highs that matter, hence the red color. Change the RGB codes as you wish.

Unfortunately, according to their own FAQ:

Can apps get real-time estimated glucose values (EGVs) with the Dexcom API?
Currently, the Dexcom API offers EGV data on a three-hour delay. The Dexcom API is intended for software developers to retrieve retrospective CGM data and CGM-derived metrics for use in software applications. Real-time treatment decisions should not be made based on the data displayed to the end user, and the delay helps clarify this. Dexcom settled on the three-hour delay after consultation with FDA.

Source: Dexcom API | Home

Yep, thatā€™s the barrier I ran into, and while they could make realtime information available they have made the decision not to.

Yeah, wondering if they have any undocumented endpoints or query parameters that their app is using to bypass the 3-hr delayā€¦ :face_with_hand_over_mouth:

Well, think about it. The Libre 3 app is on an iOS or Android device that is paired by Bluetooth to the sensor. All real-time sensor data has to pass through the Libre 3 app before going up to the cloud, to which the API allows delayed access. Thereā€™s no reason to have a real-time endpoint via an API. The Libre 3 app is able to do a real-time graph of glucose because it has access to the real-time data from the sensor.