Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/diarpicu2022-commits/backend-AgroPulse/llms.txt

Use this file to discover all available pages before exploring further.

AgroPulse lets you define automation rules that watch a specific sensor type and activate a physical actuator whenever a condition is met. When the greenhouse monitor processes an incoming reading, it evaluates all active rules and dispatches commands to any matching actuators — no polling or custom firmware logic required.

The Rule model

FieldTypeDescription
namestringHuman-readable label for the rule
sensorstringSensor type string to monitor (e.g. SOIL_MOISTURE)
conditionstringComparison operator: gt, lt, eq, gte, or lte
conditionValuenumberThreshold value for the comparison
actionstringDescription of what happens when the condition is met
actuatorIdintegerID of the actuator to activate
activebooleanWhether the rule is currently enabled

The Actuator model

Actuators represent the physical output devices controlled by rules. Supported actuator types (stored as plain strings) include:
  • PUMP — water pump or irrigation valve
  • FAN — ventilation or cooling fan
  • HEATER — heating element
  • LIGHT — grow light or supplemental lighting
  • VALVE — solenoid valve
Additional fields: gpioPin (GPIO number on the ESP32), activeLow (set true for HW-383-style relay boards where LOW signal activates the relay), deviceSource (ESP32 identifier), and status (ON, OFF, or AUTO).

Setup workflow

1

Create the actuator

Register the physical actuator in AgroPulse before creating a rule that references it.
curl -s -X POST http://localhost:8080/api/actuators \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Irrigation Pump A",
    "type": "PUMP",
    "greenhouseId": 1,
    "gpioPin": 26,
    "activeLow": true,
    "deviceSource": "esp32-abc123",
    "active": true
  }'
Note the id returned (5 in this example). You will use it as actuatorId in the rule.
2

Create the automation rule

Define the condition that should trigger the actuator. The example below activates the irrigation pump whenever soil moisture drops below 30 %.
curl -s -X POST http://localhost:8080/api/rules \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Low soil moisture → irrigate",
    "sensor": "SOIL_MOISTURE",
    "condition": "lt",
    "conditionValue": 30,
    "action": "Activate irrigation pump when soil moisture is below 30%",
    "actuatorId": 5,
    "active": true
  }'

Listing rules

curl http://localhost:8080/api/rules
The response is a JSON array of all rules (not wrapped in an object key).

Updating a rule

Send a PUT to /api/rules/{id} with the fields to change. For example, to raise the soil moisture threshold to 35 % and update the name:
curl -s -X PUT http://localhost:8080/api/rules/2 \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Low soil moisture → irrigate (35%)",
    "conditionValue": 35
  }'
To temporarily disable a rule without deleting it, set "active": false.

Deleting a rule

curl -s -X DELETE http://localhost:8080/api/rules/2
Response: {"deleted": true}

More rule examples

{
  "name": "High temperature → ventilate",
  "sensor": "TEMPERATURE_INTERNAL",
  "condition": "gt",
  "conditionValue": 35,
  "action": "Turn on roof fan to reduce temperature",
  "actuatorId": 8,
  "active": true
}
{
  "name": "Low CO2 → boost",
  "sensor": "CO2",
  "condition": "lt",
  "conditionValue": 400,
  "action": "Open CO2 valve to enrich atmosphere",
  "actuatorId": 11,
  "active": true
}

Build docs developers (and LLMs) love