3

I could not find any information on how to set the target temperature or set Away mode. Has anyone successfully gotten it to work?

https://developer-api.nest.com/devices.json?auth=asdasdasd

^ Provides the information but how do we modify the temperature or away mode??

Enigma
  • 1,247
  • 3
  • 20
  • 51
Mahes
  • 3,938
  • 1
  • 34
  • 39

1 Answers1

5

Keep the auth in the querystring, and PUT the JSON-formatted change to the appropriate endpoint. eg (PHP):

To set target temperature:

$ch = curl_init("https://developer-api.nest.com/devices/thermostats/$THERMOSTAT_ID?auth=$AUTH");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); 
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"target_temperature_c": 21.5}');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo curl_exec($ch);

To set Away mode:

$ch = curl_init("https://developer-api.nest.com/structures/$STRUCTURE_ID?auth=$AUTH");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); 
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"away":"away"}');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo curl_exec($ch);
thesimm
  • 774
  • 3
  • 12
  • 1
    I think what you have shows how to change the away state where the $ID is the structure_id. If you wanted to change the temperature you'd actually need to change the URI to developer-api.nest.com/devices/thermostats/$ID with the json being "target_temperature_c" or "target_temperature_f" – Nagesh Susarla Jun 30 '14 at 17:51