Page 1 of 1

Adding Withing Scale via IFTTT

Posted: Saturday 19 December 2015 23:19
by felix63
Although Withing has an API making the data from the scale available I found the following very simple yet effective.

Make a virtual sensor with type scale:

Code: Select all

http://IPADDRESS:8080/json.htm?type=createvirtualsensor&idx=29&sensortype=93
Make a recipe (replace IP address, user, password and idx):

IF Withings New Body Scale measurement by user THEN Maker Make a web request.

URL:

Code: Select all

http://user:password@EXTERNALIP:8080/json.htm?type=command&param=udevice&idx=100&nvalue=0&svalue={{WeightKg}}
METHODE: get
TYPE: application/json
BODY: empty

Every time I step on the scale (with a significant delay, but who cares) the script is triggered and the sensor is updated.

Enjoy..

Re: Adding Withing Scale via IFTTT

Posted: Sunday 27 December 2015 10:40
by Derik
mmm great news have a scale to...
Only i do have 1 login....
For multiple user?


Please some more info?
I do not understand your methode?

Where do i have to place ....

Re: Adding Withing Scale via IFTTT

Posted: Tuesday 12 January 2016 14:39
by dynasticorpheus
I have been working on a Python script which pulls the CO2 and temperature data from the Withings site (not available through official api) and commits it directly to the Domoticz DB so original date/time is kept. Note that due to way the scale syncs its data there is a minimal delay of 14 hours. WS-50 only.

If anyone is interested let me know so I can refine the script a bit for wider use.

/Dynasticorpheus

Image

Re: Adding Withing Scale via IFTTT

Posted: Wednesday 27 January 2016 16:41
by djgodlike
dynasticorpheus wrote:I have been working on a Python script which pulls the CO2 and temperature data from the Withings site (not available through official api) and commits it directly to the Domoticz DB so original date/time is kept. Note that due to way the scale syncs its data there is a minimal delay of 14 hours. WS-50 only.

If anyone is interested let me know so I can refine the script a bit for wider use.

/Dynasticorpheus
Hi Dynasticorpheus,

I'm seriously interested in a python script for Air quality and weight.
Thanks! Keep up the good work!

Wouter

Re: Adding Withing Scale via IFTTT

Posted: Thursday 28 January 2016 20:19
by alexando
dynasticorpheus - I'd appreciate getting getting some more details on your script, can you PM me?

Re: Adding Withing Scale via IFTTT

Posted: Friday 29 January 2016 23:43
by javaboon
I would love the script also :-)

Re: Adding Withing Scale via IFTTT

Posted: Sunday 31 January 2016 8:53
by dynasticorpheus
Ok let me work on it a bit more and make it suited for wider usage. Will report back.

Re: Adding Withing Scale via IFTTT

Posted: Tuesday 02 February 2016 19:09
by dynasticorpheus
The first version of the script is now available via github, let me know if it also works for you guys. Be smart and make a backup of your DB before doing anything else first!

As we are writing to the DB directly note that any issues from this should not be addressed to the domoticz devs!

There is a --noaction option which allows for a dry-run to confirm if everything works as expected before doing any actual update to the DB. I would also recommend to do the initial update (potentially a lot of data hence blocking the DB for other writes) whilst domoticz is not running.


https://github.com/dynasticorpheus/ws50-sync

Code: Select all

Withings WS-50 Syncer by [email protected]

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        username (email) in use with account.withings.com
  -p PASSWORD, --password PASSWORD
                        password in use with account.withings.com
  -c CO2, --co2 CO2     co2 idx
  -t TEMPERATURE, --temperature TEMPERATURE
                        temperature idx
  -d DATABASE, --database DATABASE
                        fully qualified name of database-file
  -n, --noaction        do not update database

Re: Adding Withing Scale via IFTTT

Posted: Friday 05 February 2016 22:38
by djgodlike
dynasticorpheus wrote:The first version of the script is now available via github, let me know if it also works for you guys. Be smart and make a backup of your DB before doing anything else first!

As we are writing to the DB directly note that any issues from this should not be addressed to the domoticz devs!

There is a --noaction option which allows for a dry-run to confirm if everything works as expected before doing any actual update to the DB. I would also recommend to do the initial update (potentially a lot of data hence blocking the DB for other writes) whilst domoticz is not running.


https://github.com/dynasticorpheus/ws50-sync

Code: Select all

Withings WS-50 Syncer by [email protected]

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        username (email) in use with account.withings.com
  -p PASSWORD, --password PASSWORD
                        password in use with account.withings.com
  -c CO2, --co2 CO2     co2 idx
  -t TEMPERATURE, --temperature TEMPERATURE
                        temperature idx
  -d DATABASE, --database DATABASE
                        fully qualified name of database-file
  -n, --noaction        do not update database
Hi!

Thanks!!!
I'm trying to get it to work.
This is the output, is this normal?

DISKSTATION> /volume2/homes/admin/DomoticzScripts/ws50-sync.py -u ********* -p ********** -c 103 -t 104 -d /volume2/@appstore/domoticz/var/domoticz.db -n

Withings WS-50 Syncer Version 0.2.0

[-] Database /volume2/@appstore/domoticz/var/domoticz.db
[-] Authenticating at account.withings.com
[-] Downloading data newer than 2016-02-05 22:35:00
[-] Updating database with 0 CO2 measurements [FALSE]
[-] Updating database with 0 TEMPERATURE measurements [FALSE]

This was the first run with --noaction. Is it safe to run without -n? Sorry im kinda new :)
And what do you mean with the initial update?

Thanks for your work!

Re: Adding Withing Scale via IFTTT

