Skip to content

Fix detecting heating circuits#1382

Merged
liudger merged 4 commits intomainfrom
fix-detecting-heating-circuits
Mar 2, 2026
Merged

Fix detecting heating circuits#1382
liudger merged 4 commits intomainfrom
fix-detecting-heating-circuits

Conversation

@liudger
Copy link
Owner

@liudger liudger commented Mar 2, 2026

This pull request enhances the detection logic for available heating circuits in the BSBLAN integration, 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:

  • The get_available_circuits method 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:

  • Introduced CIRCUIT_STATUS_PARAMS and INACTIVE_CIRCUIT_MARKER in constants.py to support the new status-based detection logic. [1] [2] [3]

Expanded and improved test coverage:

  • Added comprehensive tests for various scenarios, including:
    • All circuits active
    • Only some circuits active
    • Circuits marked inactive by status
    • Circuits with empty status responses (unsupported)
    • Status request failures (fail-safe behavior)
      [1] [2] [3] [4] [5] [6]

These changes make the circuit detection more accurate and robust, especially for real-world device behaviors.

Copilot AI review requested due to automatic review settings March 2, 2026 12:58
@liudger liudger added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Mar 2, 2026
@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.89%. Comparing base (fe01a19) to head (1839ab0).
⚠️ Report is 4 commits behind head on main.

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.
📢 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.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 2, 2026

@liudger liudger merged commit afffda9 into main Mar 2, 2026
17 checks passed
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 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_PARAMS and INACTIVE_CIRCUIT_MARKER added to constants.py
  • Expanded test scenarios in test_circuit.py covering all new code paths; IP address example updated to RFC 5737 TEST-NET address; speed_test.py refactored 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(
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot generated this review using guidance from repository custom instructions.
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.
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Suggested change
"""Test that a circuit is still detected if status request fails.
"""Test that a circuit is excluded (fail-safe) if status request fails.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants