Skip to content

Skip temperature range validation for devices without min/max params#1436

Merged
liudger merged 1 commit intomainfrom
fix/skip-temp-range-validation-when-unavailable
Apr 11, 2026
Merged

Skip temperature range validation for devices without min/max params#1436
liudger merged 1 commit intomainfrom
fix/skip-temp-range-validation-when-unavailable

Conversation

@liudger
Copy link
Copy Markdown
Owner

@liudger liudger commented Apr 11, 2026

This pull request updates the target temperature validation logic to better handle devices that do not provide minimum or maximum temperature parameters. Instead of raising an error when min/max are unavailable, the code now only checks that the input is a valid float. The relevant tests have also been updated to reflect this new behavior.

Validation logic improvements:

  • Updated _validate_target_temperature in bsblan.py to skip min/max range validation if the device does not provide these parameters, only ensuring the value is a valid float. [1] [2]

Test updates:

  • Modified tests in test_circuit.py and test_temperature_validation.py to expect successful validation (no exception) when min/max temperature parameters are missing, rather than raising an error. [1] [2]

Previously _validate_target_temperature raised BSBLANError when the device
did not provide min/max temperature parameters. Now it validates the value
is a valid float and skips range checking when min/max are unavailable,
allowing the temperature to pass through to the device.
@liudger liudger added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Apr 11, 2026
Copilot AI review requested due to automatic review settings April 11, 2026 08:59
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1436      +/-   ##
==========================================
- Coverage   99.89%   99.89%   -0.01%     
==========================================
  Files           6        6              
  Lines         990      988       -2     
  Branches      139      138       -1     
==========================================
- Hits          989      987       -2     
  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
Copy Markdown

@liudger liudger merged commit b3ee7c4 into main Apr 11, 2026
17 checks passed
@liudger liudger deleted the fix/skip-temp-range-validation-when-unavailable branch April 11, 2026 09:01
Copy link
Copy Markdown
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

Updates target temperature validation to support devices that don’t expose min/max temperature parameters, allowing thermostat target temperatures to be set as long as the input is numeric.

Changes:

  • Updated _validate_target_temperature to skip bounds checking when min/max are unavailable, while still validating numeric input.
  • Updated circuit thermostat test to no longer expect an exception when HC2 min/max are None.
  • Updated temperature validation test to reflect the new “no min/max available” behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/bsblan/bsblan.py Adjusts target temperature validation to avoid raising when min/max aren’t provided by the device.
tests/test_temperature_validation.py Updates expectation for validation when min/max range cannot be populated.
tests/test_circuit.py Updates thermostat behavior test for HC2 when min/max are missing.

Comment on lines +1215 to +1220
# Validate it's a valid float first
try:
temp = float(target_temperature)
except ValueError as err:
raise BSBLANInvalidParameterError(target_temperature) from err

Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

float() will accept non-finite values like 'nan', 'inf', or '-inf'. With the new early-return when min/max are unavailable, those values will now pass validation and be sent to the device. Consider explicitly rejecting non-finite floats (e.g., via a finite check) so only real temperatures are accepted even when range bounds are missing.

Copilot uses AI. Check for mistakes.
Comment on lines +343 to +349
# Should pass through without range validation when min/max are None
mock_bsblan_circuit._request = AsyncMock(return_value={"status": "success"})
await mock_bsblan_circuit.thermostat(
target_temperature="20",
circuit=2,
)
mock_bsblan_circuit._request.assert_awaited_once()
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

This test now only asserts _request was awaited once, but it doesn't verify the request payload (e.g., base_path and data) for circuit=2. Adding an assertion on the awaited arguments would ensure the thermostat call still sends the correct parameter ID/value when range validation is skipped.

Copilot generated this review using guidance from repository custom instructions.
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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