嵌套恒温器的速率限制错误-响应代码429 [英] Rate Limit Error to Nest Thermostat - Response Code 429

查看:123
本文介绍了嵌套恒温器的速率限制错误-响应代码429的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用我在Github上找到的非常酷的Google脚本(来源: https://gist.github. com/beezly/9b2de3749d687fdbff3f )来获取Nest恒温器上的温度并将其记录到Google电子表格中.

当我手动运行脚本时,效果很好,但是当我使用时间触发器自动运行脚本时,效果不佳.

在此行上将凭证发布到API时:

第12行:var response = JSON.parse(UrlFetchApp.fetch('https://home.nest.com/user/login', options).getContentText());

引发的异常是:

https://home.nest.com/user/login 返回代码的请求失败429. 服务器响应被截断:请求太多(使用MutantHttpExceptions 检查完整响应的选项)(第12行,代码"文件)

我怀疑我不是唯一一个使用该脚本的人,并且触发器使用的Google源IP已超出Nest API的限制.

您对我有什么解决办法吗?我已经考虑过使用代理服务器,但是UrlFetchApp.fetch函数似乎不接受它.

谢谢

PF

解决方案

在测试同一脚本时,在开发过程中我只遇到了请求过多"错误.我能够使该功能每小时运行一次,即使每5分钟也没问题.

要使此脚本按预期在触发器上运行,只需将getData()切换为doGet(),将其发布为具有匿名访问权限的Web应用程序,然后创建另一个函数(我将其称为getData())即可发出请求到已发布的Web应用程序url(将调用doGet())中,然后只需创建基于时间的触发器即可运行新的getData().

这是我的版本 https://gist.github.com/jbutters/bece2fffe85080fe4314

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

解决方案

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

这篇关于嵌套恒温器的速率限制错误-响应代码429的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