homebridge-nest icon indicating copy to clipboard operation
homebridge-nest copied to clipboard

It would be great to coalesce requests to change temperature

Open joeyhagedorn opened this issue 9 years ago • 5 comments
trafficstars

Often I'll tap a few degrees up or down. Rather than making separate requests to the api that count against my API quota, it'd be great if there were some coalescing period, or if homebridge-nest kept the connection open to the server so I wouldn't hit the rate limit. According to the documentation (https://developers.nest.com/documentation/cloud/data-rate-limits) it appears that Firebase api connections should be kept open and many commands sent over a single connection, rather than re-establishing them all of the time.

I found requests started failing because i was adjusting the temperature too rapidly and play with it, then in the home bridge logs I encounter lots of failures like this:

Fri, 29 Apr 2016 06:05:09 GMT Accessory [Homebridge Raspberry Pi] Error setting Characteristic "Target Temperature" to value 18.6: BLOCKED: {"error":"blocked","type":"https://developer.nest.com/documentation/cloud/error-messages#blocked","message":"blocked","instance":""}

joeyhagedorn avatar Apr 29 '16 06:04 joeyhagedorn

Maybe we only send the new temp to Nest 5 seconds after your last update; that way if you send another command in less then 5 seconds, the 5 second delay will be reset?

KraigM avatar Jun 04 '16 15:06 KraigM

@KraigM what about using _.debounce

https://lodash.com/docs#debounce

lzilioli avatar Jul 14 '16 01:07 lzilioli

Running into this with the Apple Home app. The temperature adjust slider causes many requests to go out to the point where by the time I get the slider where I want I've been rate limited =\ A debounce of 5 seconds like you mentioned would probably prevent this.

caseywebdev avatar Sep 14 '16 03:09 caseywebdev

https://github.com/KraigM/homebridge-nest/issues/82 https://github.com/KraigM/homebridge-nest/issues/83 https://github.com/KraigM/homebridge-nest/issues/37

Looks like same issue. I can implement a debounce here and submit a PR.

igbopie avatar Jan 24 '17 21:01 igbopie

Here it is: https://github.com/KraigM/homebridge-nest/pull/115/files

for the impatient: https://www.npmjs.com/package/homebridge-nest-debounced

igbopie avatar Jan 26 '17 06:01 igbopie