ToddGreenfield / homebridge-airnow

Homebridge plugin for AirNow Web-API Air Quality Sensor
36 stars 10 forks source link

Polling appears to occur too often #12

Closed deanlyoung closed 4 years ago

deanlyoung commented 4 years ago
[Homebridge] [4/13/2020, 1:03:55 PM] [AirNow] AirNow air quality AQI is: 54
[Homebridge] [4/13/2020, 1:03:56 PM] [AirNow] AirNow air quality AQI is: 54
[Homebridge] [4/13/2020, 1:03:58 PM] [AirNow] AirNow air quality AQI is: 54
[Homebridge] [4/13/2020, 1:04:01 PM] [AirNow] AirNow air quality AQI is: 54
[Homebridge] [4/13/2020, 1:04:03 PM] [AirNow] AirNow air quality AQI is: 54
[Homebridge] [4/13/2020, 1:04:05 PM] [AirNow] AirNow air quality AQI is: 54
[Homebridge] [4/13/2020, 1:04:07 PM] [AirNow] AirNow air quality AQI is: 54
[Homebridge] [4/13/2020, 1:04:08 PM] [AirNow] AirNow air quality Network or Unknown Error from airnow.
[Homebridge] [4/13/2020, 1:04:09 PM] [AirNow] AirNow air quality Network or Unknown Error from airnow.
[Homebridge] [4/13/2020, 1:04:10 PM] [AirNow] AirNow air quality Network or Unknown Error from airnow.

It's not quite clear what this portion is for

https://github.com/ToddGreenfield/homebridge-airnow/blob/5210af192da54740bc4cd5fd5a25c69068e30d86/index.js#L87

it appears redundant to this portion

https://github.com/ToddGreenfield/homebridge-airnow/blob/5210af192da54740bc4cd5fd5a25c69068e30d86/index.js#L93

and only called here

https://github.com/ToddGreenfield/homebridge-airnow/blob/5210af192da54740bc4cd5fd5a25c69068e30d86/index.js#L287

It does not follow the setTimeout polling convention here

https://github.com/ToddGreenfield/homebridge-airnow/blob/5210af192da54740bc4cd5fd5a25c69068e30d86/index.js#L81

which I believe is resulting in the API getting called too often

deanlyoung commented 4 years ago

@ToddGreenfield any chance you could take a look? I'd love to understand your approach on this in case I am misunderstanding.

ToddGreenfield commented 4 years ago

What is your polling set to in the config? If I recall, GetAirQuality is called by HomeKit, GetObservation is what actually calls out to the api. It should not be redundant. I havent used for a while now and don’t actively maintain at this time. Try setting your polling to a higher number like 300 or 600.

deanlyoung commented 4 years ago

Thanks for the insights! I'll try the longer polling interval.