gagebenne/pydexcom

[Feat] Get Alert Settings and Device Info

Closed this issue · 5 comments

Haven't had chance to look at this and provide a PR, however it'd be great if we could pass back the current alerts that are set, and any device info using the /devices endpoint

This way, it can be fed into this such as the Home Assistant integration, so users can trigger things in HA based of these values, rather than having to set them in HA as a helper.

Exposing this information allows the integrated services to be in sync with the settings from Dexcom, which should be the source of truth

I know this project doesn't utilise the developer api's but the share API's. I think at least the alert information is passed here, as when setting up share, you specify the alert upper and lower variables as an option

This is an excellent idea.

Unfortunately, the official Dexcom API (or even the new Web API) is just too restricted for an open source tool of this size. Using those endpoints with more than 10 users would require approval from Dexcom, which, considering the use of the Share API, I find unlikely.

It's a bummer, because you're right -- having a Dexcom G6 device with a unique identifier in Home Assistant, with two sensors is the way this should be handled. However, I can't just make up a device identifier and call it a day. The Share API has a way of validating whether a given serial number belongs to the user (device identifier), but the community has yet to find a valid Share API endpoint to simply get the user's serial number.

I'm currently (slowly) rewriting some of the module, with an emphasis on testing the endpoints (Dexcom will suddenly change how the Share API behaves -- gotta be ready), so I'll keep an eye out for device identifier endpoints through the Share API.

As for alert bounds being present in the Share API -- I'll look into that as well, see if anything is available via the Share API.

As for alert bounds being present in the Share API -- I'll look into that as well, see if anything is available via the Share API.

I did some digging and it seems that you set the values of the alarms when you create the invite (bit odd)

Almost seems that the way to do it is to create a session using an invite, but can't quite wrap my head around the logic of how the share system works

So what seems to happen is that when you accept a share link, it pulls the bounds set in the invite and then stores them in the app, so that any alerts are generated by the app itself, not be an API driven system. I haven't figured out the API it calls when accepting an invite though.

What I did notice though is the link that is sent to a follow, then gets redirected to a deeplink to the follow all like so dexcomrm://SubscriptionRequest?invitation=6d8c4379-e812-54cb-d1ec-47120cf7473b

How did you manage to locate the share API? Have tried sniffing the traffic but the app doesn't connect if you route through a VPN with a mitm certificate, and everything else is encrypted :(

The Share API has been investigated by lots of folks across many different projects -- the folks at NightScout were the primary researchers. I think I'm gonna go ahead and close this, I think the library does the critical parts, and if anyone finds clear additional API endpoints, I'd be open to a PR. Researching the other endpoints though I think might be a lot of work for little reward.

Thank you so much for interest in the package and the discussion!