Skip to content

dbsqp/withings-influxdb2

Repository files navigation

withings-influxdbv2

Docker container to fetch data from the Withings API and place it in your influxdb. Uses a modified version of https://github.com/vangorra/python_withings_api to allow access to further paramaters from withings API https://developer.withings.com/api-reference/.

Core script run hourly via cron but sleep stats only pulled once per day (hour = WITHINGS_SLEEP_AT) to allow synchronisation of data pulled by docker and sources.

Withings API Token

InfluxDBv2 Setup

Setup InfluxDBv2, create bucket and create a token with write permissions for said bucket.

Docker Setup

https://hub.docker.com/r/dbsqp/withings-influxdbv2

$ docker run -d \
 -e WITHINGS_CLIENT_ID="<WITHINGS CLIENT ID>" \
 -e WITHINGS_CLIENT_SECRET="<WITHINGS CLIENT SECRET>" \
 -e WITHINGS_AUTH_CODE="INIT/<WITHINGS_AUTH_CODE>/-" \
 -e WITHINGS_SLEEP_AT="<hour>" \
 -e INFLUXDB2_HOST="<INFLUXDBv2 SERVER>" \
 -e INFLUXDB2_PORT="8086" \
 -e INFLUXDB2_ORG="Home" \
 -e INFLUXDB2_TOKEN="" \
 -e INFLUXDB2_BUCKET="DEV" \
 --name "Withings-InfluxDBv2" \
dbsqp/withings-influxdbv2:latest

Start container WITHINGS_AUTH_CODE="INIT", this will generate URL in log. Goto URL, authenticate and copy authorisation code. Restart container with WITHINGS_AUTH_CODE="received authorisation code". Check log to ensure oauth authorisation worked and token created. This can take multiple trys (The authorization code is valid for 30 seconds). Once workng reset WITHINGS_AUTH_CODE="" and restart. Token is stored in directory for easy removal via docker volume.

Options

 -e INFLUXDB2_SSL="true"
 -e INFLUXDB2_SSL_VERIFY="False"

Debug

To report out further details in the log enable debug:

 -e DEBUG="true"

About

Docker image to fetch data from Withings API and push it to an InfluxDBv2 bucket.

Topics

Resources

License

Stars

Watchers

Forks