Nest Thermostat integration keeps throwing "Too Many Requests'"

Just set up the Nest Thermostat integration using the official documentation.
It’s very unreliable so far. If I change the temperature now, it works for the first time but if I try again 20 seconds from now it will either say “Too many requests” or “Bad Request”.

Is this normal or am I doing something wrong?

2021-01-23 02:42:56 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [2392309230909099] Error from API: 400, message='Bad Request',url=URL('https://smartdevicemanagement.googleapis.com/v1/enterprises/superloneditedcode:executeCommand')
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 57, in raise_for_status
resp.raise_for_status()

or

2021-01-23 02:43:04 WARNING (MainThread) [homeassistant.components.cloud.google_config] Error reporting state - 5: Requested entity was not found.
2021-01-23 02:43:07 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [2392309230909099] Error from API: 429, message='Too Many Requests', url=URL('https://smartdevicemanagement.googleapis.com/v1/enterprises/superlongeditedcode:executeCommand')
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/google_nest_sdm/auth.py", line 57, in raise_for_status
resp.raise_for_status()
1 Like

same thing happening to me

Hi, no, the first error message is not normal. To help me understand the problem, what version of home assistant are you running? Each release contains many fixes so want to make sure you are on the latest, in particular because I think we should be getting a better error message from the first failure, and the code looks out of sync with the latest build which had improvements here.

The “too many requests” comes from a rate limit imposed by nest, however it seems like it would be rare that you would hit these limits: https://developers.google.com/nest/device-access/project/limits

The limits are fairly generous, so I have seen this if you change your temp setting over and over but i only really ever do this when testing the code and have never seen it in “real life”. Perhaps because the first problem fails, then when trying again increase the error rate. So, lets focus on the first problem for now instead of this one, then see if it clears up the second one.

Wanted to give an update, the API rate limit error has gone away for me (not sure if I did anything to cause that, but it’s gone so I’m happy). I’m fully updated on everything, hope OP gets their’s figured out.

Thanks @allenporter.
I see in the docs that the limit on the THERMOSTAT API is 5 QPM or 100 QPH.

I’m on latest core-2021.1.4 running in Debian GNU/Linux 10 (buster) latest as well because I just switched to Debian.

This does indeed explain why I’m hitting the limit because here’s what happens in my scenario:

  1. I adjust the temperature. (all is well, 1 QPM).
  2. I try to adjust it again. (I either get the “Too many requests” at this point or I get the “Bad Request”).
  3. If i get the “Bad Request” and I try a few more times, I start getting the “Too many requests” every time.

It seems to me that the Bad Request occurs more often when I’m using the internal address to access lovelace (http://192.168.1.8:8123) instead of the external Nabu Casa URL.

When I set up the thermostat, I used the Nabu Casa external URL to set it up because it wouldn’t let me use my unsecure internal address.

I just updated to core-2021.1.5 supervisor-2021.1.7.

I no longer get the “Bad Requests” so far but I still get the “Too many Requests” after the second or third attempt at changing the temperature.

  1. Change the temperature with the “slider” (1 QPM)
  2. Change the temperature again with the slider (2 QPM).
  3. Change the temperature again with the slider (Too many requests).

I’m assuming the current integration sends 2 queries per call so you are really limited at changing the thermostat a max of twice per minute which is kind of limiting with my fat fingers not setting the temperature right the first time but understandable.

I’ll keep this updated.

There is an initial api call on start to fetch devices, but then from there a single call per temp change. Updates flow via the pubsub subscriber with no sdm API calls.

How many devices do you have?

Just 1.

Ok that makes sense. Just tried it again from the remote URL and internal and this time I got 5 attempts each.
I just didn’t realize that just touching the slider without changing the temperature counts as one attempt. Like I said, fat fingers :slight_smile:

Thanks for the update suggestion, that seems to have fixed the “Bad Request” error.

I have 6 thermostats and it seems I just hit the rate-limit all of the time. Anyone have a good work around? I guess it’s because I hit the per user rate limit when I change all of the thermostats at once? Not really sure…

Really quite frustrating that this integration because Google sucks actually is less reliable then using the hacky Nest HomeBridge way.

1 Like

have you made sure your api project is in production mode? ever since changing from test > production mode I haven’t had this issue (step 8 of the instructions here: https://www.home-assistant.io/integrations/nest/#device-access-registration)

Just tried this last night. Guess I’ll see if it stops happening but right after I got one.

any more issues?

@omnivoyager yes, still having the same issue.

Even worse now… just randomly needs to be reconnected cause all the devices were not working for days.

Sorry you’re still having trouble, unfortunately, I’m no real help seeing that I’m not an advanced coder; pushing my API project live is what did it for me.

Hi @jarrett – to clarify: are you saying that you are forced through the re-authentication flow? If it forces you to re-authenticate every 7 days, it may be related to a setting in the OAuth Consent screen. See Reauthentication required often in the integration troubleshooting section of the documentation:
https://www.home-assistant.io/integrations/nest/#troubleshooting – someone mentioned this earlier in the thread, but you said you already checked this so just wanted to confirm.

I would be happy to help dig deeper into the issues you are seeing if you can give me some additional details, or want to file a github issue with logs, and an explanation with a little more technical detail.

Meanwhile, check out all the troubleshooting steps in the docs that cover 95% of the problems people report in this forum.

Yeah it’s not a reauthentication issue. I get a rate limit error. I can get the exact error message when I’m on the computer. Is there any other information I should include besides some log messages?

@jarrett Whats the “reconnected” problem?

I am also getting the too many requests error. @jarrett did you ever resolve this?

@allenporter this was from me not having the app in production mode.

@loaxley nope still randomly happens.