AI Prompt

Irrigation Booster Pump (macro)

Use this prompt to generate a macro-based script similar to the irrigation booster pump macro example.

Prompt

Go to this wiki https://tb.kouman.eu/wiki/ems.html and study how their scripting language for esp32 boards works. Then please:
- Use '_' prefixed locals inside macro commands to avoid variable collisions across expansions.
- Keep the script including comments under 5000 bytes.

Write an Etheras Microscript for the SmartI8 board (DI=8, DO=8, AI=8, WiFi/Ethernet/LoRaWAN).
Write a script for a 3-pump irrigation booster system (Jockey, Main, Diesel) with analog sensors.

Use macro helpers to keep the script short and readable.

Persistent thresholds:
- load(JON, 20), load(JOFF, 40), load(MON, 10), load(MOFF, 30), load(DON, 10), load(DOFF, 30).

Inputs/outputs:
- ain(1)=pressure, ain(2)=battery, ain(3)=water.
- in(1)..in(6) select modes: for each pump, MAN input is in(2/4/6); AUTO input is active-low in(1/3/5); OFF otherwise.
- in(7) and in(8) are thermal OK (active low) for jockey and main.
- out(1)/out(2)/out(3) control pumps, out(4) is error output.

Logic:
- Use states OFF/AUTO/MAN.
- If dry-run stop pumps and publish "alarm", "DRY_RUN".
- Battery low warning after 1 min delay.
- In AUTO, start pump when pressure below ON threshold and stop when above OFF threshold. In MAN, force ON. In OFF, force OFF.
- If any fault or warning, set out(4)=1.
- Publish status every STATUS ms via publish("status", ... all fields). Log pressure every 10 s.

MQTT setters:
- onmqtt("JON_script".."DOFF_script") save new numeric thresholds using save.