Withings Sleep and Scale

This is a smartapp & dth to get data from Withings Product.

Support Devices.
Withings Sleep (Not Support up & down notify)
withings-sleep
Withings Scale

Attribute
Withings Sleep ()
Withings Scale (weight, fat_free_mass, fat_ratio, fat_mass_weight, heart_rate)

github

Install

  • Install a Smartapp & DTH on ST IDE.
  • Enable Oauth & Click Config Menu & Copy wt_url
  • Make a Withings developer app (https://account.withings.com/partner/add_oauth2)
  • Set a wt_url to callback url on Withings developer app
  • Set a client id & password to WT Smartapp
  • Click a User Informaton Auth & Login
  • Click a User Metrics Auth & Login
  • Click a User Activity Auth & Login
  • Then device is automatically generated



10 Likes

This is cool!

Will the scale DTH do multiple users? What attributes are exposed to webCoRE?

Thinking that if weight has dropped by 2lbs then Alexa would say, “Awesome “user name” you lost a couple of pounds! Keep up the good work.”

If weight rises by 3lbs then Alexa would say, “Umm, seems like you have pick up a few pounds. Be careful with your intake”

I don’t have a scale device.
That’s why I have no idea about multiple user.

Attribute
weight,
fat_free_mass,
fat_ratio,
fat_mass_weight,
heart_rate

By “ Not Support up & down notify”, do you mean it doesn’t support the ability to detect when I get in bed and get out of bed? Does the device handler lack that support because Withings API doesn’t allow it or some other reason? Wondering if it’s possible to add the support.

Thanks for this.

Anyone care to chime in if you know how to change this to lbs versus kilos? I’m going to give it a go but thought I would ask if anyone has done it already.

EDIT:

Just add a multiplier to the unitVal as follows:

sendEvent(name: "status", value: (subItem.value / unitVal * 2.20462262185))
sendEvent(name: "weight", value: (subItem.value / unitVal * 2.20462262185))
                                log.debug "Weight >> " + (subItem.value / unitVal * 2.20462262185)

sendEvent(name: "fat_free_mass", value: (subItem.value / unitVal * 2.20462262185))
                        log.debug "Fat Free Mass >> " + (subItem.value / unitVal * 2.20462262185)

sendEvent(name: "fat_mass_weight", value: (subItem.value / unitVal * 2.20462262185))
                            log.debug "Fat Mass Weight >> " + (subItem.value / unitVal * 2.20462262185)

And change the labels on the tiles from kg to lbs.

I also made a change to allow the icon to be changed.

Yes exactly.
When I tested it, it looks like not working.
It has to get a message from withings but nothing come.
I don’t know why.

Any chance to add the withings smart watches to this as well?

Hi @fison67 nice work!
Can you help me Setting up a wt_url to callback url on Withings
developer app Set a client id & password to WT Smartapp ?

What code sohuld i put in the “code” section of the Smartapp? The one from the DH dont work.

Thanks!

I have no plan to add a smart watch.

Just write client is & password of developer app.

And set wt_url from config of smartapp to developer app.

I got this error when trying to login in info auth in the APP.
error physicalgraph.app.exception.UnknownDeviceTypeException: Device type ‘Withings Person’ in namespace ‘fison67’ not found.

Do you knwo the solution?

The other 2 went well, metrics and activity.

Thanks

It means that you don’t have a DTH…

If you modify namespace or name of DTH, problems can arise

I installed everything right and i didnt modify anything in the code and is also publish.
What could be the problem? Thanks

Let me know all logs when error occurred

I installed the smartapp and device handlers no problem. When I startup the app, I enter the client ID/password from the IDE OAuth screen and I click “Copy wt_url”.

I then copy that into the developer’s registration.

Issue comes when I click “User Informatino Auth” or “user Metrics auth”. I login fine with my withings account, select one of 2 users, then I get “client id not authorized”.

Is there something I’m missing?

Yep, i have the same problem!

02:09:59: debug something went wrong: groovyx.net.http.HttpResponseException: Unauthorized

That means wrong client id & password.

Anybody got this working ? I followed the slightly confusing instructions, got the withings dev account setup and pasted in the call back from the App code on ST - which is not entirely clear, but then again I’m not a developer…

I logged in, it obviously sort of works as it retrieved the two users I have setup on my WT account and it asked me which one - then returned “Client ID not authorised” just like the others.

Anything really obvious that I’m doing wrong - I have followed the instructions, as much as I can do do that is.

Thanks
Shaun

Figured it out - the WT developers app setup earlier has ‘client id’ and ‘consumer seceret’ - which translate into client id and ‘client password’ on the ST app - do this, and everything was fine. Now to find a use-case !

This is certainly a confusing one to install. I’m getting an error on what I think is the final step.

Here are the steps I’ve followed so far.

1: Install Smartapp & DTH through Smartthings IDE
2: Enable Oauth for the smartapp through IDE
3: Go to SmartApps, My Apps, WT Connector and then CLICK SAVE (If you don’t you will get an error)
4: Open app, click “Copy wt_url” under config, copy the wt_url address provided
5: Make a Withings developer app (https://account.withings.com/partner/add_oauth2 )
6: Use the wt_url you copied in step 4 under callback url when creating the Withings developer app.
7: Copy the client ID from the withings developer app, go back to the WT Connector app, paste into Client ID.
8: Press Save (App seems to automatically clear this field if you switch windows to copy password)
9: Copy the Consumer Secret from the withings developer app, go back to WT Connector app, paste into Client Password.
10: Press save
11: Open app again and go under Add Page
12: Enter Name, click next
13: Under Auth-User press “Click Here”
14: Log into your withings account
15: Select which user you want
16: Your developer app should now come up and you must choose to allow this app

This is as far as I’ve made it so far and getting the following error message
{“errors”:[{“message”:“redirect_uri_mismatch: The redirect URI provided is missing or does not match partner callback url”}]}

I have verified that the callback url entered matches exactly to the one provided in the copy wt_url.