Fitbit nodes - working?

Continuing the discussion from Fitbit - anyone have it working with node red?:

There are a couple of nodes available for Fitbit.

Has anyone got either of them working recently?

Neither node seems to have had any love recently judging by the release dates.

In answer to my own question, I have found the following -

The 'official node' (node-red-node-fitbit (node) - Node-RED) does not seem to want to authenticate. it looks like it is old (last release says nearly 12 years) and FitBit have updated their authentication methods. Maintainer is listed as @dceejay but that may be as it is also part of a wider set of flows.

There is a contrib node (node-red-contrib-fitbit (node) - Node-RED) but again has not had any updates recently. It may work, but I could not get the right callback URL.

However, there is a fork of the contrib node (GitHub - inglevir/node-red-contrib-fitbit) which does work and has had some recent updates to it.

You do need to set your Node-RED instance up using https, but other than that the authentication worked first time and it usefully provides the correct callback URL.

Is there any appetite to get a 'core' node working well and develop the data recovered from the API? My JS is not up to it, but happy to test :slight_smile: .

I'd also like to write data to FitBit as well.

The forked node does what I need right now (which was to get the Battery Level) so I can trigger some reminders to charge/take off charge which was my primary driver at the start of this.

[edit]
After more investigations, it is clear these nodes are designed to work with an old API that only probably still works as it is a legacy format. Take a list of activities (API Docs Get Activity Log List) the API docs suggest the URL should be of a format such as;

https://api.fitbit.com/1/user/-/activities/list.json?afterDate=2019-01-01&sort=asc&offset=0&limit=2

The forked node is generating a URL like (ignore the distance parameter)

https://api.fitbit.com/1/user/-/activities/distance/date/2021-12-22/7d.json

I suspect changing the format might be relatively easy if I understood enough JS. I think probably the nodes need an extensive update to match the API.

Indeed - the "core" node was contributed to the project by a small team at IBM many years ago. I don't have a fitbit (and have no interest in getting one) so the node is just sitting there as part of that larger collection. I guess we should really delete/remove it... but if you feel like playing with it and trying to update it then we would be very grateful. More than happy for you to take it as a learning exercise. It certainly can't be more broken than it is already :slight_smile:

I suspect what I primarily need is someone to help with a template on how to create the right URLs based on the input selections. I can work out most of what is going on but not how the actual URLs are generated (so moving from a /xxx/ to a &xxx= format).

I think moving it out of this combined contrib node might be a good idea and making it standalone. I'd be happy to be guided on how to make a contribution to it. I think the fork I mentioned above would be the best place to start as the authentication does actually work.

If anyone is interested I have created an updated node and called it fitbit2 as it is probably not backward compatible.

Works better with the HA Node-RED addon (key task), extended the API EndPoints serviced and improved the help/documentation.

Still needs some more work, but functional for now.

1 Like