diff --git a/custom_components/simple_pid_controller/number.py b/custom_components/simple_pid_controller/number.py index 2660add..b8cabeb 100644 --- a/custom_components/simple_pid_controller/number.py +++ b/custom_components/simple_pid_controller/number.py @@ -67,7 +67,7 @@ "key": "sample_time", "unit": "s", "min": 0.01, - "max": 600.0, + "max": 6000.0, "step": 0.01, "default": 10.0, "entity_category": EntityCategory.CONFIG, diff --git a/tests/test_number.py b/tests/test_number.py index 91c1328..5d30d1b 100644 --- a/tests/test_number.py +++ b/tests/test_number.py @@ -222,3 +222,15 @@ async def test_control_number_step_defaults(hass, config_entry, desc): """Test that ControlParameterNumber falls back to DEFAULT_STEPS when no option is set.""" num = ControlParameterNumber(hass, config_entry, desc) assert num._attr_native_step == DEFAULT_STEPS[desc["key"]] + + +@pytest.mark.usefixtures("setup_integration") +async def test_sample_time_allows_long_intervals(hass, config_entry): + """Sample time must allow long intervals for slow systems (issue #155).""" + desc = next(d for d in PID_NUMBER_ENTITIES if d["key"] == "sample_time") + assert desc["max"] >= 6000.0 + + num = PIDParameterNumber(hass, config_entry, desc) + num.async_write_ha_state = lambda: None + await num.async_set_native_value(6000.0) + assert num.native_value == 6000.0 diff --git a/tests/test_sensor.py b/tests/test_sensor.py index d7c928a..a0e6ec7 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -420,4 +420,9 @@ async def test_update_pid_adjusts_update_interval(hass, config_entry, monkeypatc await coordinator.update_method() assert coordinator.update_interval == timedelta(seconds=sample_time) + # Long sample times for slow (inertial) systems, see issue #155 + sample_time = 6000 + await coordinator.update_method() + assert coordinator.update_interval == timedelta(seconds=sample_time) + await async_unload_entry(hass, config_entry)