Skip to content

FoxAPI - handle errors better - #2800

Merged
springfall2008 merged 4 commits into
mainfrom
fixes5
Oct 22, 2025
Merged

springfall2008 merged 4 commits into
mainfrom
fixes5

Conversation

@springfall2008

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_func to 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.

Comment thread apps/predbat/fox.py Outdated
Comment thread apps/predbat/fox.py Outdated
Comment thread apps/predbat/fox.py
Comment on lines +838 to +840
self.log("Info: Fox: Rate limiting detected, waiting...")
await asyncio.sleep(random.random() * 30 + 1)
return None, True

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rate limiting handling duplicates the logic at lines 869-871. Consider extracting this into a helper method to avoid code duplication.

Copilot uses AI. Check for mistakes.
Comment thread apps/predbat/fox.py Outdated
# 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)

Copilot AI Oct 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
#res = await fox_api.get_scheduler(sn)
# res = await fox_api.get_scheduler(sn)

Copilot uses AI. Check for mistakes.
springfall2008 and others added 3 commits October 22, 2025 09:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@springfall2008
springfall2008 merged commit 08e821c into main Oct 22, 2025
1 check passed
@springfall2008
springfall2008 deleted the fixes5 branch October 22, 2025 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants