Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
There was a problem hiding this comment.
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_temperatureto 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. |
| # Validate it's a valid float first | ||
| try: | ||
| temp = float(target_temperature) | ||
| except ValueError as err: | ||
| raise BSBLANInvalidParameterError(target_temperature) from err | ||
|
|
There was a problem hiding this comment.
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.
| # 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() |
There was a problem hiding this comment.
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.



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:
_validate_target_temperatureinbsblan.pyto 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:
test_circuit.pyandtest_temperature_validation.pyto expect successful validation (no exception) when min/max temperature parameters are missing, rather than raising an error. [1] [2]