01-02-2022 05:50
01-02-2022 05:50
Hi everyone,
My Fibit Versa 3 won't display the stats (steps, hr, cals) when I run my code but the simulator will. You can see this below, the left is the simulator and the right is mine
(Ignore the HR not appearing in the simulator, I have fixed that but that didn't change the lack of stats on my watch.)
Here is my JS code:
import clock from "clock";
import * as document from "document";
import { preferences } from "user-settings";
import * as util from "../common/utils";
import { me as appbit } from "appbit";
import { today } from "user-activity";
import { HeartRateSensor } from "heart-rate";
import { BodyPresenceSensor } from "body-presence";
/*if (HeartRateSensor && appbit.permissions.granted("access_heart_rate")) {
const hrm = new HeartRateSensor();
hrm.start();
}*/
const myHRM = document.getElementById("myHRM");
// Update the clock every minute
clock.granularity = "minutes";
// Get a handle on the <text> element
const myLabel = document.getElementById("myLabel");
// Update the <text> element every tick with the current time
clock.ontick = (evt) => {
let today = evt.date;
let hours = today.getHours();
if (preferences.clockDisplay === "12h") {
// 12h format
hours = hours % 12 || 12;
} else {
// 24h format
hours = util.zeroPad(hours);
}
let mins = util.zeroPad(today.getMinutes());
myLabel.text = `${hours}:${mins}`;
}
const mySteps = document.getElementById("mySteps");
const myCalories = document.getElementById("myCalories");
if (appbit.permissions.granted("access_activity")) {
console.log(`${today.adjusted.steps} Steps`);
mySteps.text=`${today.adjusted.steps}`;
if (today.local.calories !== undefined) {
myCalories.text=`${today.adjusted.calories}`;
console.log(`${today.adjusted.calories} calories`);
}
}
const hrm = new HeartRateSensor();
if (HeartRateSensor) {
const hrm = new HeartRateSensor({ frequency: 1 });
hrm.addEventListener("reading", () => {
myHRM.text=`${hrm.heartRate}`;
});
hrm.start();
}
And the index.view
<svg class="background">
<image href="plants01.jpg" />
<text id="dayLabel"></text>
<text id="myLabel"></text>
<svg id="stepsLoc" >
<image id="stepsIcon" href="steps_36px.png" load="sync"/>
<text id="mySteps"></text>
</svg>
<svg id="hrmLoc" >
<image id="hrmIcon" href="heart_rate_36px.png"/>
<text id="myHRM"></text>
</svg>
<svg id="caloriesLoc" >
<image id="caloriesIcon" href="calories_36px.png"/>
<text id="myCalories"></text>
</svg>
</svg>

Best Answer01-02-2022 06:50
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
01-02-2022 15:11
01-02-2022 15:11
Hi Guy, thanks for the reply. I have all permissions in the package.json files ticked (except the App Cluster Storage).
I've actually tried using someone else's code from github and still having the same issue =(
Best Answer01-04-2022 08:16
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
01-04-2022 08:16
As Guy_ said, you should move things inside the tick event, but what's in the CSS file? Make sure you're using the System font family. https://dev.fitbit.com/build/guides/user-interface/css/#fonts
01-04-2022 23:12
01-04-2022 23:12
Having the same problem... Heart Rate and Clock shows up fine but anything from Web API don't show. But works beautifully on Studio.
(I'm on a Sense btw, if that helps at all)
Best Answer01-04-2022 23:49 - edited 01-04-2022 23:49
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more
01-04-2022 23:49 - edited 01-04-2022 23:49
01-05-2022 17:33
01-05-2022 17:33
I turned off firewall and any kind of security for a moment and tested it, it still didn't work. If that were the case then why would it work on the Simulator still?
Best Answer01-05-2022 20:27
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
01-05-2022 20:27
Make sure all necessary permissions are set in package.json (or Studio). Sim doesn't check permissions; watch does.
01-05-2022 23:54
01-05-2022 23:54
Excuse me while I bury my head in embarrassment... But you did point me in the right direction! I didn't think to click "Internet" in the requested permissions in package.json. That apparently allows specifically the Companion app to communicate with the database. Thanks!
@Gondwana wrote:Make sure all necessary permissions are set in package.json (or Studio). Sim doesn't check permissions; watch does.
01-06-2022 00:05
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
01-06-2022 00:05
Yeah, the oauth and the data fetch definitely use the internet.
Best Answer