1

I'm building an Application that integrates with your Nest devices (both the thermostat and the Nest Protect, but this issue is about the thermostat).

What I'm trying to do is set my thermostat's ETA to be in x minutes (2 hours for example so 120 minutes).

This is my code that I'm executing:

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
final String path = buildStructureFieldPath(structureID, Keys.STRUCTURE.ETA);
Structure.ETA eta = new Structure.ETA.Builder()
        .setTripID(tripId)
        .setEstimatedArrivalWindowBegin(sdf.format(estimatedArrivalBegin))
        .setEstimatedArrivalWindowEnd(sdf.format(estimatedArrivalEnd))
        .build();
sendRequest(path, eta.toJSON().toString(), listener);

The path is /structures/MY_STRUCTURE_ID/eta

Unfortunately that's not working. I'm always getting an error code -2 and error message: No write permission(s) for field(s): eta

And that's were it gets strange. No permission, but I did request the permission and I did an authenticate, which is successful, before launching the update call.

In the two attached screenshots you can see first my Nest Developer Account where you can find the ETA write permission and in the second you can see the logging from within my app (using the NestAPI as can be found on GitHub, just added the ETA feature myself).

Nest Developer Account

App logging

Anyone have any idea on how to solve this issue?

sbolel
  • 3,486
  • 28
  • 45
dirkvranckaert
  • 1,364
  • 1
  • 17
  • 30

1 Answers1

0

Can you print out the exact JSON blob you're sending and post it here? (the value of eta.toJSON().toString())

Best guess is that it isn't formatted exactly correctly and as such is maybe attempting to write in such a way that doesn't adhere to the api-reference.

This is the format that it needs to match:

"eta": {
    "trip_id": "myTripHome1024" ,
    "estimated_arrival_window_begin": "2015-10-31T22:42:59.000Z" ,
    "estimated_arrival_window_end": "2015-10-31T23:59:59.000Z"
}

Single line:

{"eta":{"trip_id":"myTripHome1024","estimated_arrival_window_begin":"2015-10-31T22:42:59.000Z","estimated_arrival_window_end": "2015-10-31T23:59:59.000Z"}}

To pinpoint exactly which field may be erroneous, try sending just one change at a time for each ie: structures/ID/eta/trip_id, etc for the others.

Useful JSON Validator: http://jsonlint.com/

You could also try to send it to /structures/MY_STRUCTURE_ID.json?auth=[TOKEN] instead of /structures/MY_STRUCTURE_ID/eta.

Enigma
  • 1,247
  • 3
  • 20
  • 51
  • This is currently my request JSON: {"trip_id":"f8589b18-8b81-4f70-8050-9839c324f039","estimated_arrival_window_begin":"2015-05-17 10:11:44.693+0000","estimated_arrival_window_end":"2015-05-17 10:21:44.693+0000"}, Probably I'm missing the "eta" wrapper object... Just don't know exactly how to get there with JSONObject instances to get the wrapper around it... – dirkvranckaert May 17 '15 at 06:16
  • You would just wrap another {} around it with "eta": at the head but inside the second {}'s. `{"eta":{"trip_id":"myTripHome1024","estimated_arrival_window_begin":"2015-10-31T22:42:59.000Z","estimated_arrival_window_end": "2015-10-31T23:59:59.000Z"}}` Also feel free to use something like: http://jsonlint.com/ – Enigma May 17 '15 at 13:27