Withings Binding - vpjuslin/openhab GitHub Wiki
Documentation of the Withings binding Bundle.
The Withings Binding allows to synchronize data from the official Withings API to items. The following body measure types are supported: diastolic blood pressure, fat free mass, fat mass weight, fat ratio, heart pulse, height, systolic blood pressure, weight.
For installation of the binding, please see Wiki page Bindings.
To access Withings data the user needs to authenticate via an OAuth 1.0 flow. The binding implements the flow through the command line interface. The first time the binding is started, it prints the following messages to the console:
#########################################################################################
# Withings Binding needs authentication.
# Execute 'withings:startAuthentication' on OSGi console.
#########################################################################################
In order to start the authentication process the user needs to execute withings:startAuthentication
on the OSGi console. The binding will print the following lines to the console
#########################################################################################
# Withings Binding Setup:
# 1. Open URL 'http://<auth-url>//' in your webbrowser
# 2. Login, choose your user and allow openHAB to access your Withings data
# 3. Execute 'withings:finishAuthentication "<verifier>" "<user-id>" on OSGi console"
#########################################################################################
So the user needs to open the shown url in a web browser, login with his withings credentials, confirm that openHAB is allowed to access his data and at the end he is redirected to a page on github. There the user finds the command withings:finishAuthentication "<verifier>" "<user-id>"
with filled parameters that is needed to finish the authentication.
The binding stores the OAuth tokens, so that the user does not need to login again. From this point the binding is successfully configured.
To bind a measure value to an item the measure type has to be defined in the generic binding config. Withings data can be bound to NumberItem
s only. The syntax for a Withings binding is withings="<measure type>"
The following table shows the measure types and units, that are supported by the binding:
Measure type | Binding Config | Unit |
---|---|---|
Weight | weight | kg |
Height | height | meter |
Fat Free Mass | fat_free_mass | kg |
Fat Ratio | fat_ratio | % |
Fat Mass Weight | fat_mass_weight | kg |
Diastolic Blood Pressure | diastolic_blood_pressure | mmHg |
Systolic Blood Pressure | systolic_blood_pressure | mmHg |
Heart Pulse | heart_pulse | bpm |
The following snippet shows some sample bindings:
Number Weight "Weight [%.1f kg]" { withings = "weight" }
Number FatRatio "FatRatio [%.1f %%]" { withings = "fat_ratio" }
Number HeartPulse "HeartPulse [%d bpm]" { withings = "heart_pulse" }
By default the Withings data is requested every 60 minutes. The interval can be configured in the openhab.cfg
file. The interval must be specified in ms. The following snippet shows a data refresh interval configuration of 120 minutes:
withings:refresh=7200000
The Withings Binding uses a default application registration to request an OAuth token. The application belongs to the binding developer. If the user wants to use his own application, the binding can be configured to use another OAuth consumer key and consumer secret. Please read the Withings documentation how to register an application (http://oauth.withings.com/en/partner/dashboard). After the application was created, Withings will generate a consumer key and secret. The redirect url must be configured, too. To change the OAuth parameters for the Withings binding the user can specify the following values into the openhab config file :
withings-oauth:consumerKey="<your consumer key>"
withings-oauth:consumerSecret="<your consumer secret>"
withings-oauth:redirectUrl="<your redirect url>"