Can this be done? Sorry, not sure if they have an open API or anything.
There is not direct support but I use the IFTTT integration to step on the scale and then turn all the lights off at night. Works great.
Yeah, I’ve tried using IFTTT but it just takes way too long and is very unreliable.
Yeah … for me, since it just triggers my shutdown routine (good night events), then the timing doesn’t matter - as long as it eventually happens.
for direct support though, there definitely is an open API.
I would be nice to have temperature and co2 from Withings.
That’s true! Didn’t think of that. That would be great, actually. If your air quality is poor, then automatically send you a push notification? open a window? etc… Would be cool
Last time when I went through their API, it didn’t look like it exposed air quality, temp etc. I’m not sure why they didn’t but I doubt it would be available
Oh no!!! Way to crush my dreams…
I’m not sure if the scale transfers air quality measures immediately to cloud. So it might not work fast enough for controlling like a fan.
But it would be nice to get those measurements also to my database.
The last reverse engineering of a Withings scale I saw was this to capture values: http://www.prolixium.com/mynews?id=915
Here is my config and how I managed to script some scraping off the WS-50 for co2 and temperature sensors. I am no developer, so consider my scripts ‘hacky’ but it works!
- That I have a csv file called secrets.txt with my username and password in csv format.
- Ensure jq 1.5, some repos are a little behind. On my pi I had to manually compile 1.5 (pretty easy via the googles)
Hope that helps!
Scripts are here: https://github.com/jtscott/hass-config/tree/master/withings , check the sensors.yaml for the HA config.
Edit: I did also look into the actual withings developer API to do this first. I had to resort to scraping the user interface apis instead because the official developer APIs at this time only provide health/body information.
What are the values in your secret.txt file?
I cant get it to work with:
email, password, email once more, mac-address of my scale
my format is email,password,userid,deviceid. the userid and deviceid are two different 7 digit identifiers withings uses. Here is how I grabbed those using chrome:
- Open up a new chrome tab, and the developer tab (tools, more tools, developer settings)
- Click the ‘network’ tab
- Load up withings healthmate website, login
- watch for the “measure” POSTs to go by.
- The annoying part, find the right ‘measure’. Click each measure and look at the response tab. You need to find the right measure that returned the CO2 sensor data. It looks like
- right click the measure, copy as curl (bash)
- paste into notepad, you should see your userid and deviceid at the end in the --data section
- worst case scenario, keep searching each of the POSTs, your userid will be in the ‘account’ post for sure.
Hope that helps!
Thank you so much for your time and your effort!!
For others who want to read sensor values from their Withings as well here are some things I had to do:
The user id in question is not the 8-digit number I reciecved when registering as a Withings developer at their site, but indeed a 7 digit number in the ‘account’ post mentioned in the post above. However it was listed as “accountid”, and not userid.
Any jq version other than 1.5 will not work.
I had some difficulty finding some clear instructions, so here is what worked for me in the end:
tar -zxvf jq-1.5.tar.gz
sudo make install
Yeah < jq 1.5 has a bug reading the value at the end of the array “[-1]” which is where the latest temperature (series 0) or co2 (series 1) measurement is:
17-03-05 17:11:49 ERROR (Thread-8) [homeassistant.components.sensor.command_line] Command failed: bash /withings/withings_battery.sh
How can i find out that the sh file is found and executed correctly?
Edit: now i know my files get executed but it seems that i can’t login correctly (i get a question for a cookie.txt-File). Mhmm… not easy to find out whats wrong with my secrets.txt…
I tried userid and deviceid and as @ohjay93 mentioned above the accountid and deviceid. Same result. No cookies.txt and sensor state “null”.
ok. found it. The Withings-login shouldn’t have any special characters. now it works. Thanks for your work.
For me it works with deviceid,accountid.
BTW: is there a way to force the scale to sync more often? Mine syncs only after measuring. But it would help me to get more data if it would do it once per hour or so…
Remember that syncing more might take a toll on the battery of the scale.
Has any more development gone into this integration?
It would be nice to hook up the scale