Repository navigation
FoxAPI - handle errors better - #2800
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves error handling in the FoxAPI client by distinguishing between retryable and non-retryable errors. The changes prevent unnecessary retries for permanent failures (authentication errors, unsupported functions, invalid parameters) while allowing retries for transient issues (timeouts, rate limiting).
Key changes:
- Modified
request_get_functo return a tuple indicating whether retries are allowed - Added handling for new error codes (44096 for unsupported functions, 40257 for invalid parameters)
- Enhanced logging messages and extended rate limiting wait times
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| apps/predbat/predbat.py | Version bump to v8.26.2 |
| apps/predbat/fox.py | Enhanced error handling with retry control, improved error code handling, and better logging |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| self.log("Info: Fox: Rate limiting detected, waiting...") | ||
| await asyncio.sleep(random.random() * 30 + 1) | ||
| return None, True |
There was a problem hiding this comment.
This rate limiting handling duplicates the logic at lines 869-871. Consider extracting this into a helper method to avoid code duplication.
| # res = await fox_api.get_device_settings(sn) | ||
| # res = await fox_api.get_battery_charging_time(sn) | ||
| res = await fox_api.get_scheduler(sn) | ||
| #res = await fox_api.get_scheduler(sn) |
There was a problem hiding this comment.
[nitpick] Inconsistent comment formatting: this line has no space after # while line 1271-1273 and 1275-1276 have a space. Add a space after # for consistency.
| #res = await fox_api.get_scheduler(sn) | |
| # res = await fox_api.get_scheduler(sn) |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.