feat: alarm descriptions and proportional pressure mode fix#18
Merged
Conversation
Mode 1 (PROPORTIONAL_PRESSURE) was missing from _MODE_BYTE_MAP, causing it to default to 0x02 (Constant Speed). The correct mode_byte is 0x01, matching the entry in _MODE_SUFFIX_MAP. Without this fix, setting Proportional Pressure mode silently sends a Constant Speed command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- device_info.py: Populate alarm_description/warning_description fields in AlarmInfo using ERROR_CODES lookup from constants.py - formatters.py: Show per-code descriptions in alarm panel using ERROR_CODES lookup, support active_alarms/active_warnings lists - Fix Proportional Pressure mode_byte (1: 0x01) in _MODE_BYTE_MAP Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves how alarms/warnings and proportional-pressure mode are represented and displayed, supporting the 0.4.0 release by making alarm output more informative and fixing a control-mode mapping.
Changes:
- Add
ERROR_CODESlookups to populate alarm/warning descriptions from active code lists. - Fix
ControlServicemode-byte mapping forPROPORTIONAL_PRESSURE(mode value1). - Update CLI alarm panel formatting to render multiple active alarm/warning codes with descriptions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/alpha_hwr/services/device_info.py |
Builds alarm_description / warning_description strings from active alarm/warning codes using ERROR_CODES. |
src/alpha_hwr/services/control.py |
Adds missing _MODE_BYTE_MAP entry for proportional pressure (value 1). |
src/alpha_hwr/cli/output/formatters.py |
Formats alarm panels using active_alarms / active_warnings with ERROR_CODES descriptions. |
- Fix ruff format violation in device_info.py - Add assertions for alarm_description/warning_description in test_read_alarms - Add test_read_alarms_unknown_code_fallback for unmapped error codes
- Update version in pyproject.toml, __init__.py, mkdocs.yml, docs/index.md, .bumpversion.cfg - Add CHANGELOG.md entry for 0.5.0 release
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.
Summary
Two bug fixes targeting the 0.4.0 release:
Alarm/warning descriptions from ERROR_CODES (
device_info.py,formatters.py)Previously
read_alarms()returned only raw numeric codes inactive_alarms/active_warnings. Nowalarm_descriptionandwarning_descriptionare populated by looking up each active code inERROR_CODES, joining multiple codes as a comma-separated string. Unknown codes fall back to"Unknown (<code>)".The CLI alarm panel (
format_alarm_panel) was updated in parallel to render each active alarm/warning code with its description, replacing the previous single-code display.Proportional Pressure mode byte (
control.py)_MODE_BYTE_MAPwas missing the entry forPROPORTIONAL_PRESSURE(value1, byte0x01). Setting the pump to proportional pressure mode would previously raise aKeyError.Changes
src/alpha_hwr/services/device_info.py– populatealarm_description/warning_descriptionfromERROR_CODESinread_alarms()src/alpha_hwr/services/control.py– add missing1: 0x01entry to_MODE_BYTE_MAPsrc/alpha_hwr/cli/output/formatters.py– render multiple active alarm/warning codes with descriptions in the alarm paneltests/unit/core/test_device_info_service.py– assert description fields and add unknown-code fallback test