-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor HVAC action constants #1298
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
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1298 +/- ##
==========================================
+ Coverage 99.55% 99.60% +0.05%
==========================================
Files 6 6
Lines 678 767 +89
Branches 82 83 +1
==========================================
+ Hits 675 764 +89
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
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 pull request refactors the HVAC action status code handling system from a set-based approach to an enum-based architecture. The changes introduce strongly-typed enums for heating circuit status codes and action categories, replacing manual set memberships and lookups with a more maintainable and self-documenting solution.
Key changes:
- Introduced
HeatingCircuitStatusIntEnum with 70 vendor-specific status codes andHVACActionCategoryenum for 8 simplified action states - Added
get_hvac_action_category()helper function that maps raw status codes to action categories with fallback to IDLE - Removed 7 legacy
BSBLAN_HVAC_ACTION_*constants (sets) and updated all imports, exports, and usages throughout the codebase
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/bsblan/constants.py |
Replaced status code sets with HeatingCircuitStatus and HVACActionCategory enums; added get_hvac_action_category() helper function and internal _STATUS_TO_CATEGORY mapping dictionary |
src/bsblan/__init__.py |
Updated package exports to remove old BSBLAN_HVAC_ACTION_* constants and export new enums and helper function |
examples/control.py |
Refactored get_hvac_action_name() to use enum-based lookup; enhanced print_state() to display both status name and category using new enums |
tests/test_constants.py |
Replaced set-based tests with comprehensive enum tests covering category values, status mappings, value conversions, and package exports |
| except (ValueError, TypeError): | ||
| hvac_action_mapped = "unknown" |
Copilot
AI
Jan 3, 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.
In the exception handler, the status_name variable is not being set when an error occurs. This could lead to status_name being undefined if the code in the try block fails before line 117. Consider setting status_name = "unknown" alongside hvac_action_mapped = "unknown" in the exception handler to ensure both variables are properly initialized in all code paths.



This pull request refactors how HVAC action status codes are handled and mapped to simplified categories. Instead of using multiple sets of status codes and manual mappings, the code now uses new enums (
HeatingCircuitStatusandHVACActionCategory) and a helper function to provide a more maintainable and extensible approach. This change improves clarity and allows for easier future updates to status code handling.Refactoring and API improvements:
HeatingCircuitStatusandHVACActionCategoryenums insrc/bsblan/constants.py, replacing individual status code sets for HVAC actions. These enums provide descriptive names for vendor-specific status codes and their corresponding action categories.get_hvac_action_categoryhelper function to map raw status codes to their action category, simplifying lookups and fallback handling.Codebase cleanup and usage updates:
BSBLAN_HVAC_ACTION_*) and updated all imports and exports insrc/bsblan/__init__.pyand related files to use the new enums and helper function. [1] [2] [3] [4]examples/control.pyto use the new enum-based approach for mapping and displaying HVAC actions, including updating the logic inget_hvac_action_nameandprint_stateto leverage the new helpers and provide both category and specific status name. [1] [2] [3] [4]tests/test_constants.pyto use the new enums and helper function, removing references to the old status code sets.