Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the aioacaia library by splitting previously monolithic helper/decoder logic into focused modules (discovery/encoder/parser/messages), updating AcaiaScale to use typed messages, and adding a new test suite to cover the message framing/parsing behavior.
Changes:
- Refactors BLE discovery, encoding, and notification parsing into new modules (
discovery.py,encoder.py,parser.py,messages.py) and updatesAcaiaScaleaccordingly. - Adds comprehensive tests and fixtures for encoder/parser/scale behaviors.
- Bumps project version to
0.2.0and updates project metadata (including license switch to MIT).
Reviewed changes
Copilot reviewed 16 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Lockfile revision/version update plus extra metadata fields. |
| aioacaia/scale.py | Switches to typed parsed messages; refactors weight/button handling into helpers. |
| aioacaia/parser.py | New notification decoder/parser implementation and sample handler. |
| aioacaia/messages.py | Introduces typed message dataclasses and button enum. |
| aioacaia/encoder.py | New encoder implementation with checksum handling. |
| aioacaia/discovery.py | Extracted BLE discovery + model-name derivation from removed helpers. |
| aioacaia/init.py | Updates package exports to AcaiaScale from scale.py. |
| aioacaia/helpers.py | Removed legacy mixed helper/encoding/discovery implementation. |
| aioacaia/decode.py | Removed legacy decoder implementation in favor of parser.py. |
| tests/test_scale.py | New tests for scale state updates, timer behavior, and queueing commands. |
| tests/test_parser.py | New parser coverage for all decode branches and edge cases. |
| tests/test_encoder.py | New tests for command framing and checksums. |
| tests/fixtures/messages.py | Adds real/crafted frames for parser tests. |
| tests/init.py / tests/fixtures/init.py | Establishes test package structure. |
| pyproject.toml | Version/license/description update; adds pytest/pytest-asyncio config. |
| README.md | Updates headline but leaves usage/docs inconsistent with refactor. |
| run.py | Updates imports to new modules but leaves a now-broken debug call. |
| LICENSE | Replaces AGPLv3 text with MIT license text. |
Comments suppressed due to low confidence (1)
README.md:7
- The README usage snippet is currently not valid Python (missing
:and indentation) and references removed/renamed APIs (aioacaia.helpers.find_acaia_devices,AcaiaScale.create,startStopTimer,resetTimer). Since this PR refactors these modules, the README should be updated to match the new public entrypoints and method names.
Python library to interact with your acaia scales.
# Usage
```python
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 23 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
aioacaia/scale.py:536
- In the AcaiaMessageTooLong recovery path, the inner probe
decode(pending[next_start:])only catchesAcaiaMessageError. If that candidate header producesAcaiaMessageTooShortorAcaiaMessageTooLong, the exception will escapeon_bluetooth_data_received, potentially crashing the Bleak notification callback and breaking further state updates. Treat these framing exceptions as "not a valid resync point" and continue scanning for the next header instead.
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.