Posted: Saturday 06 February 2016 8:42
by dynasticorpheus
With initial update I mean the first time you run it against the 2 (empty!) meters. As it cannot find any entries yet it will try to update the meter will all data available from the website. If successful, any run after that will only download data from the website that is not in the DB yet.

I would keep the --noaction until you get some sensible data before running it without this option however as long as it's updating with 0 measurements it still would not write to the DB anyway. Once you get more than 0 measurements you can remove the --noaction option.

Your output shows it is downloading data newer than 2016-02-05 22:35:00 so I wonder if the meters are cleared of all data before trying? My first suggestion would be to either clear the meters you are now using from all data or create 2 new ones.

Re: Adding Withing Scale via IFTTT

Posted: Saturday 06 February 2016 11:52
by djgodlike
dynasticorpheus wrote:With initial update I mean the first time you run it against the 2 (empty!) meters. As it cannot find any entries yet it will try to update the meter will all data available from the website. If successful, any run after that will only download data from the website that is not in the DB yet.

I would keep the --noaction until you get some sensible data before running it without this option however as long as it's updating with 0 measurements it still would not write to the DB anyway. Once you get more than 0 measurements you can remove the --noaction option.

Your output shows it is downloading data newer than 2016-02-05 22:35:00 so I wonder if the meters are cleared of all data before trying? My first suggestion would be to either clear the meters you are now using from all data or create 2 new ones.
Sorry for my ignorance but by clearing the 2 meters, i assume you mean the virtual sensors in domoticz? I did not clear anything yet..
I did not have to change anything in the script itself, right?

Re: Adding Withing Scale via IFTTT

Posted: Saturday 06 February 2016 17:08
by dynasticorpheus
djgodlike wrote:
dynasticorpheus wrote:With initial update I mean the first time you run it against the 2 (empty!) meters. As it cannot find any entries yet it will try to update the meter will all data available from the website. If successful, any run after that will only download data from the website that is not in the DB yet.

I would keep the --noaction until you get some sensible data before running it without this option however as long as it's updating with 0 measurements it still would not write to the DB anyway. Once you get more than 0 measurements you can remove the --noaction option.

Your output shows it is downloading data newer than 2016-02-05 22:35:00 so I wonder if the meters are cleared of all data before trying? My first suggestion would be to either clear the meters you are now using from all data or create 2 new ones.
Sorry for my ignorance but by clearing the 2 meters, i assume you mean the virtual sensors in domoticz? I did not clear anything yet..
I did not have to change anything in the script itself, right?
Virtual sensors indeed. Creating 2 new ones would be my recommendation.

Re: Adding Withing Scale via IFTTT

Posted: Monday 08 February 2016 10:08
by dynasticorpheus
I gave the script it's own thread viewtopic.php?f=38&t=10441

Re: Adding Withing Scale via IFTTT

Posted: Monday 08 February 2016 17:56
by djgodlike
I got some data on the air quality graph! It doesn't fill the temperature graph though..
Which results does it download? It downloaded data from 7-02-16 18:00 till 8-02-16 05:00.
Is it wise to make a cron script every 12 hours, or not in this stage yet?

Code: Select all

DISKSTATION> /volume2/homes/admin/DomoticzScripts/ws50-sync.py -u ********* -p ********** -c 103 -t 104 -d /volume2/@appstore/domoticz/var/domoticz.db -n

Withings WS-50 Syncer Version 0.2.0

[-] Database /volume2/@appstore/domoticz/var/domoticz.db
[-] Authenticating at account.withings.com
[-] Downloading data newer than 2016-02-07 09:45:00
[-] Updating database with 39 CO2 measurements [FALSE]
[-] Updating database with 39 TEMPERATURE measurements [FALSE]

DISKSTATION> /volume2/homes/admin/DomoticzScripts/ws50-sync.py -u -u ********* -p ********** -c 103 -t 104 -d /volume2/@appstore/domoticz/var/domoticz.db   

Withings WS-50 Syncer Version 0.2.0

[-] Database /volume2/@appstore/domoticz/var/domoticz.db
[-] Authenticating at account.withings.com
[-] Downloading data newer than 2016-02-07 09:45:00
[-] Updating database with 39 CO2 measurements [TRUE]
[-] Updating database with 39 TEMPERATURE measurements [TRUE]
[-] Committing and closing database
Thanks for working on this!!

Re: Adding Withing Scale via IFTTT

Posted: Wednesday 30 March 2016 22:18
by Derik
i will give it a next try...

Only where in domoticz can i ad a scale.??
Or what type of sensor i need?

Re: Adding Withing Scale via IFTTT

Posted: Thursday 31 March 2016 20:05
by manuloup
Hi,

I just ordered a ws-50 today. I will give it a try too :)

Thanks,

Manu

Re: Adding Withing Scale via IFTTT

Posted: Wednesday 11 May 2016 17:40
by Derik
Please....
A Wiki....

I think there is something wrong...
I can not find a Scale type.....

Re: Adding Withing Scale via IFTTT

Posted: Wednesday 11 May 2016 20:46
by dynasticorpheus
Derik wrote:Please....
A Wiki....

I think there is something wrong...
I can not find a Scale type.....
Are you trying to use my script or IFTTT? For my script please go to this thread

viewtopic.php?f=38&t=10441

Re: Adding Withing Scale via IFTTT

Posted: Thursday 12 May 2016 20:44
by Derik
dynasticorpheus wrote:
Derik wrote:Please....
A Wiki....

I think there is something wrong...
I can not find a Scale type.....
Are you trying to use my script or IFTTT? For my script please go to this thread

viewtopic.php?f=38&t=10441
MM

My first option was to add the weight....
The Co etc.. is my second..