mirror of
https://github.com/pyMC-dev/pyMC_Repeater.git
synced 2026-06-26 04:51:34 +02:00
fix: slow sensor polling to 60 seconds
This commit is contained in:
+3
-2
@@ -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 ...".
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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": {
|
||||
|
||||
Reference in New Issue
Block a user