Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fitbit OS Sense calling out to get data from website

ANSWERED

Hey all new to the world of Fitbit apps.

 

My wife has the Sense and wears it constantly. Recently we started parking our car in the garage and we have to push the garage door controller so that the garage door starts opening when we go out to get into it. No issues with closing it or opening it when we are inside the car though.

 

Before I go digging and taking a lot of time with learning the Fitbit OS dev I need to know one thing so my question is this:

Can the Sense run the app (be it in the background or something along those lines) that calls out to my own web server and send a command to it via an API call (ex: https://mydomain.com/v1/call/message_to_send_here&SenseUniqueID) and it listen to the returned message from my web server (If the garage door is opened or closed)? Does the Fitbit OS/Sense have what's needed to accomplish that? She will always have her iPhone with her when she has the Fitbit on just in case that was a need in order to make this feasible. If I can get the GPS location and check if its near the garage door then I could just use the GPS location to determine when to send and receive the API call.

 

Ether way I go I would need to know if I can send the API call to my web server or none of this will work.

 

Thank you for taking the time to read this and I hope I get some good news 🙂

Best Answer
1 BEST ANSWER

Accepted Solutions

Yes, the companion component is a part of a Fitbit project that you can create in Studio.

The companion component should be started automatically whenever a communication is sent to it from the watch. So long as there's a Bluetooth connection between watch and phone (eg, it could sync), your companion should do its thing without needing to touch the phone.

Long-press on the watch can be used to start an app on the watch. If that app sends a comm to its companion component, the latter should then start.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
7 REPLIES 7

Goodish news: yes, you can do at least most of that. Briefly, the architecture would be that an app on the watch would communicate with its companion code on the phone. Your companion code would need to use fetch() to call your API and receive its response, which it could then communicate back to the watch app.

 

You mentioned running in the background. Fitbit doesn't support that. Only one watch app/clockface can be running at any point in time.

 

I'm not sure you'd want your app/clockface to have the GPS running continually; I suspect that would drain the battery fairly quickly.

Peter McLennan
Gondwana Software
Best Answer

Thanks for the quick response there @Gondwana 

 

So this companion app on the phone? Is that also created from the Fitbit Studios? Would I have to start the app on the phone every time I want to send something to my web server and back? I've noticed in YouTube videos that there's a shortcut you can do to start an app (Press/hold the left side of the watch for a second or so) and it will start the app on the phone - if I am correct about that.

Best Answer

Yes, the companion component is a part of a Fitbit project that you can create in Studio.

The companion component should be started automatically whenever a communication is sent to it from the watch. So long as there's a Bluetooth connection between watch and phone (eg, it could sync), your companion should do its thing without needing to touch the phone.

Long-press on the watch can be used to start an app on the watch. If that app sends a comm to its companion component, the latter should then start.

Peter McLennan
Gondwana Software
Best Answer

Moved post to the SDK forums

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer

Thanks for all your help so far. @Gondwana 

so let me make sure I’m reading this correctly. 

1) I swipe on the watch and click on my app icon. 

2) App starts in the watch and has one simple button with text. 
3) The button is pressed. 
4) Button press sends command to the companion app on the phone even if the apps not running (or has focus). 

5) Code in the companion app send the command to my web server via http. 
5) Web server reply’s back to the companion app. 
6) The companion app then send that replay to the watch. 
7) The watch displays what was sent back and changes button text with the returned value. 

Best Answer

Basically, yes. Some subtleties:

Re 1: Yes, and/or you could set up your app as a 'shortcut' (see settings on watch).

Re 2-4: Yes, or you could make the app initiate the communication automatically as soon as it starts (which may be undesirable).

Re 4: Yes, but the Fitbit mobile app will need to be running on the phone, although it can be running in the background (which it normally does). There would also need to be a bluetooth connection twixt watch and phone. Basically, if the watch can sync, your app comms should work too.

Re 5: Companion apps on Android can only use http to access some specific IPs that equate to localhost (ie, same device). If your server is running on a difference device (which is highly likely), you'll need to use https (not self-signed). iOS may be less restrictive; I don't know.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Bonus unsolicited suggestion: if I were doing this, I'd get step(s) 5 going first, with just enough code elsewhere to make it happen (you may not need anything at all in the clockface app/index).

Reason: steps 5 are the hardest bits. If it's going to prove impossible, that will almost certainly be where. If you can get steps 5 working, everything else is straightforward.

Peter McLennan
Gondwana Software
Best Answer
0 Votes