diff --git a/HOWTO.md b/HOWTO.md index c0016a2..d1505a6 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -359,6 +359,15 @@ friendly names shown by Zigbee2MQTT: nano config.yaml ``` +Sensor entries whose `name` begins with `CHANGE_ME` are placeholders and are +excluded from MQTT polling, RRD creation, graphs, and the HTML dashboard. Rename +an entry when its physical sensor is ready. The marker is configurable: + +```yaml +collection: + excluded_name_prefix: CHANGE_ME +``` + By default, the databases are written to `/var/lib/rrd` and the generated graphs to `/var/www/html/sensors`. Create those directories and grant the user running the collector ownership: diff --git a/config.yaml b/config.yaml index 05ddb69..b9fcac6 100644 --- a/config.yaml +++ b/config.yaml @@ -7,6 +7,7 @@ mqtt: collection: interval_seconds: 600 mqtt_timeout_seconds: 15 + excluded_name_prefix: CHANGE_ME storage: data_directory: /var/lib/rrd @@ -19,15 +20,15 @@ logging: sensors: - name: Server room topic: zigbee2mqtt/sensor_server_room - - name: Sensor 2 - topic: zigbee2mqtt/CHANGE_ME_SENSOR_2 - - name: Sensor 3 + - name: CHANGE_ME Sensor 2 + topic: zigbee2mqtt/sensor_supply_room + - name: CHANGE_ME Sensor 3 topic: zigbee2mqtt/CHANGE_ME_SENSOR_3 - - name: Sensor 4 + - name: CHANGE_ME Sensor 4 topic: zigbee2mqtt/CHANGE_ME_SENSOR_4 - - name: Sensor 5 + - name: CHANGE_ME Sensor 5 topic: zigbee2mqtt/CHANGE_ME_SENSOR_5 - - name: Sensor 6 + - name: CHANGE_ME Sensor 6 topic: zigbee2mqtt/CHANGE_ME_SENSOR_6 rrd: diff --git a/read_temperature.py b/read_temperature.py index b5b4b59..5cdad5d 100644 --- a/read_temperature.py +++ b/read_temperature.py @@ -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))