如何使用普通REST而不是firebase api来设置温度

Mah*_*hes 3 nest-api

我找不到有关如何设置目标温度或设置离开模式的任何信息.有没有人成功地让它工作?

https://developer-api.nest.com/devices.json?auth=asdasdasd
Run Code Online (Sandbox Code Playgroud)

^提供信息,但我们如何修改温度或离开模式?

the*_*imm 5

将auth保留在查询字符串中,并将JSON格式的更改PUT到适当的端点.例如(PHP):

设定目标温度:

$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);
Run Code Online (Sandbox Code Playgroud)

要设置离开模式:

$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);
Run Code Online (Sandbox Code Playgroud)