01-26-2020 04:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-26-2020 04:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I made an app on my Fitbit Versa 2 where I can control my garage door. It fetches an URL on my raspberry which triggers the garage. Sometimes nothing happens as the companion app is not running due to synchronisation errors (on the same time alexa is not working on my watch either).
Is there any way to test if the companion app is running and displaying the status? So I know if I have to get out my keys for the garage instead of the app.

01-27-2020 13:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-27-2020 13:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
It sounds like the Fitbit mobile app is being killed due to battery optimization on your phone. Check your phone settings.

08-02-2021 17:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-02-2021 17:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
But how can we check if the companion is active, Messaging API still reads the socket as open even though messages sent aren't received by the companion in 4.3.0
08-02-2021 17:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


08-02-2021 17:16
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Put code in the companion to reply to messages. In your device, ensure that replies are received within a reasonable period of time.
Gondwana Software

08-02-2021 19:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-02-2021 19:08
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Sounds good, however is there an event that knows when the companion becomes active from inactive? I just don't want to drain battery with message callbacks, and timely inform the user when the device is connected with the companion

08-02-2021 19:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


08-02-2021 19:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You could try onclose and maybe onerror.
Gondwana Software

08-03-2021 00:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-03-2021 00:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Is there one for when the companion becomes active?

08-03-2021 10:18 - edited 08-03-2021 10:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-03-2021 10:18 - edited 08-03-2021 10:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
This may not be exactly what you are looking for, but here's what I do to talk to my companion:
import { peerSocket } from "messaging";
const err_element = document.getElementById("err_element");
//send message to companion
function sendMessage() {
if (peerSocket.readyState === peerSocket.OPEN) {
// Send to the companion
peerSocket.send("Whatever I want");
}
else {
console.log("CONNECTION CLOSED");
err_element.style.display = "inline";
err_element.style.fill = "red";
}
}
// Listen for messages from the companion
peerSocket.onmessage = function(evt) {
console.log(evt);
}
// Listen for the onopen event
peerSocket.addEventListener("open", (evt) => {
// console.log("Ready to send or receive messages");
});
// Listen for the onerror event
peerSocket.addEventListener("error", (err) => {
console.log("Connection error: " + err.code + " - " + err.message);
});
Maybe you can rig something up that'll send a message every X seconds/mins or something to check connection, then if it fails, set an icon on your fitbit to a different color (which is what I do)

08-03-2021 14:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-03-2021 14:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
That is a viable choice, however the problem is that if the user turned on their phone and their phone becomes active, it may take a few minutes.
Another consideration is that how frequent it checks also impacts battery.
I'm currently using Appbit API for the unload event, but where is the event when the companion becomes active is my question.

08-03-2021 15:23 - edited 08-03-2021 15:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


08-03-2021 15:23 - edited 08-03-2021 15:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
In its startup code, you could get the companion to send a message to the watch.
However, the companion will only start when it needs to; eg, receiving a message or file, user starts settings, or wake interval.
Gondwana Software

08-03-2021 15:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-03-2021 15:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Ooh okay, sounds interesting
Will find out later today

08-04-2021 15:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-04-2021 15:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You maybe could also use the launchReasons to detect why the companion has launched. Companion Guide (fitbit.com)

08-15-2021 03:43 - edited 08-15-2021 03:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

08-15-2021 03:43 - edited 08-15-2021 03:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
dismiss reply will try later

