问题
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??
回答1:
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);
来源:https://stackoverflow.com/questions/24457353/how-do-i-set-temperature-by-using-plain-rest-not-firebase-api