问题
I use a very cool Google Script I found on Github (source: https://gist.github.com/beezly/9b2de3749d687fdbff3f) to fetch the temperature on my Nest thermostat and log it into a Google Spreadsheet.
It is working great when I run the script manually, but not when I use a time trigger to run it automatically.
When posting the credential to the API on this line:
Line 12: var response = JSON.parse(UrlFetchApp.fetch('https://home.nest.com/user/login', options).getContentText());
The exception raised is:
Request failed for https://home.nest.com/user/login returned code 429. Truncated server response: Too many requests (use muteHttpExceptions option to examine full response) (line 12, file "Code")
I suspect that I'm not the only one using the script, and the Google source IP used by the trigger has exceeded the limit of the Nest API.
Would you have any solution for me? I have considered using a Proxy server, but the UrlFetchApp.fetch
function does not seem to accept it.
Thank you,
PF
回答1:
I only ran into the "Too many requests" error during development when I was testing that same script. I was able to get this function to run hourly no problem, even every 5 minutes.
To get this script run as expected on a trigger just switch the getData() to a doGet(), publish it as a web app with anonymous access then create another function (i called it getData()) that makes a request to your published web app url (which invokes a doGet()), then just create your time-based trigger to run the new getData().
here's my version https://gist.github.com/jbutters/bece2fffe85080fe4314
来源:https://stackoverflow.com/questions/28434686/rate-limit-error-to-nest-thermostat-response-code-429