I believe that both of these watches support a web based API which can receive remote data from a web server.
I propose attempting to incorporate an optional web service in to xDrip to respond to queries on the localhost address but I am not familiar with watch-face development for either of these devices at the moment to know fully whether this will work and the ideal way to structure it.
What is the best format for data to be provided? json?
What information should be provided to the watch?
Does anyone have any of these devices to test/develop with?
Can we respond to events, for example an action on the watch to generate a specific request which we could use for example to snooze alerts? I could attempt to open up the tasker interface via http etc...
@danpowell88 @Rytiggy you may be interested in this.
Hey, I was able to connect to a REST API server when the fetch is formatted like shown below on my Fitbit Ionic companion app. my REST API is just the a basic heroku API that was set up through this tutorial ,
Code:
const test = () => {
console.log('TEST IS A CONNECTION')
let url = 'YOUR URL'
fetch('url',{
method: 'GET',
mode: 'cors',
headers: new Headers({
"Content-Type": 'application/json; charset=utf-8'
})
})
.then(response => {
console.log('Get Data On Phone');
response.text().then(data => {
console.log( data);
sendVal(data);
})
.catch(responseParsingError => {
console.log('fetchError');
console.log(responseParsingError.name);
console.log(responseParsingError.message);
console.log(responseParsingError.toString());
console.log(responseParsingError.stack);
});
}).catch(fetchError => {
console.log('fetchError');
console.log(fetchError.name);
console.log(fetchError.message);
console.log(fetchError.toString());
console.log(fetchError.stack);
})
};
test(); // test right away
function sendVal(data) {
console.log('sendVal')
if (messaging.peerSocket.readyState === messaging.peerSocket.OPEN) {
console.log('Sending Values')
messaging.peerSocket.send(data);
}
}
@Rytiggy so this is with the garmin api? Is there any existing watch-face for garmin which connects to nightscout? I am thinking if one already exists I can emulate the same endpoint within xDrip
@jamorham I did not use the garmin API, I am developing this on the fitbit Ionic using the fitbit sdk, and fitbit studio.
If you make it work either with the /pebble endpoint or /api/v1/entries/sgv.json?count=24 endpoint then I can make sure that it is supported out of the box with xDrip
The garmin api actually supports sending messages to the watch directly and can handle processing them order etc. I believe it just requires the watch face an xdrip to share an 'inbox' address
See https://developer.garmin.com/connect-iq/programmers-guide/communication/ directly messaging
I believe Andreas May had some kind of fork of xdrip and a watch face built that would take advantage of it, I don't have his github d to ails though, he goes by Swissalpine on gittter
@danpowell88 yes, @swissalpine has sent me that fork which I can look over. The problem is that without a device for me to test it with its going to be really tricky to get reliable etc and if we need to implement a http api for fitbit then the same interface I assume could be used for garmin and its going to be that much easier to maintain.
True, when I last looked through the Fitbit forums people were complaining and asking for api integration as fitbit is the only one that doesnt really have it, didn't see any official response though
I can test the garmin integration currently nt using a garmin vivoactive hr 24/7 with @swissalpine watch face, but it is sort of limited due to requiring a data connection to always be available, would love to have it working off local data
@Rytiggy can you try with either of the endpoints which are now available in the Jan 7th nightly version and let me know if the fitbit api can connect to them? https://github.com/NightscoutFoundation/xDrip/blob/master/Documentation/technical/Local_Web_Services.md
@jamorham I'm not quite sure how to get the local end points set up, I have x drip running and linked to my rest API receiving data points.
With the fetch I have set up on my Fitbit ionic it will work with any rest API
@Rytiggy You should be able to go to Settings -> Inter-App settings -> xDrip Web Service -> ON
Then with the ionic code you have, see if you can create a connection to url: http://127.0.0.1:17580/sgv.json
This should pull a nightscout style json but from xDrip's internal database.
@jamorham I don't think I have the local web server set up right, here is what my inner app settings look like

Upgrade to the latest version to see the new settings item:
https://github.com/NightscoutFoundation/xDrip/wiki/How-to-get-the-Nightlies-on-Automatic-Update
@jamorham okay tested and can confirm that when you set up the local rest API with the endpoint (http://127.0.0.1:17580/sgv.json) through xdrip that you can do a fetch on the fitbit ionic companion app, here is the fetch request that i made.
fetch('http://127.0.0.1:17580/sgv.json',{
method: 'GET',
mode: 'cors',
headers: new Headers({
"Content-Type": 'application/json; charset=utf-8'
})
})
.then(response => {
console.log('Get Data On Phone');
response.text().then(data => {
console.log('fetched Data from API');
// Do somthing with the data
sendVal(data);
})
.catch(responseParsingError => {
console.log('fetchError');
console.log(responseParsingError.name);
console.log(responseParsingError.message);
console.log(responseParsingError.toString());
console.log(responseParsingError.stack);
});
}).catch(fetchError => {
console.log('fetchError');
console.log(fetchError.name);
console.log(fetchError.message);
console.log(fetchError.toString());
console.log(fetchError.stack);
})
}
};
Okay, so that means with this local web service it should be possible to create a fitbit watchface for xdrip. I assume you got good looking data coming back?
@swissalpine any chance you could publish a garmin watchface with that api and I can test it
I have been working on a watch face for the Fitbit ionic that will display blood sugars that just takes in a REST API URL, its functional now but needs some refactoring. definitely going to publish it once I finish it up. here's where it's at now.

