Based on jeff89179's work, which is based on peterot's work (peterot/nest-graph). Updated for the new Google version of the nest device APIs.
Based on Axlan's updated python-next which uses said Google APIs. Pleaes read the README there https://github.com/axlan/python-nest to learn how to authenticate with the API, it's nuanced and requires following the instructions carefully.
This project is a slightly over engineered solution for collecting metrics from Nest devices (i.e. temperature, humidity, alarm state etc.) such that they can be visualised in a customisable way.
The stack relies on OpenTSDB for the metrics storage and Grafana for the visualisation. The metrics collection is provided by a custom Python collector which runs within the OpenTSDB tCollector service.
Everything is packaged in a self-contained Docker container allowing it to be deployed anywhere.
- Install Docker.
- Follow the readme steps at axlan/python-nest to generate a project_id, client_id and client_secret
- Pull and run the Docker container.
- Run a config script on the Docker container to provide three credentials.
- Visit the Grafana web console and start playing with all the graphs. (data takes 1-2 minutes to start)
Follow the platform specific install instructions.
First build the docker image:
docker build . -t nest-graph
Make a folder on the host machine to store data and auth access credentials
mkdir -p /opt/nestdata
Start the container running with the ports for Grafana (3000) and OpenTSDB (4242) mapped to localhost:
docker run -d -p 4242:4242 -p 3000:3000 --restart unless-stopped -v /opt/nestdata:/data nest-graph
The previous command will return the container id as a long string. Copy this for use in the next step.
It is necessary to execute a small python script on the docker container to setup the Nest API credentials. The stript will ask for the id and secret obtained when the developer account was set up. It will then output a URL which you must visit to inform Nest that you are happy to allow the metrics collector the specified access. Once accepted it will give you a pin which must be provided to the config script.
docker exec -it [CONTAINER-ID] /usr/bin/python3 /opt/nest-auth.py
Grafana will already have been configured with the OpenTSDB datasource and two example dashboards.
- Thermostats Overview - graphs showing all metrics from all the associated Nest thermostats.
- Smoke/CO Alarms - graphs showing the alarm state for all the associated Nest smoke/co alarms
You can access Grafana at localhost:3000 with default credentials admin:admin
.
If you wish to play with OpenTSDB directly you can access the web console on localhost:4242
nest.away
nest.num_thermostats
- away state; 'home': 1, 'away': 0, 'unknown': -1nest.thermostat.temperature
nest.thermostat.humidity
nest.thermostat.target
- target temperaturenest.thermostat.eco.temperature.low
nest.thermostat.eco.temperature.high
nest.thermostat.hvac_state
- heating state; 'heating': 1, 'off': 0, 'cooling': -1nest.thermostat.is_online
- online state; 'online': 1, 'offline': 0nest.smoke_co_alarm.co_status
- 'ok': 0, 'warning': 1, 'emergency': 2nest.smoke_co_alarm.smoke_status
- 'ok': 0, 'warning': 1, 'emergency': 2
In addition to Grafana and OpenTSDB this project relies on the excellent Python client for accessing the Nest API python-google-nest.