-
-
Notifications
You must be signed in to change notification settings - Fork 94
Fix potential crash, GECloud missing entity, Web dashboard html escape issue #3276
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
Conversation
… to predbat stopping running
There was a problem hiding this comment.
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 fixes a critical bug where exceptions in load_user_config() or validate_config() would cause the prediction_started flag to remain True, permanently blocking all future predictions and causing Predbat to stop running. The fix moves these potentially-failing operations inside try-catch blocks so that the finally block can properly reset the flag.
Changes:
- Moved
load_user_config()andvalidate_config()calls inside try-catch blocks in bothupdate_time_loop()andrun_time_loop() - Improved error logging in
hass.pytimer_tick() to provide better context - Version bump from v8.32.10 to v8.32.11
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/predbat/predbat.py | Moved config loading operations inside try-catch blocks in update_time_loop() and run_time_loop() to ensure prediction_started flag is properly reset on exceptions; version bump |
| apps/predbat/hass.py | Enhanced error message in timer_tick() exception handler to include more context |
Comments suppressed due to low confidence (2)
apps/predbat/predbat.py:1593
- The changes to exception handling in
update_time_loop()lack test coverage. Consider adding tests that verify: 1)prediction_startedis properly reset to False when exceptions occur inload_user_config()orvalidate_config(), and 2) subsequent iterations can run after an exception. This is critical functionality that prevents predbat from stopping permanently.
try:
self.load_user_config()
self.validate_config()
self.update_pred(scheduled=False)
self.create_entity_list()
except Exception as e:
self.log("Error: Exception raised {}".format(e))
self.log("Error: " + traceback.format_exc())
self.record_status("Error: Exception raised {}".format(e), debug=traceback.format_exc(), had_errors=True)
raise e
finally:
self.prediction_started = False
apps/predbat/predbat.py:1667
- The changes to exception handling in
run_time_loop()lack test coverage. Consider adding tests that verify: 1)prediction_startedis properly reset to False when exceptions occur during config loading or prediction, 2)update_pendingstate is handled correctly on exception, and 3) subsequent iterations can run after an exception. This is critical functionality that prevents predbat from stopping permanently.
try:
config_changed = False
if self.update_pending:
self.update_pending = False
self.ha_interface.update_states()
self.load_user_config()
self.validate_config()
config_changed = True
# Run the prediction
self.update_pred(scheduled=True)
if config_changed:
self.create_entity_list()
except Exception as e:
self.log("Error: Exception raised {}".format(e))
self.log("Error: " + traceback.format_exc())
self.record_status("Error: Exception raised {}".format(e), debug=traceback.format_exc(), had_errors=True)
raise e
finally:
self.prediction_started = False
| self.check_entity_refresh() | ||
| if self.update_pending and not self.prediction_started: | ||
| # Full update required | ||
| self.update_pending = False |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent handling of update_pending flag compared to run_time_loop(). In run_time_loop() (line 1650), update_pending is set to False inside the try block, ensuring it's only cleared after successful config loading. However, here it's set to False before the try block. If an exception occurs in load_user_config() or validate_config(), the pending update will be lost and won't retry on the next iteration. Consider moving line 1580 inside the try block for consistency and correctness.
Add missing inverter data: #3268
… to predbat stopping running