05-12-2021 15:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-12-2021 15:03
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
This is my GUI. My GUI app
Code for GUI (frontend):
from tkinter import *
from tk_tools import *
from tkinter.ttk import *
from tkinter import messagebox
root=Tk()
root.title('Fitbit Dashboard')
root.grid()
hr=RotaryScale(root, max_value=(220-age), unit=' BPM Heart rate')
steps=Gauge(root, max_value=10000, label='steps', unit='', red_low=20, yellow_low=30, red=100, yellow=100)
steps.grid(column=2, row=1)
cals=Gauge(root, max_value=2400, label='calories', unit='', red_low=20, yellow_low=30, red=100, yellow=100)
cals.grid(column=4, row=1)
dist=Gauge(root, max_value=5, label='distance', unit=' mi', red_low=20, yellow_low=30, red=100, yellow=100)
dist.grid(column=3, row=1)
actmins=Gauge(root, max_value=30, label='active minutes', unit='', red_low=20, yellow_low=30, red=100, yellow=100)
actmins.grid(column=5, row=1)
hr.grid(column=1, row=1)
hr.set_value(0) hrEntry=Spinbox(root, from_=0, to=23, state='readonly')
hrEntry.grid(column=7, row=1)
minEntry=Spinbox(root, from_=0, to=59, state='readonly')
minEntry.grid(column=8, row=1)
addbutton=Button(root, text='Add Alarm', command=add_alarm) a
ddbutton.grid(column=9, row=1)
lo_bat=Led(root, size=50) lo_bat.grid(column=4, row=2)
lo_bat.to_red(on=False)
Label(root, text='Battery low when lit').grid(column=4, row=3)
Pseudocode for backend:
def add_alarm():
if all textboxes filled:
add alarm and notify user via messagebox
else:
show error via messagebox
while True:
set cals needle to cals burned
set steps needle to steps
set heart needle to current heart rate
set active minutes needle to active minutes
set distance needle to distance walked
if battery<=17:
turn on LED
else:
turn off LED
How do I turn the needles of the gauges on my GUI according to Fitbit stats, light the low battery indicator when the Fitbit's battery runs low, and add an alarm when pressing the "Add Alarm" button? In other words, how do I do my pseudocode in Python? The gauge's needles turn to show live data.
05-12-2021 15:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-12-2021 15:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The Web API doesn't provide live data. It's only updated whenever the device syncs, so could be 20 minutes or so behind.
Gondwana Software

05-12-2021 15:31
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-12-2021 15:31
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
If not, how do I get the data (steps, calories, dist. active mins) from the last day and light the "Low Battery" LED as mentioned?

05-12-2021 15:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-12-2021 15:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You can probably get yesterday's data (so long as it's not just after midnight). If you want current (near-real-time) data, you'll need to use the device and companion APIs.
Gondwana Software

05-12-2021 15:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-12-2021 15:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Gondwana Then how do I light the "Battery Low" LED when my Alta HR battery runs low, and how do I capture the last synced data?

05-12-2021 15:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-12-2021 15:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Can I light the "Low Battery" LED when the battery gets low?

05-12-2021 15:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-12-2021 15:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Oh sorry, I didn't realise this was about Alta. You can't use device and companion APIs with Alta.
Gondwana Software

05-12-2021 15:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-12-2021 15:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Gondwana What libraries/variables should I use to detect a low battery on my fitbit and light the "Low Battery" LED?

05-12-2021 15:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-12-2021 15:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Check whether battery charge is exposed in the Web API. I suspect it isn't.
There may be Python libraries you could use to help with the Oauth flow. If so, they'll be mentioned in the Web API documentation site.
Gondwana Software

05-13-2021 09:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



05-13-2021 09:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
As @Gondwana described, you may use the Fitbit Web APIs to pull the device data after the device syncs with the mobile application. This includes querying the activity data for the previous day. We do not have a Web API to turn on a low battery light. My understanding is low battery notifications are managed by the device itself. However, you may use the Get Devices endpoint, https://dev.fitbit.com/build/reference/web-api/devices/#get-devices, to find out a device's battery life. From there, you could send an additional notification through your mobile application recommending the user charge their device.
Gordon
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

