edge 22 min read

Edge Configuration Reference

A complete reference for every section and key in config.toml, with annotated examples.

Published Jun 2, 2026

Introduction

The config.toml file is the single source of truth for how your Pyvorin Edge Agent behaves. Every sensor, every privacy rule, every cloud endpoint, and every logging preference is declared here. This article is a comprehensive reference. We explain every top-level section, every key, every valid value, and the defaults that apply when a key is omitted. We finish with a full, heavily annotated example config that you can copy and adapt.

Configuration Basics

Pyvorin Edge uses TOML (Tom's Obvious Minimal Language) because it is human-readable, supports comments, and maps cleanly to Python dictionaries. The Config class in pyv_edge_agent/config.py parses the file, substitutes environment variables, merges your values over built-in defaults, and validates required sections.

Environment Variable Substitution

Any value can reference an environment variable using ${VAR} or ${VAR:-default} syntax:


[cloud]
endpoint = "${CLOUD_ENDPOINT}"
api_key = "${CLOUD_API_KEY:-}"  # empty string if unset
  

This is evaluated at load time, not at runtime, so changes to environment variables after startup require a config reload.

Validation

Calling Config.validate() checks for:

  • Presence of required sections: sensors, windows, rules, policies, cloud, privacy.
  • That sensors.devices is a list.
  • That windows.default_size is an integer.
  • That cloud.endpoint is non-empty when cloud.enabled is true.

Section: [sensors]

Defines how often the agent polls devices and what devices exist.

Key Type Default Description
poll_interval_seconds float 5.0 Seconds between collection cycles. Minimum practical value is 1.0; values below this increase CPU usage without meaningful benefit for most sensors.
devices list of tables [] Each table defines one sensor or ingest source. At least one device is required for the agent to do useful work.

Device Table Keys

Each [[sensors.devices]] entry configures one adapter instance.

Key Type Required Description
name string Yes Unique identifier for the device. Used as the key in buffers and adapters.
ingest_type string No One of simulator, mqtt, http, file. Default is simulator.
sensor_type string No For simulators: temperature, humidity, co2, voc, pressure, leak, occupancy, vibration, current, voltage. Default temperature.
unit string No Display unit (e.g., °C, %, ppm, V).
min_value float No Minimum clamp value for simulator. Default 0.0.
max_value float No Maximum clamp value for simulator. Default 100.0.
noise_std float No Standard deviation of Gaussian noise added to simulator baseline. Default 0.0 (perfect readings).
baseline float No Central value around which the simulator generates readings. Default 0.0.

Example: Three Simulated Sensors


[sensors]
poll_interval_seconds = 5.0

[[sensors.devices]]
name = "office_temp"
ingest_type = "simulator"
sensor_type = "temperature"
unit = "°C"
min_value = 10.0
max_value = 40.0
noise_std = 0.5
baseline = 22.0

[[sensors.devices]]
name = "office_humidity"
ingest_type = "simulator"
sensor_type = "humidity"
unit = "%"
min_value = 0.0
max_value = 100.0
noise_std = 2.0
baseline = 45.0

[[sensors.devices]]
name = "server_room_leak"
ingest_type = "simulator"
sensor_type = "leak"
unit = "bool"
min_value = 0.0
max_value = 1.0
noise_std = 0.0
baseline = 0.0
  

Section: [windows]

Configures ring buffers that hold recent readings in memory for fast rule evaluation.

Key Type Default Description
default_size int 100 Number of items each ring buffer can hold before overwriting old values.
default_dtype string "float" Storage type hint: float, int, dict, or sensor_reading.

Section: [rules]

Declares event rules that trigger when conditions are met. Rules are evaluated during each run_once() cycle for every reading.

Key Type Default Description
evaluation_interval_seconds float 10.0 Reserved for future scheduler use; currently rules are evaluated per-reading.
items list of tables [] Each rule table defines a condition and action.

Rule Item Keys

Key Type Required Description
name string Yes Unique rule name for logging and deduplication.
condition_expr string No Python expression evaluated against ctx (the reading). Only a safe subset of builtins is available.
severity string No info, warning, or critical. Default info.
cooldown_seconds float No Minimum seconds between repeated firings of this rule. Default 0.0.

Example: Temperature and Humidity Rules


[rules]
evaluation_interval_seconds = 10.0

[[rules.items]]
name = "office_overheat"
condition_expr = "ctx.value > 28.0"
severity = "warning"
cooldown_seconds = 300.0

[[rules.items]]
name = "humidity_too_high"
condition_expr = "ctx.value > 70.0"
severity = "critical"
cooldown_seconds = 60.0
  

Section: [policies]

Defines high-level policy defaults. Note that fine-grained privacy rules live in the [privacy] section instead.

Key Type Default Description
default_action string "allow" Fallback action for policy evaluation: allow or drop.
rules list [] Reserved for future policy rule expansion.

Section: [cloud]

Controls outbound cloud synchronisation. When disabled, data stays entirely on the gateway.

Key Type Default Description
enabled bool false Master switch for cloud sync.
endpoint string "" HTTPS URL that accepts POST batches. Required if enabled.
api_key string "" Bearer token sent in the Authorization header.
batch_size int 100 Target number of items per upload batch.
flush_interval_seconds float 60.0 Maximum seconds between upload attempts.
db_path string "sync_queue.db" Path to the persistent queue SQLite database.

Example: Enabled Cloud Sync


[cloud]
enabled = true
endpoint = "https://api.pyvorin.com/v1/ingest"
api_key = "${PYV_API_KEY}"
batch_size = 50
flush_interval_seconds = 30.0
db_path = "/home/pi/pyvorin-edge/data/sync_queue.db"
  

Section: [privacy]

The privacy firewall. Every reading is evaluated against these rules before storage and cloud sync.

Key Type Default Description
enabled bool true Master switch. If false, all readings pass through untouched.
default_action string "allow" Action for readings that do not match any rule.
rules list of tables [] Privacy rules evaluated in order.

Privacy Rule Keys

Key Type Required Description
sensor_pattern string Yes Unix glob pattern matching sensor names.
action string Yes drop, mask, or hash.
replacement string No Reserved for future custom replacement strings.

Example: Privacy Rules


[privacy]
enabled = true
default_action = "allow"

[[privacy.rules]]
sensor_pattern = "camera_*"
action = "drop"

[[privacy.rules]]
sensor_pattern = "badge_*"
action = "hash"

[[privacy.rules]]
sensor_pattern = "internal_*"
action = "mask"
  

Section: [logging]

Controls how the agent writes diagnostic output.

Key Type Default Description
level string "INFO" One of DEBUG, INFO, WARNING, ERROR, CRITICAL.
format string "json" json for structured logs, text for human-readable lines.

Section: [health]

Configures the built-in HTTP health server.

Key Type Default Description
enabled bool true If false, the health server does not start.
port int 8080 TCP port to bind. Must be available and, if binding below 1024, requires root (not recommended).

Section: [store] (Optional)

Controls the SQLite evidence store path.

Key Type Default Description
path string "edge_store.db" Path to the SQLite database file.

Complete Annotated Example Config


# /home/pi/pyvorin-edge/config.toml
# Pyvorin Edge Agent Configuration
# ================================

# [sensors] defines what data sources the agent monitors and how often.
[sensors]
poll_interval_seconds = 5.0

# Device 1: Simulated office temperature sensor
[[sensors.devices]]
name = "office_temp"
ingest_type = "simulator"
sensor_type = "temperature"
unit = "°C"
min_value = 10.0
max_value = 40.0
noise_std = 0.5
baseline = 22.0

# Device 2: Simulated office humidity sensor
[[sensors.devices]]
name = "office_humidity"
ingest_type = "simulator"
sensor_type = "humidity"
unit = "%"
min_value = 0.0
max_value = 100.0
noise_std = 2.0
baseline = 45.0

# Device 3: Simulated leak detector (boolean)
[[sensors.devices]]
name = "server_room_leak"
ingest_type = "simulator"
sensor_type = "leak"
unit = "bool"
min_value = 0.0
max_value = 1.0
noise_std = 0.0
baseline = 0.0

# [windows] configures in-memory ring buffers for fast access.
[windows]
default_size = 200          # Keep last 200 readings per device
default_dtype = "float"     # Storage type hint

# [rules] defines event conditions that trigger alerts.
[rules]
evaluation_interval_seconds = 10.0

[[rules.items]]
name = "office_overheat"
condition_expr = "ctx.value > 28.0"
severity = "warning"
cooldown_seconds = 300.0

[[rules.items]]
name = "server_room_leak_detected"
condition_expr = "ctx.value >= 0.5"
severity = "critical"
cooldown_seconds = 60.0

# [policies] sets high-level defaults.
[policies]
default_action = "allow"
rules = []

# [cloud] controls outbound synchronisation.
[cloud]
enabled = false             # Set to true and configure endpoint to enable
endpoint = ""
api_key = ""
batch_size = 100
flush_interval_seconds = 60.0

# [privacy] filters sensitive data before storage or upload.
[privacy]
enabled = true
default_action = "allow"

[[privacy.rules]]
sensor_pattern = "camera_*"
action = "drop"

[[privacy.rules]]
sensor_pattern = "badge_*"
action = "hash"

# [logging] controls diagnostic output.
[logging]
level = "INFO"
format = "json"             # Use "text" for human-readable output during debugging

# [health] exposes /health and /metrics over HTTP.
[health]
port = 8080
enabled = true

# [store] sets the SQLite evidence database path.
[store]
path = "/home/pi/pyvorin-edge/data/edge_store.db"
  

Config Reload at Runtime

The EdgeAgent supports reloading configuration without restarting the process, but be aware that reload_config() only updates the _config object. Some components (adapters, buffers, logging) are only created during _init_components(), which runs at startup. For deep changes (adding sensors, changing ports), a full restart is recommended.


# Programmatic reload
agent.reload_config()
  

Summary

The config.toml file controls every aspect of Pyvorin Edge behaviour. Use the tables above as a quick reference, copy the annotated example as a starting template, and remember that absolute paths and environment variable substitution make your configuration portable and secure.