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
Hi All,
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!
Note:
- 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
{"status":0,"body":{"series":[{"type":12,"data":[{"date":1477128613,"value":24.4},{"date":1477126812,"value":24.4},{"date":1477125013,"value":24.4},{"date":1477123212,"value":24.4},{"date":1477121413,"value":24.5},{"date":1477119612,"value":24.5},{"date":1477117813,"value":24.5},{"date":1477116012,"value":24.5}]},{"type":35,"data":[{"date":1477128613,"value":545},{"date":1477126812,"value":545},{"date":1477125013,"value":576},{"date":1477123212,"value":542},{"date":1477121413,"value":565},{"date":1477119612,"value":575},{"date":1477117813,"value":552},{"date":1477116012,"value":614}]}]}}
- 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:
wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-1.5.tar.gz
tar -zxvf jq-1.5.tar.gz
rm jq-1.5.tar.gz
cd jq-1.5
./configure
make
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:
.body.series[1].data[-1].value
I get
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