Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/simple_pid_controller/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions tests/test_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading