dont read unconfigured sensors

This commit is contained in:
2026-08-22 09:14:13 +02:00
parent 86b6b4f87b
commit e873b49836
3 changed files with 25 additions and 7 deletions
+9 -1
View File
@@ -77,6 +77,8 @@ def load_config(path: Path) -> Config:
if not isinstance(configured_sensors, list) or not configured_sensors:
raise SystemExit("The configuration requires a non-empty sensors list")
collection = raw.get("collection", {})
excluded_prefix = str(collection.get("excluded_name_prefix", "CHANGE_ME"))
sensors: list[Sensor] = []
slugs: set[str] = set()
topics: set[str] = set()
@@ -88,6 +90,8 @@ def load_config(path: Path) -> Config:
raise SystemExit("Every sensor requires a name and topic") from error
if not name or not topic:
raise SystemExit("Sensor names and topics cannot be empty")
if excluded_prefix and name.casefold().startswith(excluded_prefix.casefold()):
continue
slug = safe_slug(name)
if slug in slugs or topic in topics:
raise SystemExit(f"Duplicate sensor slug or topic: {name!r}, {topic!r}")
@@ -95,7 +99,11 @@ def load_config(path: Path) -> Config:
topics.add(topic)
sensors.append(Sensor(name, topic, slug))
collection = raw.get("collection", {})
if not sensors:
raise SystemExit(
f"No active sensors remain after excluding names beginning with {excluded_prefix!r}"
)
storage = raw.get("storage", {})
logging_config = raw.get("logging", {})
interval = int(collection.get("interval_seconds", 600))