scripts/sample_data.sql and demonstrate common flow patterns.
Temperature and humidity to database
Stores sensor readings in the database for historical tracking.- Subscribes to the
sensors/aht10topic - Validates that incoming messages have
temperatureandhumidityfields (both floats) - Stores each field as a separate record in the
datatable - No HTTP endpoint required (action is
STORE_DB)
scripts/sample_data.sql:11-20
Generic temperature/humidity database flow
Similar to the AHT10 example but using a more generic topic pattern.scripts/sample_data.sql:32-41
HTTP endpoint forwarding
Forwards sensor data to an external HTTP service instead of storing in the database.- Subscribes to
sensors/aht10/http - Validates the same temperature/humidity schema
- POSTs the entire payload as JSON to the configured endpoint
- The gateway increments
last_msg_idbut does NOT store data in the database
host.docker.internal is used when the gateway runs in Docker and needs to reach services on the host machine.
Source: scripts/sample_data.sql:53-62
Flow processing behavior
All flows share these common behaviors implemented insrc/processor.py:79-135:
- Payload validation - The
validate_payload()function checks that all fields inpayload_schemaexist and have the correct type - Message ID increment - Every processed message increments the flow’s
last_msg_idcounter - Database transaction - Flow updates and data storage happen atomically with row-level locking (
with_for_update()) - Error handling - Invalid payloads raise
ValueError, HTTP errors are logged but don’t fail the transaction