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.

    Withings

    Scheduled Pinned Locked Moved Unsolved Requests
    health
    26 Posts 14 Posters 24.7k Views 17 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.
    • D Offline
      darrene
      last edited by

      I too have a Withings scale which I’d be interested in integrating the data from with MM.

      It’s next on my list to take a look at, but I suspect progress is likely to be slow as my skills are very basic :)

      1 Reply Last reply Reply Quote 0
      • D Offline
        darrene
        last edited by darrene

        I’ve been having a very quick play with this python script on my Pi, which demonstrates the API which could form the basis of a simple weight-data retrival module.

        I’m struggling with a few issues at the moment though - I’ve git clone’d and npm install’d, created a test.py file as indicated by the readme and in it I’ve put in it my Withings API key and secret values.

        I had to sudo pip install requests_oauthlib as that was a requirement which wasn’t installed.

        I’m SO nearly there I think! when my test.py file runs, it generates a Withings URL to authorise the app, I authorise on the website and am given an oauth response verification code, but when I paste it back into the script response, I get an error which i think is at the point the script tries to parse them through auth.get_credentials (after this point, the script gets my last measured weight):

         File "test.py", line 8, in <module>
         creds = auth.get_credentials(oauth_verifier)
         File "/home/pi/MagicMirror/modules/python-withings/withings/__init__.py", line 107, in get_credentials
        tokens = oauth.fetch_access_token('%s/access_token' % self.URL)
        File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/oauth1_session.py", line 304, in fetch_access_token
        token = self._fetch_token(url, **request_kwargs)
        File "/usr/local/lib/python2.7/dist-packages/requests_oauthlib/oauth1_session.py", line 361, in _fetch_token
        raise ValueError(error)
        ValueError: Unable to decode token from token response. This is commonly caused by an unsuccessful request where a non urlencoded error message is returned. The decoding error was No JSON object could be decoded.
        

        Oh well. It’s progress I suppose.

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

          I got the withings scale, interested about the module you’re building :)

          1 Reply Last reply Reply Quote 0
          • D Offline
            darrene
            last edited by

            So the Python module I was trying to re-use didn’t work. I suspect Withings have changed their API or something else has changed. Following the steps on their website though, did work and I was able to send a command to retrieve my data.

            Now it’s a case of trying to code it up into a module!

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

              Hi,

              Just upload first version of my module. This is more a proof of concept than a complete functional module, but it works fairly well on my mirror.

              MM_Withings

              Will update and improve it (especially design, if someone could provide me nice icons) and create new post in module section forum.
              Module is based on Netatmo module from Christopher Fenner.

              F 1 Reply Last reply Reply Quote 0
              • F Offline
                frog @matt25
                last edited by

                @matt25 What do you put in for the application website when creating the application on the withings site? Seems to be needed later when granting access - and I get a 404 error if I just put some random site mane in there.

                M 1 Reply Last reply Reply Quote 0
                • M Offline
                  matt25 @frog
                  last edited by

                  @frog I personally simply wrote 127.0.0.1 and no problem. Let me know if it is ok so that I can complete the user guide.

                  F 1 Reply Last reply Reply Quote 0
                  • F Offline
                    frog @matt25
                    last edited by

                    @matt25
                    The problem I had was that I was ssh’ing into my mirror - so I tried running the Withings authorisation process on the mirror using Chrome, but I’m now getting a message that 127.0.0.1 can’t be reached.

                    M 1 Reply Last reply Reply Quote 0
                    • M Offline
                      matt25 @frog
                      last edited by

                      @frog Ok sorry. When creating a withings app it is necessary to write something in the application website (127.0.0.1). In the Withings authentification process, do not fill the the ‘callback url’ field. Hope it helps.

                      1 Reply Last reply Reply Quote 0
                      • F Offline
                        frog
                        last edited by frog

                        Ah, OK,

                        Now a different error.

                        When I get to Step 3, do I stop there or continue on (I’m getting a Bad Request on step 4)

                        Also it says in step 2 I should get a URL once I access the user - but I get Access Granted - and another token - no URL.

                        To be clear about the parameters for the config.js:

                        oath_consumer key is the key given in the partner app page. under My Keys and called APIKey

                        oauth_signature is listed right at the bottom in the black box in step 3.

                        clientID - no idea what that is

                        oauth_token is taken from the black box in step 3 and is highlighted. There are two copies of it.

                        Oh, One last request about functionality. It would be great if you could specify in Config.js which readings are actually shown. I only use the scales and so the other stuff is superfluous. I suspect the majority of people would not necessarily have the full set (steps and sleep).

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

                          @frog

                          Seems that you are not using correct parameters in the Withings authentification process:

                          • Step1 : Use API keys and API secret generated during your Withings apps creation.
                            You get a result URL with oauth_token and oauth_token_secret.

                          • Step2: Use oath_token and oauth_token_secret generated at step1. This will generate a result URL. Click on it and look at the adress bar, you will get in the URL your userid (6 digits), ‘&userid=xxxxxxx’

                          • Step3: use the userid got from step2. you will get an URL result with oauth_signature and oauth_token.

                          Hope it helps.

                          Selecting the data you want to display is the next step, that is why currently this is just a basic module and I did not yet published a official release.

                          F 1 Reply Last reply Reply Quote 0
                          • F Offline
                            frog @matt25
                            last edited by

                            @matt25 Hi,

                            Thanks, with your pointers, I got through to step 4 and the resultant URL does retrieve data so I know the credentials are working- but putting that into the config.js (all info it looks like you ask for is contained in that request URL), I still get zeros.

                            I suspect I’m close, but not sure what could be wrong.

                            I 1 Reply Last reply Reply Quote 1
                            • I Offline
                              ih800a @frog
                              last edited by

                              @frog I’m getting the same results as you. I suspect the MM_Withings.js script needs to be tweaked a bit. I manually tested all the variables used in the config.js file, confirming that the API is setup correctly and returning data. My guess is that the output string of the MM_Withings.js script is different than what I’m testing.

                              M 1 Reply Last reply Reply Quote 0
                              • M Offline
                                matt25 @ih800a
                                last edited by matt25

                                @ih800a @frog

                                Hi, sorry, was out last few weeks. Just tried the module on another raspberry card with from scratch installation and I cannot reproduce the issue you describe. When you launch the mirror, do you have any issue in the logs? (use “npm start dev” command). Thanks

                                I 1 Reply Last reply Reply Quote 0
                                • I Offline
                                  ih800a @matt25
                                  last edited by

                                  @matt25

                                  Per the console, I do receive weight (poids=90.67;) and date (date=1481195497) information, but then see the following:

                                  status=0
                                  error TypeError: Cannot read property ‘date’ of undefined
                                  error TypeError: Cannot read property ‘body’ of undefined
                                  data=undefined
                                  data is null

                                  M 1 Reply Last reply Reply Quote 0
                                  • M Offline
                                    matt25 @ih800a
                                    last edited by matt25

                                    @ih800a
                                    ok thanks.
                                    Do you only have a Withings scale, correct? or do you also have a watch or others?

                                    My guess is that as my module is just currently a proof of concept, I try to display all the related information (weight, sleep, activity ) but if you do not have the withings device related it crashes.

                                    Also, could you tell me when:
                                    “error TypeError: Cannot read property ‘date’ of undefined”
                                    which line in the MM_Withings.js script is related. It should be written in the debug console. Thanks

                                    I 1 Reply Last reply Reply Quote 0
                                    • I Offline
                                      ih800a @matt25
                                      last edited by

                                      @matt25

                                      I have a few Withings devices (pulse, scale, BP monitor, etc), so your theory makes good sense. Kudos, by the way on this proof of concept - I like it and this will be one of my first Pi / Magic Mirror / module customizations, so I appreciate any insight you have.

                                      The errors appear at MM_Withings.js:208, which I believe is the line that writes the error to the log.

                                      1 Reply Last reply Reply Quote 0
                                      • aluiniA Offline
                                        aluini
                                        last edited by

                                        I corrected some things on the module :

                                        • correction of the @ih800a bug (I had the same)
                                        • add external CSS
                                        • add the loader
                                        • add translation

                                        I’ll review the design of the module

                                        [card:aluini/MM_Withings]

                                        1 Reply Last reply Reply Quote 0
                                        • SnilleS Offline
                                          Snille Module Developer
                                          last edited by

                                          Hi @aluini, is your module still working correctly? I’m only getting the weight. :)
                                          I have an Body Cardio Scale, do I have to define this somewhere?

                                          Thanks!

                                          If you cant find it, make it and share it!
                                          Modules: MMM-homeassistant-sensors, MMM-Modulebar, MMM-Profilepicture, MMM-Videoplayer

                                          1 Reply Last reply Reply Quote 0
                                          • foxF Offline
                                            fox
                                            last edited by

                                            @aluini said in Withings:

                                            I corrected some things on the module :

                                            • correction of the @ih800a bug (I had the same)
                                            • add external CSS
                                            • add the loader
                                            • add translation

                                            I’ll review the design of the module

                                            [card:aluini/MM_Withings]

                                            Nice. I want to test it.
                                            My data from my withings steel also showable?

                                            Issues With MMM-WatchDog known?

                                            https://forum.magicmirror.builders/post/29827

                                            Useful for PIR-Sensor: https://forum.magicmirror.builders/post/21299

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