Conversation
…issing permissions
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #587 +/- ##
=======================================
Coverage 99.26% 99.26%
=======================================
Files 9 9
Lines 679 682 +3
Branches 62 63 +1
=======================================
+ Hits 674 677 +3
Misses 2 2
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where older firmware (API 2.1.0) in battery 'zero' mode was incorrectly treated as 'standby' due to the missing permissions field. The fix distinguishes between a missing permissions field (older firmware) and an explicitly empty permissions array (intentional standby mode).
Key changes:
- Made the
permissionsfield nullable to distinguish between missing and empty - Added backwards compatibility logic to preserve 'zero' mode when permissions field is absent
- Added test fixtures for both API versions (2.1.0 without permissions, 2.2.0 with permissions)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| homewizard_energy/models.py | Changed permissions field to nullable, updated deserialization logic, and added backwards compatibility in post_deserialize to keep mode as ZERO when permissions is None |
| tests/v2/test_v2_batteries.py | Updated test parametrization to test both API 2.1.0 and 2.2.0 fixtures for HWE-P1 model |
| tests/v2/fixtures/HWE-P1/batteries_2_1_0.json | Added fixture for API 2.1.0 (older firmware) with mode="zero" but no permissions field |
| tests/v2/fixtures/HWE-P1/batteries_2_2_0.json | Added fixture for API 2.2.0 (newer firmware) with mode="zero" and permissions field |
| tests/v2/snapshots/test_v2_batteries.ambr | Updated snapshots to reflect expected behavior for both API versions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Before:
After: