potmat / homebridge-google-nest-sdm

A Homebridge plugin for Google Nest devices that uses the Google Smart Device Management API. Supports Cameras, Doorbells, Displays, and Thermostats. Includes support for HomeKit Secure Video.
ISC License
140 stars 17 forks source link

rateLimitExceeded #99

Open walking opened 1 year ago

walking commented 1 year ago

Hi! I get this error every time I try to change the temperature in the Nest Thermostat

Could not execute device command: {"response":{"config":{"url":"https://smartdevicemanagement.googleapis.com/v1/enterprises/[myProjectId]/devices/[deviceId]:executeCommand","method":"POST","userAgentDirectives":[{"product":"google-api-nodejs-client","version":"5.1.0","comment":"gzip"}],"data":{"command":"sdm.devices.commands.ThermostatTemperatureSetpoint.SetRange","params":{"heatCelsius":22.5,"coolCelsius":25}},"headers":{"x-goog-api-client":"gdcl/5.1.0 gl-node/16.14.2 auth/7.14.1","Accept-Encoding":"gzip","User-Agent":"google-api-nodejs-client/5.1.0 (gzip)","Authorization":"Bearer [Bearer value]","Content-Type":"application/json","Accept":"application/json"},"params":{},"retry":true,"body":"{\"command\":\"sdm.devices.commands.ThermostatTemperatureSetpoint.SetRange\",\"params\":{\"heatCelsius\":22.5,\"coolCelsius\":25}}","responseType":"json","retryConfig":{"currentRetryAttempt":0,"retry":3,"httpMethodsToRetry":["GET","HEAD","PUT","OPTIONS","DELETE"],"noResponseRetries":2,"statusCodesToRetry":[[100,199],[429,429],[500,599]]}},"data":{"error":{"code":429,"message":"Rate limited for the SetThermostatTemperatureRange command for the user.","errors":[{"message":"Rate limited for the SetThermostatTemperatureRange command for the user.","domain":"global","reason":"rateLimitExceeded"}],"status":"RESOURCE_EXHAUSTED"}},"headers":{"alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000","cache-control":"private","connection":"close","content-encoding":"gzip","content-type":"application/json; charset=UTF-8","date":"Wed, 06 Sep 2023 05:25:25 GMT","server":"ESF","transfer-encoding":"chunked","user-id":"[UserId]","vary":"Origin, X-Origin, Referer","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","x-xss-protection":"0"},"status":429,"statusText":"Too Many Requests","request":{"responseURL":"https://smartdevicemanagement.googleapis.com/v1/enterprises/[ProjectId]/devices/[deviceId]:executeCommand"}},"config":{"url":"https://smartdevicemanagement.googleapis.com/v1/enterprises/[ProjectId]/devices/[deviceId]:executeCommand","method":"POST","userAgentDirectives":[{"product":"google-api-nodejs-client","version":"5.1.0","comment":"gzip"}],"data":{"command":"sdm.devices.commands.ThermostatTemperatureSetpoint.SetRange","params":{"heatCelsius":22.5,"coolCelsius":25}},"headers":{"x-goog-api-client":"gdcl/5.1.0 gl-node/16.14.2 auth/7.14.1","Accept-Encoding":"gzip","User-Agent":"google-api-nodejs-client/5.1.0 (gzip)","Authorization":"Bearer [Bearer]","Content-Type":"application/json","Accept":"application/json"},"params":{},"retry":true,"body":"{\"command\":\"sdm.devices.commands.ThermostatTemperatureSetpoint.SetRange\",\"params\":{\"heatCelsius\":22.5,\"coolCelsius\":25}}","responseType":"json","retryConfig":{"currentRetryAttempt":0,"retry":3,"httpMethodsToRetry":["GET","HEAD","PUT","OPTIONS","DELETE"],"noResponseRetries":2,"statusCodesToRetry":[[100,199],[429,429],[500,599]]}},"code":429,"errors":[{"message":"Rate limited for the SetThermostatTemperatureRange command for the user.","domain":"global","reason":"rateLimitExceeded"}]} Dining Room Thermostat

The values for projectId, deviceId, Bearer or userId have been replaced, the originals look fine. The account is new and there is no limit reached in the panel.

Thanks in advance!

potmat commented 11 months ago

Hi @walking, does this happen with any other action? The request is definitely blocked by Google due to API rate limiting. Are you doing lots of other stuff? HKSV perhaps?

walking commented 11 months ago

Hi! Thanks for your reply. Nope. Just for the thermostat and every time I try to change the temperature. I'm not using any google device service or any other api or functionality from google. I've tried to setup it several times and always the same...Usually I can only change the temperature once a day. If I move from 70 to 72, it tries to call it for 70.5,71,71.5 and 72. So every time that I try to change the temperature it can be more than 2 or 3 calls. And that's the limit for the range... Then I check the dashboard and it says that I only made a couple of calls and I didn't reach any limit...

potmat commented 10 months ago

Hi @walking, I've been keeping an eye on this at my home and nothing I do seems to cause this behaviour. Temperature is always set to exactly what I desire, never in steps. I even upgraded to the "new Home architecture" thinking it might be that, but nope.

Maybe if anyone else has this issue we can get to the bottom of it.

epietrowicz commented 9 months ago

Hey @walking @potmat I just configured this plugin and ran into this issue for my Nest thermostat. What info can I provide to help debug this? My thermostat does not seem to be responding at all. I try to change the temperature, and my Homekit UI just snaps back to the previously set temperature. I try once or twice more and I get the rate limit exceeded error.

I've attached a screenshot of the API requests from my GCP dashboard.

Screenshot 2023-11-14 at 7 31 25 AM

potmat commented 9 months ago

Hi @epietrowicz, try enabling debug mode and provide some logs when the system is making too many requests. Include all the requests, not just the error at the end. Maybe that will shed some light.

dadsalleb commented 9 months ago

I had this issue when I changeed the thermostate temperature and controled fan on/off status at the same time in Home app. I resolved this issue by adding Wait command for 3-5 sec between each request.

walking commented 9 months ago

Hi @dadsalleb can you add more information about how you solved it? Thanks!

dadsalleb commented 9 months ago

Hi, what I did was add 5 sec of wait command after or before any actions (control or getting status) related to the thermostat. But recently got a new error saying that badRequest. So, my final workaround is restarting the this plugin by cmdSwitch2 whenever I want to change the temperature or operate fan, and then combining the automation I mentioned above. It is pretty dirty workaround but it doesn't have be to super responsive, so I'm happy with this workaround for now.

walking commented 7 months ago

How this is completed? We are still having this issue... there is no change in the code to fix it. Could you please leave it open? Thanks!

justin-robinson commented 6 months ago

I'm seeing the same thing on boot. I have 2 thermostats and 4 cameras. This plugin is constantly making my NAS run out of memory now. Applying for a google commercial developer account to see if higher rate limits help.

potmat commented 5 months ago

Hi guys, despite everything I've tried I've never been able to reproduce this. If anyone can, and can submit a PR it would be appreciated.

walking commented 4 months ago

I still don't know how I can fix it on my own. The error is still present and there is no way to use it with homebridge

polymorpher commented 4 months ago

I had the same rate limit error. I have 3 cameras (Google Home indoor wired, indoor/outdoor wireless, and an old wired Nest camera). Most of the time I don't see any snapshot, get no event / motion detection, and streaming has been really slow. I ended up just deleting the plugin and am buying a bunch of new cameras with good HomeKit / Homebridge support. Would love to get the three Google Home / Nest camera working again in HomeKit some day.