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.
    • M Offline
      MechMatt @Vendittelli
      last edited by

      @Vendittelli I’ll be happy to assume the role here as the guy who makes sure everything is idiot proof :D

      VendittelliV 1 Reply Last reply Reply Quote 1
      • VendittelliV Offline
        Vendittelli Module Developer @MechMatt
        last edited by

        @MechMatt I put a basic run through on the wiki page, feel free to adapt it to make it more new user friendly

        MichMichM 1 Reply Last reply Reply Quote 0
        • MichMichM Offline
          MichMich @Vendittelli
          last edited by

          @Vendittelli Thanks!

          1 Reply Last reply Reply Quote 0
          • ? Offline
            A Former User
            last edited by A Former User

            Would something similar be possible with Google Fit? There’s a REST API: https://developers.google.com/fit/rest/

            1 Reply Last reply Reply Quote 0
            • A Offline
              ascension
              last edited by

              This Module is driving me insane… Magic Mirror doesn’t start if I add the module script to my config.js as it is written in the example config.js. I can only get it to work by removing “Credentials: {” ,replacing the “[” from the previous line (config:[) with “{” and replacing the matching “]” with"}" . Magic Mirror will then run with the fitbit module displayed on screen with zeros for every field. It simply won’t update. I get “null” value errors and the .py script overwrites my credentials.ini file with empty spaces, I assume because of the missing “credentials” line in my config.js. I simply cannot make it work with any modification of the “credentials” line that I’ve tried. I’d really appreciate some help on this…

              A 1 Reply Last reply Reply Quote 0
              • A Offline
                ascension @ascension
                last edited by

                @ascension
                Made some progress by replacing braces with swirly brackets. The script moves further along and my credentials.ini gets updated. Running setupAccess.py is sucessful, it brings up a fitbit page which requests authorization, but even when I approve it, tokens.ini isn’t populated, fitbit app reads all zeros, and terminal returns error " There was an uncaught exception…{ [Error: process exited with code 1] executable: ‘python’, options: null, script: ‘modules/MMM-fitbit/python/getdata.py’, args: null, exitCode: 1}.

                1 Reply Last reply Reply Quote 0
                • M Offline
                  Maldras
                  last edited by

                  same problem

                  A 1 Reply Last reply Reply Quote 0
                  • A Offline
                    ascension @Maldras
                    last edited by ascension

                    @Maldras
                    I’ve mostly resolved the issue. I’ve still got to work out an issue with my access token not updating, but I think that may be down to an intermittent connectivity issue. My resolution started with the knowledge that the documentation for the module is a bit lacking… there is a list of underlying dependencies, also a" requirements.txt" which one would assume would verify all requirements are satisfied. This doesn’t seem to be the case. I first clicked on the fitbit dependency listed on the fitbit module. Once I navigated to it’s Github page, I cloned it to my MM modules folder. To be sure I didn’t have an issue of broken references, etc, I checked the files in the new python folder against those in MMM - fitbit/python folder, copy/pasting those files that were missing from the 2nd folder. There is a procedure for resolving this issue which If you have the issue I had is caused by an authentication failure listed on a webpage I found. Its a good read, but not all of the listed procedures were necessary. I’m listing what I did from memory, so hopefully I get it right… first, the site: http://pdwhomeautomation.blogspot.com/2016/01/fitbit-api-access-using-oauth20-and.html?m=1. When I copy/pasted from the folder created by the newer cloned Git, I saw that some files he lists were missing. One I had to create myself. I copied the script from the linked page (the first script listed in all green), saving it to my MMM-fitbit/python folder as “runthis.py”. I ran "setupAccess’, which opened a page whose url started with https://127.0.0.1, and ended with 2 long strings separated by “code” and I think some other text. I copied the entire url. Opened “runthis.py” and filled in client Id, secret, and the first code/key from the copied url. Be aware of the syntax in the script before editing. Double quotes, etc. Once edited run this script. Unless I’ve forgotten something your should get access tokens, Which will be listed in the script results window. Copy them. Be sure to get entire auth token and refresh token. Open tokens.ini. The tokens have likely been copied there already, but if not add them, without quotes. Assuming I haven’t forgotten anything, running “getdata.py” should now be successful, listing the retrieved data assuming your fitbit has been synched - it’ll only pull data if your fitbit dashboard shows data. Somewhere in the previously listed steps, you should be directed to the fitbit page which will advise you that you are now authorized.
                    I’m not near my pc, and as I’ve mentioned this is all from memory. I can try to assist further if I’ve left something out…

                    A 1 Reply Last reply Reply Quote 0
                    • A Offline
                      ascension @ascension
                      last edited by

                      @ascension
                      Forgot to mention that you will need to create “tokens.ini” if you haven’t already. Editing the existing “tokens.ini.sample” won’t give the desired result when running the script, since it’s looking for “tokens.ini”.

                      1 Reply Last reply Reply Quote 0
                      • O Offline
                        onetwankyfive
                        last edited by

                        Is the first code/key part the part inbetween the code= &state= or the entire thing? I can’t seem to get this workaround to work.

                        A 1 Reply Last reply Reply Quote 0
                        • A Offline
                          ascension @onetwankyfive
                          last edited by

                          @onetwankyfive
                          Just the first part.

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

                            Lots of good info to try out. I failed at getting this working this morning before leaving for work.

                            I do have a question. The directions say MM has to be started with sudo, i’m starting it by running ‘pm2 start mm’ per the MM install setup. How do I run this as root?

                            Thanks

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

                              OK, So I’m working on this and being new to MM, NodeJS, GIT, etc. is not helping :) (I am a programmer, so at least I have that going for me).
                              Something that I don’t think was too clear, at least it wasn’t for me. When running setupAccess.py, it’s starting a web service, the direction say to log into your fitbit account and authorize your app, what I had to do, on my Pi, was to go to 127.0.0.1:8080. This initiated the redirect to Fitbit, when I logged in I had the check boxes to enable/disable items and the allow/deny buttons.
                              When I clicked on the “allow” then the terminal with setupAccess running showed that the tokens were getting written out, and indeed the tokens.ini file was finally created.

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

                                I’m having a problem with my fitbit module. (mods if this should be a new thread just let me know).
                                I can start the MM and the FB data loads, then after a time my ‘credentials.ini’ file gets changed to “undefined” for both entries

                                [Credentials]
                                c_id = undefined
                                c_secret = undefined
                                

                                Now, when I ran setupAccess.py the file was correct and my tokens file was created. What I’m seeing happen is that after a while the FB module stops refreshing. I’m guessing it’s because the tokens need to be refreshed and because my credentials are gone, it can’t authorize.

                                Any thoughts?
                                I’m not sure how to get any logs or info out of the system. I’m running MM through pm2 and I don’t see any log files.

                                TIA

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

                                  Solved my issues.

                                  Saw the following when starting up MM

                                  results: [{"message":"Writing credentials to credentials.ini","type":"status"},{"message":"Writing id: undefined and secret: undefined","type":"status"},{"message":"Credentials write successful","type":"status"}]
                                  Create new todo fetcher for list: Groceries - Interval: 60000
                                  Create new todo fetcher for list: Family - Interval: 60000
                                  Whoops! There was an uncaught exception...
                                  { Error: process exited with code 1
                                      at terminateIfNeeded (/home/pi/MagicMirror/modules/node_modules/python-shell/index.js:100:23)
                                      at ChildProcess.<anonymous> (/home/pi/MagicMirror/modules/node_modules/python-shell/index.js:88:9)
                                      at emitTwo (events.js:106:13)
                                      at ChildProcess.emit (events.js:191:7)
                                      at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
                                    executable: 'python',
                                    options: null,
                                    script: 'modules/MMM-fitbit/python/getData.py',
                                    args: null,
                                    exitCode: 1 }
                                  MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
                                  If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
                                  

                                  Tracing the information back, it was in the config.js file. I had an extra set of [] around the credentials data. Not sure how or why I had it that way, but all cleared up now.

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

                                    Hi Guys,

                                    Firstly thank you for creating this module it’s exactly what I wanted!

                                    I’m having an issue with the module running for extended periods of time where it loses connection to fitbit and I need to run “sudo python setupAccess.py” on the python directory again to get it to pull my latest stats from Fitbit.

                                    Do you have any way it can check in with Fitbit every 30 mins or every hour to reconnect and pull the latest stats?

                                    Many thanks
                                    Ollie

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

                                      Hi Guys,

                                      this Module is freaking me out… (123456789 are just examples for my API ID)
                                      I just entered this Code in my config.js

                                      {
                                      	module: 'MMM-fitbit',
                                      	position: 'top_center',
                                      	config: [
                                      		credentials: {
                                      			client_id: 123456789,
                                      			client_secret: 123456789,
                                      		},
                                      		resources: [
                                      			'steps',
                                      			'floors',
                                      			'caloriesOut',
                                      			'distance',
                                      			'activeMinutes',
                                      			'sleep',
                                      			'heart'
                                      		]
                                      	]
                                      },
                                      

                                      if i try to start magicmirror it doesnt load because he says there is no valid config.
                                      I opened an issue in github for that and Venditteli says there are some issues with the file ownership of any ini file. Any hint or any workaround is very pleased wellcome.

                                      Thank you guys.

                                      Regards

                                      Hellangel


                                      Note from admin: Please use Markdown on code snippets for easier reading!

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

                                        Hi Hellangle1978,

                                        Try the below I saw a few errors in the example code;

                                        {
                                        	module: ‘MMM-fitbit’,
                                        	position: ‘top_center’,
                                        	config: {
                                        		credentials: {
                                        			client_id: '123456789',
                                        			client_secret: '123456789',
                                        			},
                                        		resources: [
                                        			‘steps’,
                                        			‘floors’,
                                        			‘caloriesOut’,
                                        			‘distance’,
                                        			‘activeMinutes’,
                                        			‘sleep’,
                                        			‘heart’
                                        			]
                                        		}
                                        },
                                        

                                        Note from admin: Please use Markdown on code snippets for easier reading!

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

                                          Hi @olliewarren411

                                          i used your code - not working.

                                          I created as followed in instructions an token.ini worked all out no problem.
                                          Just wen pasting the code in my config.js then after that the mirror will not start. Even if i use sudo npm start on desktop.
                                          Mirror is aways asking for an config or an error in my config after pasting that in config :(

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

                                            @Hellangel1987 Can you post the config code you’re using please?

                                            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
                                            • 1 / 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