Data Model

Tzone RS485 climate probe mounted in the south zone, one of six sensors feeding the data pipeline

The data pipeline: ESP32 sensors publish state changes over aioesphomeapi (encrypted, port 6053). The ingestor maps 172 entities to 128 database columns and writes them to TimescaleDB in near real-time. Twelve periodic tasks enrich the data: outdoor weather from Open-Meteo, energy from a Shelly EM50, forecasts, alert monitoring, and band-driven setpoint dispatch. Everything runs locally on a single VM.

TimescaleDB (PostgreSQL 16 + hypertables) stores every measurement, event, plan, and observation.

Public Sample Dataset

For launch readers who want to inspect the receipts without database access:

7-day climate sample CSV190,519 bytes; generated 2026-05-02 18:09 MDT

5-minute indoor climate, outdoor weather, hydro, soil, water, and solar fields. SHA-256: a6a9321bb55ebd48f872bc8d9bba5a182fae298534e33d358ffa291fa608a8a3.

30-day plan outcome sample CSV174,667 bytes; generated 2026-05-02 18:09 MDT

Plan scorecards, stress hours, resource cost, hypotheses, expected outcomes, and actual outcomes. SHA-256: eba09057e5c70ba8bcbe68200d4213d3315496e207fd207f848217735f0404ea.

Dataset notes467 bytes

Timestamp, timezone, and scrub boundary for the export.

The export omits local IPs, device IDs, trigger UUIDs, alert channels, hostnames, and raw sensor entity names.

Core Tables

TableTypeRowsWrite Pattern
climateHypertable221K+~2 min batch (ESP32 sensors + outdoor merge)
equipment_stateHypertable39K+Event-driven (relay changes)
energyHypertable516K+Every 5 min (Shelly EM50)
setpoint_changesHypertableEvent-driven (ESP32 reports + plan pushes)
setpoint_planHypertable144+3× daily (AI planner waypoints)
weather_forecastHypertable28K+Hourly (Open-Meteo, 16-day, 27 columns)
daily_summaryRegular236Nightly snapshot
diagnosticsHypertable~60s (ESP32 health)

Setpoint & Tunable Delivery

Iris (our OpenClaw AI agent) writes future intent to setpoint_plan, not directly to relays. The active value for each parameter resolves through v_active_plan; the ingestor dispatcher pushes changed values to ESPHome and the ESP32’s reported values land in setpoint_changes. Firmware cfg_* readbacks land in setpoint_snapshot, which is the ground-truth table for whether bounded tunables actually reached the controller.

ObjectRole
setpoint_planAI-authored waypoints: timestamp, parameter, value, plan id, source, and reason.
v_active_planLatest active plan value per parameter after supersession.
setpoint_changesEvent log of pushed and ESP32-reported setpoint values; drives fn_setpoint_at().
setpoint_snapshotESP32 configured-value readbacks from cfg_* sensors.
plan_delivery_logTrigger id, planner instance, delivery status, and resulting plan id for MCP audit.
/setpointsHTTP fallback that combines active plan values, crop-band functions, and outdoor readings for ESP32 pull.

See AI-Writable Tunables for the bounded tunable taxonomy and relay impact.

Crop & Operations Tables

TablePurposeStatus
cropsActive plantings with position, zone, stage3 records
crop_eventsStage changes, transplants, harvestsEmpty (awaiting operator input)
observationsPest scouting, visual notes, camera assessmentsEmpty
treatmentsSpray/biological applications with PHI/REIEmpty
harvestsYield recordsEmpty
plan_journalPer-plan hypothesis, outcome, score12 entries
planner_lessonsValidated patterns from planning cycles75 lessons

Key Views (56 total)

ViewPurpose
v_greenhouse_nowSingle-row snapshot: all zones, hydro, costs, health
v_equipment_nowCurrent state of all 33 equipment items
v_cost_todayReal-time electric + gas + water cost
v_active_planResolves plan supersession (latest waypoint per parameter)
v_stress_hours_todayHours above/below target bands per day
v_disease_riskBotrytis + condensation risk from RH/temp/VPD
v_mister_effectivenessVPD drop per pulse by zone, with outdoor context
v_forecast_vs_actualHourly forecast accountability (bias detection)
v_indoor_outdoor_correlationThermal gain coefficient
v_state_durationsTime-in-state per day
v_estimated_plant_dliCorrected DLI estimate (sensor × correction factor)

Key Functions

FunctionReturns
fn_equipment_health()0–100 composite health score
fn_stress_summary(date)Human-readable stress text
fn_system_health()4-component health: sensors, alerts, equipment, controller
fn_compliance_pct()% time within target bands
fn_forecast_dli()Predicted natural DLI from forecast radiation
fn_forecast_correction()Rolling 7-day bias per forecast parameter

Compression & Retention

TableCompressionRetention
climate7 days365 days
energy7 days365 days
diagnostics7 days180 days
esp32_logs30 days

Where to Go Next

  • Planning Loop — how the AI planner reads this data and writes setpoints
  • Operations — live health checks and data freshness monitoring
  • Lessons Learned — what the data has taught us about greenhouse control