-
Notifications
You must be signed in to change notification settings - Fork 3
Skip temperature range validation for devices without min/max params #1436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -332,19 +332,21 @@ async def test_thermostat_circuit2_invalid_temperature( | |
| async def test_thermostat_circuit2_no_temp_range( | ||
| mock_bsblan_circuit: BSBLAN, | ||
| ) -> None: | ||
| """Test error when HC2 temp range not available.""" | ||
| """Test thermostat passes through when HC2 temp range not available.""" | ||
| # Set HC2 as initialized but with None range | ||
| mock_bsblan_circuit._circuit_temp_ranges[2] = { | ||
| "min": None, | ||
| "max": None, | ||
| } | ||
| mock_bsblan_circuit._circuit_temp_initialized.add(2) | ||
|
|
||
| with pytest.raises(BSBLANError, match="Temperature range"): | ||
| await mock_bsblan_circuit.thermostat( | ||
| target_temperature="20", | ||
| circuit=2, | ||
| ) | ||
| # 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() | ||
|
Comment on lines
+343
to
+349
|
||
|
|
||
|
|
||
| # --- Validation tests --- | ||
|
|
||
There was a problem hiding this comment.
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.