Rebuilding the Nest plugin

For heating/cooling related questions in Domoticz
poudenes
Posts: 513
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Rebuilding the Nest plugin

Post by poudenes » Wednesday 13 June 2018 21:32

dotms wrote:Nest throwing a 307 redirect either means:
  • There is some maintenance happening at their side. That should be transient and resolve itself.
  • You hit some rate limit. This can be fixed by polling less frequently.
The latter case which is something that needs to be changed in the plugin. Unfortunately for us Nest does not tell us the actual limits (except that you have crossed the limit) so it remains a guess what a good interval is.
Where in the plugin can I change the rate frequency? And does the normal login password no limit?


Verzonden vanaf mijn iPhone met Tapatalk Pro
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

dotms
Posts: 28
Joined: Monday 01 May 2017 22:52
Target OS: Linux
Domoticz version: git
Location: Netherlands
Contact:

Re: Rebuilding the Nest plugin

Post by dotms » Wednesday 13 June 2018 21:41

Not too sure about the behavior of the mobile API. Chances are that one does not enforce rate limiting since it's not an official API anyway and Nest never bothered to implement rate limiting? But to be frank: I just don't know.

The polling interval is currently not user configurable. But in the code it's in hardware/NestOAuthAPI.cpp line 78:

Code: Select all

#define NEST_POLL_INTERVAL 30

poudenes
Posts: 513
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Rebuilding the Nest plugin

Post by poudenes » Wednesday 13 June 2018 22:45

dotms wrote:Not too sure about the behavior of the mobile API. Chances are that one does not enforce rate limiting since it's not an official API anyway and Nest never bothered to implement rate limiting? But to be frank: I just don't know.

The polling interval is currently not user configurable. But in the code it's in hardware/NestOAuthAPI.cpp line 78:

Code: Select all

#define NEST_POLL_INTERVAL 30
Thanks for the info. Let's hope when I change it and there is smoke it will not wait for the interval before you see it in Domoticz.... Haha 1 minute interval means full burned house before update device in Domoticz haha


Verzonden vanaf mijn iPhone met Tapatalk Pro
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

poudenes
Posts: 513
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Rebuilding the Nest plugin

Post by poudenes » Thursday 14 June 2018 10:08

this is what i can find on NEST Developers website:
So one call per minute max
Per access token limits
Each access token also has an associated rate limit. Establishing connections to the service incurs some overhead, so we limit the number of connections a product can make in a specific time period.

For REST and REST streaming calls, each access token has a limited number of calls. Data rate limits apply to read/write calls via REST, and on read calls via REST streaming. To avoid errors, we recommend you limit requests to one call per minute, maximum.
And those error explanation
Error response
When using REST or REST streaming, you will receive a response code of 429 Too Many Requests.

Handling 307 redirects
When making REST or REST streaming calls, your product will need to handle 307 redirects. Also known as URL forwarding, a 307 Temporary Redirect response provides a new URL for the browser to resubmit a request.

When a 307 redirect happens, you'll need to make the call again with the new URL information. When you do this, you should cache the host and port number for use in future calls with that user/access token. Remember, each call counts toward the rate limit. Consider how your user is interacting with your product. Some users will press a button or choose a setting repeatedly, so if you make a call for every user action, it can impact rate limits very quickly. If a user makes a series of changes in rapid succession, you should only make an API call for the last (most recent) value.

For more information and an example, see How to Handle Redirects.

After 307 redirect
If you are using the redirect URL information and get a 307 redirect at a later time, you should follow that redirect.

Connection error
If you are using the cached URL information and get a connection error (due to host out of service or site down), you should revert to the original base URL.
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

jarr
Posts: 3
Joined: Friday 29 June 2018 5:04
Target OS: Linux
Domoticz version:
Contact:

Re: Rebuilding the Nest plugin

Post by jarr » Saturday 30 June 2018 21:39

The 30 second interval seems to be too short when you're not using the simulator.
I think the interval should be changed to 60 seconds (even though that's not ideal for Protect...). I get no errors at a 60s interval, but toooooons at 30s. Sometimes it won't pull an update for 30 minutes because of the rate limiter which is far worse than waiting 1 minute for an update...

poudenes
Posts: 513
Joined: Wednesday 08 March 2017 10:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Rebuilding the Nest plugin

Post by poudenes » Sunday 01 July 2018 20:21

What will happen if Protect react on spoke or CO. Will we have wait also 1 minute before Domoticz will be updated?
Or will send NEST a request to update the device directly?
RPi3 with OSMC - RPi3 with Domoticz - Dashticz - MiLight - Nanolead Aurora - KaKu - Logitech Hamony - Nest - RFLink

jarr
Posts: 3
Joined: Friday 29 June 2018 5:04
Target OS: Linux
Domoticz version:
Contact:

Re: Rebuilding the Nest plugin

Post by jarr » Sunday 01 July 2018 21:41

Based on how this plugin works, it has to poll the status of devices, so you would have to wait up to 1 minute to know your Protect has been triggered. The plugin would have to re-written again to use the Rest Streaming API or Firebase API to be able to receive realtime changes in devices...

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests