homebridge-nest
homebridge-nest copied to clipboard
It would be great to coalesce requests to change temperature
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":"
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 what about using _.debounce
https://lodash.com/docs#debounce
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.
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.
Here it is: https://github.com/KraigM/homebridge-nest/pull/115/files
for the impatient: https://www.npmjs.com/package/homebridge-nest-debounced