Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i set temperature by using plain REST not firebase api

Tags:

nest-api

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??

like image 695
Mahes Avatar asked Dec 30 '25 16:12

Mahes


1 Answers

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);
like image 200
thesimm Avatar answered Jan 01 '26 15:01

thesimm