Documentation
Controls
Controls let you manage pumps, valves, relays, and other output devices.
Relay Control
Relays are the primary control mechanism in MudPi. They can switch pumps, solenoid valves, lights, and other electrical devices on and off based on schedules or sensor thresholds.
Configuration
Controls are defined in the controls array of your configuration file:
JSON
{
"controls": [
{
"pin": 17,
"type": "relay",
"name": "Main Water Valve",
"default_state": "off"
},
{
"pin": 27,
"type": "relay",
"name": "Drip Line Zone A",
"default_state": "off"
}
]
}
| Property | Type | Description |
|---|---|---|
pin |
Integer | GPIO pin connected to the relay input |
type |
String | Control type (currently relay) |
name |
String | Human-readable name for the control |
default_state |
String | on or off — state on system startup |
Manual Control
Controls can be toggled manually via the API, the Solarbeam dashboard, or command-line tools:
Shell
redis-cli PUBLISH "mudpi:controls" '{"action": "toggle", "control": "Main Water Valve"}'
Automated Control
Combine controls with triggers to automate actions. For example, turn on a pump when soil moisture drops below a threshold:
JSON
{
"triggers": [
{
"source": "Garden Bed 1",
"condition": "below",
"value": 40,
"action": "Main Water Valve",
"action_state": "on",
"duration": 120
}
]
}
Warning
Always use the duration property with automated triggers to prevent devices from running indefinitely. Use appropriately rated relays for your load and never work on live circuits.