Merged
Conversation
- Handle AWS_ERROR_MQTT_CONNECTION_DESTROYED in mqtt_connection.py publish() - Marks connection as disconnected to trigger reconnection handler - Logs warning with context about AWS-initiated disconnections - Allows reconnection handler to recover automatically - Improve error classification in mqtt_periodic.py - Distinguish between CANCELLED_FOR_CLEAN_SESSION (debug) and CONNECTION_DESTROYED (warning) - Prevents 'Future exception was never retrieved' errors - Continues periodic requests despite connection destruction Fixes periodic timeouts (~24h) when AWS IoT Core disconnects clients after their timeout limit. Ensures seamless recovery without manual intervention required in Home Assistant.
- Simplify multi-line condition in mqtt_periodic.py to single line - Format examples and other files per ruff format standards All code now passes ruff linting and formatting checks.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates emoji and special character indicators throughout the codebase to use plain text alternatives (e.g., ✅ → [SUCCESS], ❌ → [ERROR]). This improves compatibility across different terminal environments and CI systems that may not properly render Unicode emoji characters.
Key Changes
- Replaced all emoji indicators with bracket-wrapped text equivalents throughout examples, scripts, and documentation
- Updated error handling messages in MQTT connection code to handle
AWS_ERROR_MQTT_CONNECTION_DESTROYEDevents - Changed User-Agent string from
NaviLink-Python/1.0.0tonwp500-python/1.0.0for consistency with package naming - Added comprehensive new documentation files for data conversions, scheduling features, and advanced features
Reviewed Changes
Copilot reviewed 48 out of 49 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/nwp500/mqtt_periodic.py | Enhanced error handling for MQTT connection destruction with improved logging |
| src/nwp500/mqtt_connection.py | Added specific handling for AWS connection destruction during publish operations |
| src/nwp500/auth.py | Updated User-Agent header to match package name |
| scripts/*.py | Replaced emoji indicators with plain text alternatives for better terminal compatibility |
| examples/*.py | Replaced emoji indicators with plain text alternatives throughout all example files |
| docs/*.rst | Replaced emoji/special characters with plain text and added new comprehensive documentation |
- Import __version__ from package instead of hardcoding - User-Agent now reflects actual package version via setuptools_scm - Follows project version management guidelines (no hardcoded versions) This ensures the User-Agent header always uses the correct version from setuptools_scm without manual updates.
- Extract error_name once using conditional expression and getattr() - Eliminate nested if statements for cleaner control flow - Remove duplicate error logging (RuntimeError path) - Use elif chain instead of nested if/elif - Improves readability and reduces code nesting The logic remains identical but is now more maintainable.
- Remove redundant 'ERROR:' prefix from error messages - Replace with ❌ emoji for consistency - Apply ruff formatting fixes (whitespace, line length) - Remove unnecessary f-string prefix (no placeholders) Error messages now have consistent formatting without duplication.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.