# Automation Guide

Automation makes your garden respond on its own: water when soil dries out, vent
when it's hot, run a scene at dawn. Rules combine **conditions** (from sensors,
time, and weather) with **actions** (devices, notifications, scenes).

## Build a rule

Go to **Sensors → Automation** (`/sensors/automation`) → **New rule**. A rule is
"**when** these conditions hold, **do** these actions":

1. **Conditions** — add tests like _soil moisture < 30%_, _time between 6–8am_,
   _no rain forecast_. Combine them with **AND/OR** groups (and nest groups for
   "A and (B or C)").
2. **Actions** — _open a valve for 10 min_, _send a notification_, _run a
   scene_, _log an event_, or _wait_ between steps.
3. **Guards** — set a **cooldown** (e.g. at most once per 6 h) and a
   **priority** so rules don't fight or spam.

The full grammar (condition types, operators, action types) is documented in the
[automation rule syntax](../automation/rule-syntax.md).

## Ready-made building blocks

- **Irrigation** — schedule-, moisture-, or evapotranspiration-based watering
  with usage tracking.
- **Climate control** — vent/fan actions driven by temperature and wind.
- **Scenes** (`/sensors/scenes`) — named bundles of actions ("Morning",
  "Heatwave") you can trigger manually or from a rule.
- **Alerts** (`/sensors/alerts`) — a focused rule type for threshold
  notifications (see [IoT Setup](iot-setup.md)).

## Trust but verify

- Rules only fire when **enabled**; start disabled and watch the preview.
- Every trigger is logged (with the conditions that matched), so you can see
  _why_ something ran. Automation **history** also reports water savings and
  flags under-performing rules.
- Cooldowns prevent rapid re-triggering; manual override is always available.

## Example

> _Bed 3 low-moisture watering:_ **when** soil moisture < 30% **and** rain = 0,
> **open** the drip valve for 10 minutes and **notify** me — **at most** once
> every 6 hours. (Full JSON in the
> [rule syntax doc](../automation/rule-syntax.md).)
