Documentation about when attributes may be omitted from response?


#1

I have been working on Python bindings for the Nest API over in https://github.com/jkoelker/python-nest/pull/49 . Since starting on that work, I have been getting report by different users that they are getting errors back for some fields.

In the code, we are getting JSON back, and that becomes a python dictionary, and then pulling them out with the array notation, ie data[key]. However, it seems that a ton of fields are omitted from the JSON response rather than being null. That gives a KeyError from python, which I can work around by using .get, but I’d be worried about making all my code use this for values that are expected to exist. Some fields observed being omitted so far:

  • is_locked
  • locked_temp_min_f
  • eco_temperature_f

The API reference doesn’t talk about this at all. I’m not able to use the Nest Home Simulator to create those same condition

My best guess is that maybe these users had thermostats that existed before the fields were added, or maybe their thermostats need updating?


#2

Most likely this is due to having an access token associated to an old permission version. If a client is updated, than new fields will be exposed to those users that have allowed the new permission but will not be exposed to those that have not allowed the new permissions.

Please see the following about client versions.

https://developers.nest.com/documentation/cloud/client-version/


#3

Thanks for the info, will check that out.

Will this happen if a product doesn’t have a particular permission, and a user uses an authorized token on a field that wouldn’t be granted by the product’s permissions?


#4

If a product doesn’t have a particular permission, than none of the fields associated to that permission will appear in the API. For example, if the product does not have thermostat read, or thermostat read/write, permission, than none of the fields for thermostat will appear, although there are some permissions that have overlaps, like structure “away” which exists in both Away read and Thermostat read.