Skip to content

Catch exception on reserve value#3469

Merged
springfall2008 merged 1 commit intomainfrom
fixes11
Mar 3, 2026
Merged

Catch exception on reserve value#3469
springfall2008 merged 1 commit intomainfrom
fixes11

Conversation

@springfall2008
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings March 2, 2026 20:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Predbat to avoid crashing when inverter entity values (notably reserve-related) can’t be parsed as floats during write-and-poll verification, and bumps the application version accordingly.

Changes:

  • Bump THIS_VERSION to v8.33.11.
  • Add float-conversion exception handling when re-reading and comparing inverter values in write_and_poll_value().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
apps/predbat/predbat.py Version bump to reflect the change release.
apps/predbat/inverter.py Harden numeric comparison in write_and_poll_value() by handling non-numeric current_state values.

Comment on lines +1730 to +1734
try:
current_state = float(current_state)
except (ValueError, TypeError):
current_state = 0.0
matched = abs(current_state - new_value) <= fuzzy
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

On conversion failure, current_state is forced to 0.0 and then used for the fuzzy comparison. This can incorrectly mark the value as already matched (e.g., when new_value is 0 or fuzzy is large), causing the method to stop retrying even though the real state was non-numeric (e.g., unknown). Consider treating conversion failure as matched = False (and optionally logging the unexpected state) so the write/poll loop doesn’t silently succeed on bad sensor values.

Copilot uses AI. Check for mistakes.
@springfall2008 springfall2008 merged commit 10976ea into main Mar 3, 2026
5 checks passed
@springfall2008 springfall2008 deleted the fixes11 branch March 3, 2026 08:06
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