-
Notifications
You must be signed in to change notification settings - Fork 2
Add optional parameter filtering #1310
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
…andling - Introduced 'include' parameter to several methods in the BSBLAN class to allow fetching specific parameters. - Added INVALID_INCLUDE_PARAMS_ERROR_MSG for better error reporting when no valid parameters are requested. - Updated State and Info models to support optional fields for partial fetching.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1310 +/- ##
=======================================
Coverage 99.88% 99.88%
=======================================
Files 6 6
Lines 872 886 +14
Branches 115 121 +6
=======================================
+ Hits 871 885 +14
Partials 1 1 ☔ 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 PR adds optional parameter filtering to the BSBLAN client library, enabling users to request only specific fields from the API instead of fetching all data for a section. This improves efficiency and flexibility by allowing partial data fetching.
Changes:
- Added an optional
includeparameter to methods (state(),sensor(),static_values(),info(),hot_water_state(),hot_water_config(),hot_water_schedule()) that allows users to fetch specific parameters - Modified
StateandInfodataclass models to make all fields optional, supporting partial responses - Introduced error handling that raises
BSBLANErrorwhen none of the requested parameters are valid
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/test_include_parameter.py | Comprehensive test suite covering single/multiple parameter fetching, invalid parameters, and default behavior for all affected methods |
| src/bsblan/models.py | Updated State and Info dataclasses to make fields optional with documentation explaining partial fetching support |
| src/bsblan/constants.py | Added INVALID_INCLUDE_PARAMS_ERROR_MSG constant for consistent error messaging |
| src/bsblan/bsblan.py | Implemented parameter filtering in _fetch_section_data() and _fetch_hot_water_data(), updated method signatures and docstrings with examples |
…rove error handling for empty include lists
|



This pull request adds support for partial data fetching in the BSBLAN client by introducing an optional
includeparameter to several methods. This allows users to request only specific fields from the API, improving efficiency and flexibility. The changes also ensure that model classes support partial data by making their fields optional, and introduce error handling for invalid parameter requests.Partial fetching and API enhancements:
Added an optional
includeparameter to methods such asstate,sensor,static_values,info,hot_water_state,hot_water_config, andhot_water_scheduleinbsblan.py, allowing users to fetch only specific parameters instead of all data for a section. This is implemented in both generic and hot water-specific data fetchers, with updated docstrings and usage examples. [1] [2] [3] [4] [5] [6] [7] [8]Updated internal logic in
_fetch_section_dataand_fetch_hot_water_datato filter parameters based on theincludelist and raise a new error if none of the requested parameters are valid for the section. [1] [2]Error handling improvements:
INVALID_INCLUDE_PARAMS_ERROR_MSGinconstants.pyand used it to raise aBSBLANErrorwhen an invalidincludelist is provided. [1] [2] [3]Model changes for partial data:
StateandInfodataclasses inmodels.pyto make all fields optional, supporting partial responses when using theincludeparameter. [1] [2]Imports and minor adjustments:
bsblan.pyto include the new error message constant.