Cultivar Types

Shared type definitions for the Grove5 Cultivar appliance.

Grove5 — Open source software, honest hardware.


What it is

The single source of truth for data shapes shared across the Cultivar stack. TypeScript types for the Svelte UI, Pydantic models for the Python daemon — kept in sync manually. When a type changes, update both.

cultivar-types/
├── typescript/
│   └── types.ts          # source of truth — TypeScript
└── python/
    └── cultivar_types.py # Pydantic mirror — Python

TypeScript types

Used by cultivar-ui. Key types:

Type Description
CultivarState Full appliance state — environment, chambers, hardware, recipe
Chamber One chamber with slots, bags, and environment
ChamberEnvironment Live temp, humidity, CO2, CO2e, VOC
EnvironmentReading One timestamped environment reading
EnvPayload Full processed sensor payload from daemon
GasSweepPoint Single point in 10-step gas sweep
ZoneScores Z1/Z2/Z3 zone aggregates
SweepBaseline Per-chamber baseline resistance fingerprint
SensorHealth Cross-validation between BME690 and SCD43
EnvAnomaly Detected anomaly with severity and contaminant hint
WsMessage WebSocket message envelope
BagState Bag identity, vision, and stage
Run Cultivation run lifecycle

Installation

# In cultivar-ui — symlink or copy
ln -s ../cultivar-types/typescript/types.ts src/lib/types.ts

Python types (Pydantic)

Used by cultivar-daemon. Key models:

Model Description
STM32Payload Raw validated payload from STM32 serial
EnvPayload Processed payload sent to UI
GasSweepPoint Single sweep point with raw/corr/norm resistance
SweepBaseline Baseline resistance fingerprint
SensorHealth Cross-validation state
EnvAnomaly Detected anomaly
WsMessage WebSocket envelope
Run Cultivation run
Co2eCalibrationSample Training data for CO2e model

Installation

# In cultivar-daemon — symlink
ln -s ../cultivar-types/python/cultivar_types.py cultivar_types.py

# Or install as package (when published to Gitea registry)
pip install cultivar-types

Key data contracts

STM32 → Daemon (Serial JSON)

{
  "chamber_id": "colonization",
  "ts": 300000,
  "ambient": {"temp_c": 23.1, "humidity_pct": 45.2, "pressure_hpa": 929.4, "valid": true},
  "co2": null,
  "health": {"scd43_present": false, "temp_ok": true, "humidity_ok": true},
  "baseline": {"established": false, "samples_collected": 2},
  "sweep": [
    {"heater_temp_c": 200, "heater_dur_ms": 150, "zone": 1, "resistance": 85000000, "heater_stable": true, "valid": true},
    "..."
  ]
}

Daemon → UI (WebSocket)

{
  "type": "payload",
  "chamber_id": "fruiting",
  "ts": 1714234567,
  "data": {
    "ambient": {"temp_c": 18.8, "humidity_pct": 92.0, "pressure_hpa": 929.4, "valid": true},
    "co2": {"ppm": 820, "valid": true},
    "co2e_ppm": null,
    "co2e_confidence": "uncalibrated",
    "voc_ppb": 44.0,
    "zone_scores": {"Z1": 0.94, "Z2": 0.87, "Z3": 1.02},
    "baseline": {"established": true, "n_samples": 6},
    "health": {"scd43_present": true, "temp_delta": 0.66, "humidity_delta": 1.88, "temp_ok": true, "humidity_ok": true},
    "anomalies": [],
    "sweep": ["...10 points..."]
  }
}

Versioning

Types are versioned with the repo. Breaking changes increment the minor version. Both cultivar-daemon and cultivar-ui pin to a specific commit via git submodule.

License

MIT — Grove5

S
Description
Shared typescript and python types for various Cultivar packages.
Readme MIT
62 KiB
0 Stars 1 Watchers 0 Forks
Languages
Python 59.6%
TypeScript 40.4%