MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Fitbit

    Scheduled Pinned Locked Moved Troubleshooting
    129 Posts 42 Posters 200.8k Views 37 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Hellangel1987 @olliewarren411
      last edited by

      @olliewarren411

      good job buddy now it works but i dont get any numbers :(

      alt text

      O 1 Reply Last reply Reply Quote 0
      • O Offline
        olliewarren411 @Hellangel1987
        last edited by olliewarren411

        @Hellangel1987
        No Problem.

        When you run #sudo python setupAccess.py# on the python directory inside the MMM-fitbit folder does it redirect you to log into you fitbit account in an internet browser?

        Also what fitbit model are you using? I tried this with a fitbit alta and it didn’t work. Then I tried with my fitbit ChargeHR and it works perfect* see attached. I changed the CSS to display vertically.
        0_1471979871787_IMG_4570.JPG

        *i say it works perfect i just need a way to keep the connection to my fitbit account over a long period of time without having to re-run sudo python setupAccess.py on the python directory once a day.

        H T 2 Replies Last reply Reply Quote 0
        • H Offline
          Hellangel1987 @olliewarren411
          last edited by

          @olliewarren411

          Im using The Fitbit Charge HR

          O 1 Reply Last reply Reply Quote 0
          • O Offline
            olliewarren411 @Hellangel1987
            last edited by

            @Hellangel1987
            When you run #sudo python setupAccess.py# on the python directory inside the MMM-fitbit folder does it redirect you to log into you fitbit account in an internet browser?

            1 Reply Last reply Reply Quote 0
            • H Offline
              Hellangel1987
              last edited by

              @olliewarren411

              yepp works perfect. i have the token and autorized that app in browser.
              after that i startet mirror with sudo npm start. but only zero numbers are shown :(

              Did i have to do this once a day? Any cronjob for that ?

              O 1 Reply Last reply Reply Quote 0
              • O Offline
                olliewarren411 @Hellangel1987
                last edited by

                @Hellangel1987

                Sorry I’m out of ideas then.

                Cronjob? I’m pretty new to this.

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Hellangel1987
                  last edited by

                  @olliewarren411 can you describe your steps and your configs ? i think there is any missconfiguration in my credentials config i think soo.

                  O 1 Reply Last reply Reply Quote 0
                  • O Offline
                    olliewarren411 @Hellangel1987
                    last edited by

                    @Hellangel1987

                    I cant easily explain as I had to play around a lot to get it to work… and then it just did.

                    When setting up your app on the fitbit website did you get the below steps?

                    Check browser and personal for OAuth settings
                    Callback URL MUST BE http://127.0.0.1:8080/
                    Give your app read & write permissions (read-only untested)

                    I could not set the Personal and OAuth settings until I got my personal URL wrong. When the page reloaded these two extra options appeared.

                    H 2 Replies Last reply Reply Quote 0
                    • H Offline
                      Hellangel1987 @olliewarren411
                      last edited by

                      @olliewarren411

                      i set it all on that page. exeption was my location. but all other options are set.

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Hellangel1987 @olliewarren411
                        last edited by

                        @olliewarren411

                        works! i sued your code. Delete the token. set it up new - start it with sudo npm start in MagicMirror directory. -> WORKS!

                        I think i missunterstand the fibit API page where you have some buttons tu push and autorize the app (i think i pushed them in the wrong way)…

                        You sayed something about your token.ini -> can you explain what exactly you have to to every day? i think about an cronjob for that - good chance to solve that together!

                        And another option is the weight of my fitbit ARIA, these data are also available - how can we bind them into the app ?

                        O 1 Reply Last reply Reply Quote 0
                        • O Offline
                          olliewarren411 @Hellangel1987
                          last edited by

                          @Hellangel1987
                          Glad to hear you got it working.

                          I’m just trying to get the module to refresh more often. Not sure how to go about it.

                          You probably could get your weight data in too, you’d need to contact the creator of the module for that.

                          K 1 Reply Last reply Reply Quote 0
                          • K Offline
                            kckndrgn @olliewarren411
                            last edited by

                            @olliewarren411 said in Fitbit:

                            Yes, you can change the refresh interval. In the script MMM-fitbit.js you’ll see

                            start: function() {
                            		Log.info('Starting module: ' + this.name);
                            		this.sendSocketNotification('SET CREDS',this.config.credentials)
                            		this.sendSocketNotification('GET DATA', 'intial');
                            		
                            		this.fadeSpeed = 500;
                            		
                            		// Schedule update interval.
                            		var self = this;
                            		setInterval(function() {
                            			self.updateData();
                            		}, 60*60*1000);
                            },
                            

                            change the 60 x 60 x 1000 to an interval of your choosing. Just be careful to to refresh too often as you’ll get emails from FB telling you that you are pulling too much data. I think (and I’d have to check tonight) that I have mine set to 15 x 60 x 1000.

                            O 1 Reply Last reply Reply Quote 0
                            • O Offline
                              olliewarren411 @kckndrgn
                              last edited by

                              @kckndrgn

                              Thanks! works perfect. I’ve copied your set up so it refreshes the data every 15 mins.

                              1 Reply Last reply Reply Quote 0
                              • P Offline
                                plumcraft
                                last edited by

                                I was getting invalid redirect_uri during the setup process. (sudo python setupAccess.py)

                                But now It’s working for me, great module !

                                1 Reply Last reply Reply Quote 0
                                • K Offline
                                  kckndrgn
                                  last edited by

                                  Anyway to get around having to run the setupAccess.py everyday/every other day to keep the tokens fresh?
                                  Since I have to stop the MM from running, run the script to get new token, start MM again, it gets kind of annoying. I also run my Pi w/o keyboard/mouse so when I need to refresh the tokens I have to connect them.
                                  I thought about adding a cron job to stop the MM, run the script and start MM, thoughts? Since the script leaves a browser window open, can the cron job kill it or is there a way to have the python script close the window when done?

                                  TIA

                                  H 1 Reply Last reply Reply Quote 0
                                  • H Offline
                                    Hellangel1987 @kckndrgn
                                    last edited by

                                    @kckndrgn

                                    dont know exactly but im also interested in your cronjob solution, can you inform us about your steps ? im tired getting every day that setupaccess working :(

                                    K 1 Reply Last reply Reply Quote 0
                                    • K Offline
                                      kckndrgn @Hellangel1987
                                      last edited by

                                      @Hellangel1987 said in Fitbit:

                                      @kckndrgn

                                      dont know exactly but im also interested in your cronjob solution, can you inform us about your steps ? im tired getting every day that setupaccess working :(

                                      I haven’t done it, yet, just thinking about it since it was mentioned. I think I’ve narrowed down the issue though:

                                      {"message": {"401": {"errors": [{"message": "Access token expired: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI0NU5QMzUiLCJhdWQiOiIyMjdRVjkiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJzY29wZXMiOiJ3aHIgd3BybyB3bnV0IHdzbGUgd3dlaSB3c29jIHdhY3Qgd3NldCB3bG9jIiwiZXhwIjoxNDcxNzAxNjYzLCJpYXQiOjE0NzE2NzI4NjN9.VvLWtyYYvVShgrWC4UOVMXfdv0uiy7Nic-WDj7RMiKA. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process.", "errorType": "expired_token"}], "success": false}}, "type": "error"}
                                      {"message": "Getting a new access token", "type": "status"}
                                      {"message": "Error getting new access token", "type": "error"}
                                      {"message": {"400": {"errors": [{"message": "Refresh token invalid: 4292cf037821b9441122e432bdd92a238fac61028dfbd6be982d2e6b73474c32. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process.", "errorType": "invalid_grant"}], "success": false}}, "type": "error"}
                                      

                                      First got an “expired” token notice, then the process tries to get a new token (possibly using the “refresh” token, I’m not sure at this point). But refresh tokens are valid for one use only, so it’s like the updated token is getting updated in the token.ini file.

                                      1 Reply Last reply Reply Quote 0
                                      • P Offline
                                        plumcraft
                                        last edited by

                                        Also interested with the cron mechanism, the module could execute the setupAccess process once a day and trigger a reload on the gui ?

                                        I’m using vnc to connect remotely on the RPI since i don’t have mouse/keyboards connected.

                                        1 Reply Last reply Reply Quote 0
                                        • K Offline
                                          kckndrgn
                                          last edited by

                                          3 days of syncing without an issue. Not sure what changed, I did pull the latest dev code for MM but made no changes to the fitbit module.
                                          (of course now that I’ve said this, it will error out during the day :) )

                                          1 Reply Last reply Reply Quote 0
                                          • K Offline
                                            kckndrgn
                                            last edited by

                                            Had my first issues in a while last night. The problem was that my router lost internet connection and when it was restored the tokens were expired. I ran the setupAccess.py and got new tokens.
                                            Seems that there should be a better way to reset the module on restart, like if the tokens are expired, the go get new ones.

                                            1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 3 / 7
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy