I am trying to change the temperature of my Nest programmatically (Android), without any luck. Requests work maybe 1 in 30-50 tries.
I have tried doing it through the Firebase Nest SDK, and the NestAPI.CompletionListener doesn't get called at all. Seeing how that doesn't work, I tried it with the REST api, where it worked twice, and then again 1 in 30 tries. I also tried it with curl from the command line, with the same results, until I finally got "blocked" because of the rate limiting. Before being blocked, requests were returning the full thermostat object, just like doing a GET request instead of PUT.
When the temperature actually did get updated, the response contained just the new target_temperature_high_c and target_temperature_high_c values.
Has anyone else seen similar behavior ?
Edit: added some code below
Here's my code using the Nest Android API (based on Firebase):
NestAPI.CompletionListener completionListener = new NestAPI.CompletionListener() {
public void onComplete() {
Debug.d("NEST", "request complete");
}
public void onError(int errorCode) {
Debug.e("NEST", "error: "+errorCode);
}
};
NestAPI.getInstance().setTargetTemperatureHighC(myNest.getDeviceID(), 25, completionListener);
This only works if I make that call once an hour. If I even try to do it twice, the second try doesn't work.
Next, I tried with the REST interface. This seems work more often (worked 5-6 times, after which it the API started acting like I was doing GET requests instead of PUT.
JSONObject dataToSend = new JSONObject();
dataToSend.put("target_temperature_low_c", 23);
dataToSend.put("target_temperature_high_c", 26);
HttpPut httpost = new HttpPut("https://developer-api.nest.com/devices/thermostats/"+myNest.getDeviceID()+"?auth="+myAuthToken);
httpost.setHeader("Content-type", "application/json");
httpost.setEntity(new StringEntity(dataToSend.toString()));
HttpResponse response = defaultHttpClient.execute(httpost);
HttpEntity entity = response.getEntity();
String response = convertStreamToString(entity.getContent());
Edit 2: Just tested this with the Nest Home Simulator, and it works perfectly fine. The real hardware is problematic though