chrisjshull / homebridge-nest

Nest plugin for HomeBridge
700 stars 112 forks source link

Optional configuration of scan interval #526

Closed EjvindHald closed 2 years ago

EjvindHald commented 2 years ago

By using Pihole to look at my internet traffic, it is clear that this plugin generates much traffic.

To better control this I would like a new optional setting to set the scan interval.

The only way to stop using so much bandwith for my total 10 Nest devices is to stop this great plugin. And this is not desireable.

adriancable commented 2 years ago

@EjvindHald - what kind of Nest devices do you have, and what do you mean by 'scan interval'? And, roughly how much traffic (e.g. in MB/day) are you seeing?

EjvindHald commented 2 years ago

@adriancable - I have 9 Nest Learning Thermostat E and 1 Nest Protect device. Your great plugin sync Homekit and thermostat close to real time, but I can live with a delay of e.g. 10 seconds. I assume that this could reduce the bandwidth needed. See this integration for Home Assistant, where similar is implemented: https://github.com/therealryanbonham/badnest

Unfortuntely, I have removed my Pihole installation again, so I do not have the stats. I will try to get some stats, but it will take a few days to collect a proper sample.

adriancable commented 2 years ago

@EjvindHald - sorry, I still don't understand your request. What do you mean by 'scan interval'?

I interpret this to mean something to do with polling, but that doesn't apply to the homebridge-nest plug-in which does not do any kind of polling. The Nest APIs (both the REST and protobuf APIs) use a subscribe/observe model which pushes device state updates to clients like homebridge-nest as and when they occur. There is no polling.

What do you mean by "delay of 10 seconds"? Given that we don't poll, why we would we intentionally want to delay anything?

EjvindHald commented 2 years ago

Sorry, my bad. I thought you were polling and that was the reason for seeing quite high traffic numbers. So it is purely event driven and communication to Goggle/Nest only happens in case of a change in temperature or setting? If yes, then I will have to look at my stats again.

adriancable commented 2 years ago

Yes, that’s exactly right.

iMicknl commented 2 years ago

So it is purely event driven and communication to Goggle/Nest only happens in case of a change in temperature or setting?

@adriancable I think the mechanism works a bit different. In order to subscribe to new events, there will be a POST request to the Google server. If a new update arrives or the connection times out, a new POST request will be registered. This means that there will be a lot of (small) requests, which is probably what @EjvindHald is seeing.

Unfortunately Google doesn't offer any other model (with a webhook e.g.) where they actively push changes. It is only possible to subscribe and listen for new changes, which is more some kind of long poll / observer mechanism.