rpi-nest-radiator-switch
A nodejs project to get a Raspberry PI to control a towel radiator using the Nest API
Setting up the hardware parts
You'll need:
- A Raspberry PI, I'm using v3 (with OS installed, plus git, daemontools, and node)
- A 10A 240V relay (eg this one from eBay)
- GPIO connectors (I've used female-to-female)
I use PINs 12 (BCM 18), 1 (5V), and 14 (Ground) to connect to the relay (you're able to change this in the code). Here's a handy chart: https://pinout.xyz/
Getting your auth settings
This project uses the config.json
to hold your access token. Thankfully Nest
uses non-expiring tokens so to get your
access token simply follow these steps:
- Do everything as root (I know, I know)
- Open
/etc/rc.local
and addsvscan /service &
beforeexit 0
- Make a folder
/service
cd
into/service
and clone the repo, this'll create a folder within calledrpi-nest-radiator-switch
cd
into the repo folder, runchmod +x run
- Register a new Nest project for yourself: https://developers.nest.com/products
- Create a whack 'Redirect URI'
- Take note of the Product ID and Product Secret and hit the Authorization URL
- Take note of the
code
in the URL once you've authed - Make the CURL request displayed here: https://developers.nest.com/documentation/cloud/sample-code-auth
- Copy and paste the response into
config.json
(it ought to look like{ "access_token": "xxx", "expires_in": 315360000 }
) - Don't forget to set your
target_thermostat
too, this is the ID (key) underdevices > thermostats
object: https://developers.nest.com/documentation/api-reference