[Under review] Fitbit - Start sleep tracking when companion app is launched on the watch

First of all, thank you so much for creating this wonderful application.
I was wondering if it is possible to launch sleep tracking when companion application is launched on Fitbit device.
Thank you so much once again.

Thanks .]

It would be kind of possible, but it’s something we’re reluctant to do - the reasons are in the architecture of Fitbit’s communication stack. .

Let me explain:
Fitbit doesn’t support any native communication with apps. When an app on the watch is started, a javascript process is launched inside the official Fitbit app, which can communicate with that watch app.
It can also communicate with something else using http (web) calls. What we do is run a local webserver inside Sleep as Android, which can be called from this javascript process.
However the webserver has to be running at the time when you want to call it.

So here you go - you have to know when to start the server in order to get message from the watch that sleep tracking should start.
So you have either to start the server manually at the time sleep tracking begins - that’s the current state.
Or you would need to have the webserver running the whole day in the background. This would not be necessarily a bad thing from a technical standpoint - it wouldn’t drain any battery while it’s just listening for messages.
However Google wants us to display a persistent notification in order to keep something like this running for longer than 5 seconds. Which would annoy the hell out of users, I assume.

1 Like

Thank you so much for your prompt reply and wonderful and easy to understand explanation.

I don’t know if this is possible but I often see notification saying that Sleep is waiting for Fitbit to be found, which I think is depend on phone activity around my sleep time. I may be wrong and you are best person to answer that.

Though, can we work out that I can set the time at which Sleep would automatically start the server to receive message? So, there won’t be any persistent notification all day?

I used to have Mi Band 3 and coupled with Notify app it worked great. I don’t recall correctly but it was automated, again I might be wrong because it is quite a long time since I last used Sleep with Mi Band.

Thank you for the support! <3