Conversation
…dd dual/triple circuit comparisons
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1382 +/- ##
=======================================
Coverage 99.89% 99.89%
=======================================
Files 6 6
Lines 985 997 +12
Branches 137 139 +2
=======================================
+ Hits 984 996 +12
Partials 1 1 ☔ 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 the get_available_circuits detection method in the BSBLAN client to more reliably identify which heating circuits are actually active. It addresses a real-world scenario where BSB-LAN controllers return valid operating mode responses for all three circuits even if only some are physically installed/active, using a secondary status parameter check (8000/8001/8002) that returns value="0" and desc="---" for inactive circuits.
Changes:
- Two-step circuit availability check: operating mode probe + status parameter validation, with fail-safe exclusion if either check fails
- New constants
CIRCUIT_STATUS_PARAMSandINACTIVE_CIRCUIT_MARKERadded toconstants.py - Expanded test scenarios in
test_circuit.pycovering all new code paths; IP address example updated to RFC 5737 TEST-NET address;speed_test.pyrefactored into pluggable benchmark suites
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/bsblan/bsblan.py |
get_available_circuits updated with two-step probe logic using new constants |
src/bsblan/constants.py |
Added CIRCUIT_STATUS_PARAMS and INACTIVE_CIRCUIT_MARKER constants |
tests/test_circuit.py |
New and updated tests covering inactive-by-status, empty-status, status-failure, and all-three-active scenarios |
examples/speed_test.py |
Refactored into pluggable benchmark suites with CLI support; updated example IP |
examples/fetch_param.py |
Updated example IP to RFC 5737 TEST-NET address |
README.md |
Updated example IP to RFC 5737 TEST-NET address |
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_get_available_circuits_status_failure_still_detects( |
There was a problem hiding this comment.
The test function name test_get_available_circuits_status_failure_still_detects is misleading. The name implies that the circuit is still detected when the status request fails, but both the docstring and the assertion (assert circuits == []) confirm the opposite: the circuit is excluded (fail-safe behavior). The function name should be renamed to something like test_get_available_circuits_status_failure_excludes_circuit to accurately describe what the test verifies.
| async def test_get_available_circuits_status_failure_still_detects( | ||
| mock_bsblan_circuit: BSBLAN, | ||
| ) -> None: | ||
| """Test that a circuit is still detected if status request fails. |
There was a problem hiding this comment.
The first line of the docstring, "Test that a circuit is still detected if status request fails," contradicts what the test actually verifies. The test shows that the circuit is excluded (not detected) when the status request fails. This is correctly stated in the second paragraph ("the circuit should be excluded") and confirmed by the assertion circuits == []. The first line should instead read something like "Test that a circuit is excluded (fail-safe) if its status request fails."
| """Test that a circuit is still detected if status request fails. | |
| """Test that a circuit is excluded (fail-safe) if status request fails. |



This pull request enhances the detection logic for available heating circuits in the
BSBLANintegration, making it more robust by introducing a secondary status check and expanding test coverage. The main goal is to ensure that only truly active circuits are reported as available, accounting for real-world controller responses.Key improvements and additions:
Detection logic improvements:
get_available_circuitsmethod now performs a two-step check: it first queries the operating mode parameter, then verifies the circuit's status via a dedicated parameter. Circuits are only considered available if both checks pass, filtering out inactive or unsupported circuits more reliably. [1] [2]New constants for status checks:
CIRCUIT_STATUS_PARAMSandINACTIVE_CIRCUIT_MARKERinconstants.pyto support the new status-based detection logic. [1] [2] [3]Expanded and improved test coverage:
[1] [2] [3] [4] [5] [6]
These changes make the circuit detection more accurate and robust, especially for real-world device behaviors.