Okay that looks great! So is the watchface now able to get the data directly from xDrip without needing to go over the internet to Nightscout?
Exactly it's all local to the phone now!
@Rytiggy Is it possible to side load apps for the ionic? It would be really good for ionic users if there was a way you could publish the watch face even if its not 100% complete!
@jamorham yeah it is possible to side load through the fitbit companion app (https://dev.fitbit.com/build/reference/companion-api/)
I would love to publish the watch face, I would also love it go be part of the xdrip community, what would I need to do to be a part of it?
@Rytiggy I'm not exactly sure what you're asking but within xDrip we have automated facilities to install Pebble and Android wear watchfaces and they come bundled within the app for simplicity. We could do the same for a fitbit watchface if it can be sideloaded easily.
If you're just talking about the watch face source code then just publish a repository and we can link to it in the documentation. Anything else feel free to drop me an email, my username at gmail
@jamorham okay awesome I will doublecheck the side loading; if not we can link it in the documentation. We'll be in touch :)
@Rytiggy Is it possible to access the step counter / heart rate within your watch face? Can you send the step counter in to xDrip using the ?steps= interface I just added: See updated documentation: https://github.com/NightscoutFoundation/xDrip/blob/master/Documentation/technical/Local_Web_Services.md
@jamorham I will see if it's possible, I think It should be.
@Rytiggy do you the watch face anywhere, I'm considering buying an ionic as my garmin just died and would like to try it
@danpowell88 I am going to upload the code soon but I do have a repo that I am working on that will eventually show you how to set up the watch.
@danpowell88 @jamorham code has been posted, @jamorham I still have not found the time to test the step counter.
@jamorham I looked into this and it should be possible to send the steps to xdrip. What would need to happen is that the watch would need to send the data (steps) to the companion app which would then send the step with a fetch request to xdrips endpoint. I can implement this next functionality soon.
@Rytiggy nice one! How do users install it? Is there some package file?
Is it suitable to enter fitbit competion? https://dev.fitbit.com/app-champ-2017/ (last day to enter!)
@jamorham I have the .fba file but haven't finished the instructions yet on how to get everything working. I will be posting them soon to the git.
I didn't even know that that was going on! thank you for letting me know I have submitted my code for review.
Managed to get the code loaded on mine, need a way to change it to mmol though, @jamorham wondering if the json should automatically output in the units that xdrip is setup to use rather than defaulting to mg/dl?
Wrapping my head around the ionic code @Rytiggy has. For a UX consistency perspective I would back the suggestion from @danpowell88 for the json exporting units based on xdrip settings, that way the app on either fitbit or garmin would only need to look for the units to set the graph parameters and not have to do any calculations on each reading. Small calculation definitely but why do something you don't need to?
Please don't change it. Let it be the same output as the "official"
Nightscout json response. All my apps are recalculating this and I don't
like to change all. And I wish to have the possibility to build apps, where
the user can decide: Nightscout Download or xDrip+.
Thanks!
Andreas
2018-01-13 21:25 GMT+01:00 raymond-richmond notifications@github.com:
Wrapping my head around the ionic code @Rytiggy
https://github.com/rytiggy has. For a UX consistency perspective I
would back the suggestion from @danpowell88
https://github.com/danpowell88 for the json exporting units based on
xdrip settings, that way the app on either fitbit or garmin would only need
to look for the units to set the graph parameters and not have to do any
calculations on each reading. Small calculation definitely but why do
something you don't need to?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/NightscoutFoundation/xDrip/issues/261#issuecomment-357464864,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AL8BPdA_wyiTCi4zqV4WeGmLdwFeBkMPks5tKRFIgaJpZM4RVT2J
.
Ahhh, wasn't considering that we used an "official" format. In that case yeah, it would complicate matters to start changing. If something were to be "bundled" with Xdrip however I would resume this discussion.
Thank you for coming back and understand my wishes!
You can test the "official" formats with your Nightscout url, f. e.:
your-name.herokuapp.com/api/v1/entries/sgv.json&count=24
~.herokuapp.com/api/v1/profile
~.herokuapp.com/api/v1/status
~.herokuapp.com/pebble?count=24
In every case Nightscout is sending values in mg/dl (afaik), all values
stored in mlab are in mg/dl.
So it is calculate in every app which works with these data. That's sound
unnecessary, but I thinks it is not bad, it's easier!
All my calculations in my apps (for plotting the graph, firering alarms)
are done only with mg/dl. The difference is "only" the shown scale. I don't
have two different formulas.
The only thing I have is one function to change mg to mmol. I use it only
three times for displaying Delta, the scale of the graph und the BG himself.
In the function is something like that (it's GARMINS monkey c):
function mmol( bg ) {
return (0.0555 * bg).format("%.1f");
}
If Jamorham gives you a sole response it doesn't concern me, but please let
the sgv.json output unchanged.
Andreas
2018-01-14 3:13 GMT+01:00 raymond-richmond notifications@github.com:
Ahhh, wasn't considering that we used an "official" format. In that case
yeah, it would complicate matters to start changing. If something were to
be "bundled" with Xdrip however I would resume this discussion.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/NightscoutFoundation/xDrip/issues/261#issuecomment-357483203,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AL8BPbU0uVgMiIsv4UAIK40P5HFMWwEaks5tKWLggaJpZM4RVT2J
.
@raymond-richmond I could add an extra field to indicate whether xDrip is set to mmol/mgdl so that the watchface can assume the same conversion without requiring the user to specify it.
For all developers I have updated the documentation which explains how to use the heart rate and tasker endpoints and how to trigger those from the sgv endpoint. Also note the new OSNOOZE tasker feature which would be suitable for uncontrolled button presses on the watchface.
For reference @swissalpine has published the garmin watchface which can be obtained here: https://apps.garmin.com/en-EN/apps/fc892009-996a-4907-b277-0c5bfa6fdab2
does'nt seem to work with my garmin fenix3hr. i'dont' know if there are any additional permitions are needed.
Hi Klaus,
can you describe your problem. Do get an error with the code 2?
Then you have to downgrade Garmin Connect Mobile. As you can read in Google Play Store the actual version has massive problems with bluetooth connections. I'm fine with this Version:
https://www.apkmirror.com/apk/garmin/garmin-connect-mobile/garmin-connect-mobile-4-1-5-release/garmin-connect-mobile-4-1-5-android-apk-download/
If the app crashes then please deinstall and reinstall the app. I've build a new version.
Regards
Andreas
And: Have you activated the web service feature in xDrip+? Do you have the actual nightly?
What have you done? I was already on Connect 4.1.5 and reseted the watch and my phone multible times. Still only got the IQ! Screen. I reinstalled the app on the watch and now it works. But before and after reinstallation its version 1.21.
The shown version in Garmin Connect Mobile App is the last version in the app store, not the installed one. ;-)
I haven't secured the case if the json-response contains no aaps strings. I expected that the string will be empty but part of the response. This should be fixed now.
I'm happy to read that the app does its works now.
Thanks for your work.
One very minor thing: Your app seems to round differently than xdrip.
Your app just cuts off the decimals, or the xdrip web service does this.
But the values are not the same very often.
Yes. That's possible and it's the same thing if you look at the readings in Nightscout. There are also sometime different than xDrip.
Are you using mmol?
That's the only thing I can influence and my formula could be an other than xDrip.
No, i'm using mg/dl. It's just a diffence of max 1 mg/dl, so not a big deal. But it confuses a bit if you look on your watch and then on your phone and its not the same.
I've looked in the code. @jamorham constant MG_DL_TO_MMOL_L is 0.05556, mine is 0.0555. I will update this but I don't think that's a big deal ...
Garmins SDK is restricted in mathematics, so I couldn't do so much.
But if Nightscout and xDrip differs (at this moment Nightscout: 86 mg/dl, xDrip 87 mg/dl) and we think about the relliability of CGM readings I think that not a big thing ...
Oh, and I don't round mg/dl values. That's the json output which I take unchanged and I could not influence (and I think the same difference as between Nightscout and xDrip). You can see the xDrip
output in your smartphone browser by entering 127.0.0.1:17580/sgv.json
@Klaus3d3 Which device are you using?
I've tested it myself on vivoactive, vivoactive hr and fr 920xt.
fenix3hr
@jamorham what are the chances that the units field could be included in the nightscout feed as well? I like the idea but if someone points the web call to their nightscout (which I could see in various scenarios) then without that we would still need to provide a toggle in the watch settings.
@raymond-richmond @Rytiggy @swissalpine in the sgv.json endpoint provided by xDrip I have added a units_hint in the first record as described below. You could use this to set your watch face units automatically to follow what xDrip is set to.
The first record will contain a hint as to the units being used, units_hint will be mgdl or mmol to indicate the user's preference but the values will always be sent as mgdl
I've just ordered a Fitbit Versa (due to arrive in about two weeks) which seems to use the Ionic OS. Did the Ionic integration get anywhere? The versa looks a lot like it could be a good replacement for the pebble.
@tim2000s hey! Congrats in the new versa, I haven't tested on a versa yet only my ionic but I have a working watch face here on my repo https://github.com/Rytiggy/api-watchface
You should be able to pull in the code and load it on your watch.
Side note I'll be releasing version 1 of my watchface soon, next few weeks. And v1 will be compatible with both watchs.
@Rytiggy I just got a Fitbit ionic and in desperate to pull the xdrip data onto the watchface, but I have ZERO coding experience to even begin the process of using your code (thank you by the way).
Any chance you could help me out with this? Be it a written tutorial or a Skype meeting, I'm determined to make it happen and your feedback is welcome (and appreciated).
Thanks!
@vpwagner I just made a how-to guide you can follow here: https://github.com/Rytiggy/api-watchface/blob/master/howto.md
Hey guys I just released a new version of my watch face. I'm calling it Glance, Check out out!
https://github.com/Rytiggy/Glance
Wow, that looks awesome. Time for me to get a watch. Will it work with a Versa?
@gitanO0 Thanks! I just updated the repo to make it super easy to install. Just follow these steps.
https://github.com/Rytiggy/Glance#user-setup
I haven't tested on a Versa yet but I have used the simulator, so it should work. let me know how it goes and if you need any help!
@jamorham We might be able to sideload it now?
Hi new to all this and not very tech savy can someone point me in the right direction in how i get my sons data onto my versa iam using the 600 series uploader for nightscout. Ive got the watch face up on my versa but it just says loading where bgl should be.
Thanks
@ryanwalker9 Hey I'm glad you're using the watchface! The next step for you would be to set up a web services so you can tell the watch where to read Dada from.
If you are using xDrip which I recommended ( your setup sounds similar to mine, (670g with a gardian sensor)
In xDrip, Navigate to Settings -> Inter-App settings -> xDrip Web Service -> ON
Open up glances settings and enter this url http://127.0.0.1:17580/sgv.json in the API endpoint settings input box and set your high and low thresholds and you should start seeing bgs on the watchface
@ryanwalker9 Further, if you are using xDrip+ I believe you need to be using the "nightly" release which has an embedded web server that needs to be turned on as @Rytiggy outlined. Not sure if the "public" release has it yet. And if you are not using xDrip+ you need to point the watch face configuration to the appropriate URL for your nitescout site, likely https://
Has anyone gotten any traction on getting heart rate and steps data out of fitbit device, through the companion app and then back into xdrip+? Would love to get that working but don't quite know what the code should look like. I'm comfortable writing code for a fitbit versa/iconic watch face and getting xdrip/nightscout data to the watchface (thanks to all of @Rytiggy work on that front), but going the other way ??? I know xdrip will take that local web service URL with the appended ?heart=xxx&steps=xxx syntax but how to pass that data from the fitbit device, to the companion and then have the companion app send that URL for xdrip to pickup?
Yes, but I haven't released it generally on my watch face as nightscout receipt of the data directly is still different. Fundamentally it is exactly the same with a URL get from the companion as outlined by @jamorham above. I'm using a timer on the ionic/versa to trigger a data request from the watch and at the same time push the current steos/HR values.
Ok, Thanks. I've got it working now. Sending heart and step data back to xdrip+.
Still hoping for this to make it into the main branch :)
@Bard09 what do you mean? The nightlies from June time are included in the main release from September.
@jamorham So xDrip+ is currently able to gather Step/HR data from Fitbit devices? I'm on the xDrip beta channel and running the 2018.09.08 version and haven't seen any of the HR/step data appearing.
I have the Web Service turned on and have all of the Health Data/HR options enabled.
@Bard09, in the pre-release version of Glance, it supports sending the HR/steps back to xDrip. I plan to release it later this month :)
@Rytiggy You beautiful beautiful dev. Sorry for the confusion @jamorham. I already use Glance so that's exciting!!
Do you guys think it is possible to develop a websocket server in xDrip+ which, as soon as new glucose data comes from the collector, pushes it to the connected clients (say, a FitBit app)?
Data sync between the watch and the phone would be almost instantaneous, wouldn't it?
There would be no need of polling the web service every n minutes.
I've been browsing the sources of Glance to understand how it gets and updates data and that websocket idea just came to me.
Does it make sense to you?
Most helpful comment
I have been working on a watch face for the Fitbit ionic that will display blood sugars that just takes in a REST API URL, its functional now but needs some refactoring. definitely going to publish it once I finish it up. here's where it's at now.
