From f2b7d254a75fbcfd8f3dc12a4f5c8d516175969d Mon Sep 17 00:00:00 2001 From: Yellowcooln <12516003+yellowcooln@users.noreply.github.com> Date: Mon, 15 Jun 2026 18:32:12 -0400 Subject: [PATCH] fix: slow sensor polling to 60 seconds --- config.yaml.example | 5 +++-- repeater/sensors/manager.py | 8 ++++---- tests/test_sensors.py | 8 ++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/config.yaml.example b/config.yaml.example index 71c3ee1..d66da5e 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -225,8 +225,9 @@ sensors: # Master switch for sensor subsystem enabled: true - # Poll interval for all configured sensors - poll_interval_seconds: 10.0 + # Poll interval for all configured sensors. Keep modem-backed sensors at 60s + # or slower so their HTTP stats reads don't contend with modem traffic. + poll_interval_seconds: 60.0 # If true, missing Python packages for a sensor may be installed at runtime # using "python -m pip install ...". diff --git a/repeater/sensors/manager.py b/repeater/sensors/manager.py index 367756b..7cb09ee 100644 --- a/repeater/sensors/manager.py +++ b/repeater/sensors/manager.py @@ -131,10 +131,10 @@ class SensorManager: def _poll_loop(self) -> None: """Background thread: poll sensors at configured interval and cache readings.""" section = self.config.get("sensors", {}) - poll_interval = 30.0 + poll_interval = 60.0 if isinstance(section, dict): try: - poll_interval = float(section.get("poll_interval_seconds", 30.0)) + poll_interval = float(section.get("poll_interval_seconds", 60.0)) except (TypeError, ValueError): pass @@ -155,10 +155,10 @@ class SensorManager: def get_summary(self) -> Dict[str, Any]: section = self.config.get("sensors", {}) - poll_interval = 30.0 + poll_interval = 60.0 if isinstance(section, dict): try: - poll_interval = float(section.get("poll_interval_seconds", 30.0)) + poll_interval = float(section.get("poll_interval_seconds", 60.0)) except (TypeError, ValueError): pass diff --git a/tests/test_sensors.py b/tests/test_sensors.py index eb3426a..e00c8c2 100644 --- a/tests/test_sensors.py +++ b/tests/test_sensors.py @@ -108,6 +108,14 @@ def test_sensor_manager_summary_reflects_sensor_config(): assert summary["loaded"] == 1 +def test_sensor_manager_default_poll_interval_is_sixty_seconds(): + config = {"sensors": {"enabled": True, "definitions": []}} + + manager = SensorManager(config, registry=_TestRegistry) + + assert manager.get_summary()["poll_interval_seconds"] == 60.0 + + def test_sensor_manager_loads_and_reads_sensors_without_stopping_on_failure(): config = { "sensors": {