Skip to content

Conversation

@liudger
Copy link
Owner

@liudger liudger commented Jan 10, 2026

This pull request adds support for partial data fetching in the BSBLAN client by introducing an optional include parameter 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 include parameter to methods such as state, sensor, static_values, info, hot_water_state, hot_water_config, and hot_water_schedule in bsblan.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_data and _fetch_hot_water_data to filter parameters based on the include list and raise a new error if none of the requested parameters are valid for the section. [1] [2]

Error handling improvements:

  • Introduced a new error message constant INVALID_INCLUDE_PARAMS_ERROR_MSG in constants.py and used it to raise a BSBLANError when an invalid include list is provided. [1] [2] [3]

Model changes for partial data:

  • Modified the State and Info dataclasses in models.py to make all fields optional, supporting partial responses when using the include parameter. [1] [2]

Imports and minor adjustments:

  • Updated imports in bsblan.py to include the new error message constant.

…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.
Copilot AI review requested due to automatic review settings January 10, 2026 18:18
@liudger liudger added enhancement Enhancement of the code, not introducing new features. new-feature New features or options. labels Jan 10, 2026
@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.88%. Comparing base (83c2712) to head (a68da4c).
⚠️ Report is 5 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a 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 include parameter to methods (state(), sensor(), static_values(), info(), hot_water_state(), hot_water_config(), hot_water_schedule()) that allows users to fetch specific parameters
  • Modified State and Info dataclass models to make all fields optional, supporting partial responses
  • Introduced error handling that raises BSBLANError when 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

@sonarqubecloud
Copy link

@liudger liudger merged commit bddbd6e into main Jan 10, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement of the code, not introducing new features. new-feature New features or options.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants