Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Polling Behavior Impacts API interactions and updates. #333

Open
JasonGoldenDDT opened this issue Feb 17, 2025 · 0 comments
Open

API Polling Behavior Impacts API interactions and updates. #333

JasonGoldenDDT opened this issue Feb 17, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@JasonGoldenDDT
Copy link

Working on latest 2.0.0-beta.4

I am noticing frequent polling of the API in the log. This behavior affects how the Apps can access the data. I am suggesting we eliminate interval polling as ThinQ V2 devices send "heartbeat" MQTT messages that keep things in sync. Asking the API should be a fall back.

Asking Co-Pilot to improve polling behavior. Findings:

`// ThinQ2 devices polling (backup method)
setInterval(() => {
this.ThinQ.devices().then((devices) => {
devices.filter(device => device.platform === PlatformType.ThinQ2)
.forEach(device => {
this.events.emit(device.id, device.snapshot);
});
});
}, this.intervalTime);

// ThinQ1 devices polling
const interval = setInterval(async () => {
try {
for (const accessory of this.accessories) {
const device = accessory.context.device;
if (device.platform === PlatformType.ThinQ1 && this.enable_thinq1) {
const deviceWithSnapshot = await ThinQ.pollMonitor(device);
if (deviceWithSnapshot.snapshot.raw !== null) {
this.events.emit(device.id, deviceWithSnapshot.snapshot);
}
}
}
} catch (err) {
// ... error handling
}
}, this.intervalTime);`

Key issues to address:

Both polling mechanisms use the same fixed intervalTime
No exponential backoff on failures
Sequential polling could cause delays
No consideration for device state changes

@JasonGoldenDDT JasonGoldenDDT added the bug Something isn't working label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant