Updating multiple thermostats with one PUT request


#1

We have multiple thermostats registered in the same account. We would like change the target temperature of more than one thermostats at the same time via the REST API. Since we have to respect the rate limits we cannot make more than one call per minute [1]. If we updated thermostats sequentially (waiting 1 minute after each update) this would result in poor user experience. Therefore we combine the updates for multiple thermostats in a single PUT request like this:

$ curl -L -X PUT -H “Content-Type: application/json” -H “Authorization: Bearer c.FLl…” -d “{”-LAf…": {“target_temperature_c”: 22.5}, “f1O…”: {“target_temperature_c”: 22.5}}" ‘https://developer-api.nest.com/devices/thermostats

For this request an HTTP status code 200 (OK) is returned together with the following response from the server:

{"-LAf…": {“target_temperature_c”: 22.5}, “f1O…”: {“target_temperature_c”: 22.5}}

This indicates that the server has accepted our request. However, only one of the two thermostats is actually updated: we see this on the Nest webapp and on the devices themselves. This is also true when we try to update more than two NEST thermostats within the same request. We have tested this with several thermostats and confirmed that it is not an issue of a device being offline. Are we missing something or is this a known issue?

[1] https://developers.nest.com/documentation/cloud/data-rate-limits


#2

The Nest API doesn’t support bundled calls. You’re likely getting 200’s because the HTTP call itself was successful and the server will try to apply what it got, but is going to drop anything bundled together.

I believe the rate limits also apply to specific devices and specific structures. So you should only be hitting the rate limits if you are making more than 10 changes to 10 thermostats in the same structure.

What is your use case out of curiosity?


#3

Thank you for your reply.

Do I understand your statement about rate limits correctly: given 10 thermostats in the same structure, are we allowed to update each thermostat once per minute (i.e., creating in total 10 HTTP PUT requests per minute for the structure) without hitting the rate limits?

If you are interested in the use case, please send me a private message. Thank you.


#4

The rate limit is per device. You should be able to make 10 updates to each of 10 thermostats, or a total of 100 updates for all 10 thermostats. 10 updates to a thermostats for most users is sufficient as typically HVAC units cannot react so quickly.


#5

Thank you for your reply. From your answer (and our tests) I understand that we can make 10 requests per hour per thermostat. For example, one request every 6 minutes, or 10 requests back-to-back and then waiting 1 hour. Can you confirm this?


#6

That is correct. It’s a rolling one hour window, after making 10 requests for the same device, you must wait one hour, from the first request, to make another request for that device. This waiting period allows for recharging of the thermostat battery.


#7

Could you please elaborate further on the “per-device hourly limit” vs the “per-access-token minutely limit”…

Question one - In the above case, can you PUT two updates of different device IDs back to back, or do you need to space them out by one minute?
Question two - Do GETs fall under the same “per-device hourly limit” and “per-access-token minutely limit” as the PUTs, or are those treated differently?

Thanks


#8

Rate limits are per device, so two updates to two different device IDs are each counted separately. You will able to make 10 updates to each device in the rolling hour. After 10 updates to the same device, the device will be locked out of further updates from 1 hour from the first successful update. These counters are for each device.

GETs have a separate higher limit based on the user account not the device. The limit is 180/hr.