> For the complete documentation index, see [llms.txt](https://docs.chirpwireless.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chirpwireless.io/rules-engine/reference/automation-runs-a-command.md).

# When an Automation Runs a Command

Let a Chirp automation act on its own — the Execute Command step sends a device a command when conditions are met.

An automation can do more than send you an alert: it can run a saved action on a connected device. Add an **Execute Command** step when you want the rule to switch a smart plug or set a light's brightness as part of the response.

The command must already be configured on the device. The automation decides when to send it and supplies any required values, so the same saved action can be used by a person or by a rule.

For example, a humidity automation could request that a compatible plug turns on a dehumidifier. Set up and test the [device command](https://docs.chirpwireless.io/devices/commands.md) first, then select it in this step.

A request being sent does not prove the appliance turned on. [Verification](https://docs.chirpwireless.io/devices/commands/verification.md) is optional and checks the feedback your device can report. Choose it when you need to distinguish a sent request from a reported result.

## Before you start

The Execute Command step runs a command your device **already has**. It doesn't create new ones. So first:

1. **The device has to be controllable** — connected over Zigbee/MQTT, or a Class C LoRaWAN device (those listen all the time, so they're always ready to receive a command).
2. **The device needs at least one command set up** — do that on the device's **Commands & States** tab first. See [Setting up a command](https://docs.chirpwireless.io/devices/commands/creating-commands.md).
3. **You have permission to control it** — same as your home's sharing settings.

If a device doesn't have any commands yet, there'll be nothing to run — set the command up first, then come back to your automation.

## Adding an Execute Command step

1. Open your automation in the [Visual Editor](https://docs.chirpwireless.io/rules-engine/reference/visual-editor.md) and switch to **Editing**.
2. Drag **Execute Command** from the palette onto the canvas. It sits with the other action steps, like Set Alarm.
3. Wire it into your flow. Usually it comes after a gateway: the automation checks a condition, and the branch that means "do it now" leads into the Execute Command step.
4. Click the step to open its settings and fill in the fields below.
5. Click **Save**, then **Build** and switch the automation on. Nothing is sent until the automation is built and running.

## What you fill in

| Field                | What it's for                                                                                                                                                                                               |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Name**             | A label for the step. Leave it blank and pick a command, and it fills in with the command's name. Example: "Turn on dehumidifier".                                                                          |
| **Device**           | A search box listing your devices. Pick the one you want the automation to control.                                                                                                                         |
| **Command**          | A list of that device's commands. It wakes up once you've picked a device, then shows everything the device can do.                                                                                         |
| **Parameters**       | Shows up once you pick a command, with a row for each thing the command needs (a brightness level, a target temperature, on or off). Each one is either a fixed **Value** or an **Expression** — see below. |
| **Inputs / Outputs** | Optional, for advanced setups — named expressions if you want to prepare or pass along values. Most home automations don't need these.                                                                      |

There are **Save** and **Cancel** buttons at the bottom.

### Fixed value, or worked out on the fly

For each thing the command needs, you choose how to fill it in:

* **Value** — a fixed setting you type in. Use this when it's always the same: turn the plug `on`, set brightness to `30`, target `21` degrees. Chirp checks it's a sensible value (in range, right kind of thing) before it'll let you save.
* **Expression** — a little [CEL](https://docs.chirpwireless.io/rules-engine/reference/cel-for-home-automations.md) formula worked out when the automation runs. This is where it gets clever: the reading that set the automation off is available as `vars.value`, so the command can respond to *how* things are — turn the fan up higher the hotter it gets, instead of just on or off.

Put together, it's lovely and flexible: a gateway decides *whether* to act, and an expression decides *how much* — so one automation can both react and respond in proportion.

## What happens when it runs

1. The automation reaches the Execute Command step.
2. Each setting is worked out — fixed values as-is, expressions calculated from the current reading.
3. The command is sent to the device, over Zigbee/MQTT or LoRaWAN, exactly as if you'd pressed it yourself.
4. It's logged in the device's history with how it went (sent, confirmed, delivered, or didn't work), so you can always see what your home did and when.

Because it goes through the normal controls, any "check it actually worked" you set up on that command applies here too. See [Making sure it worked](https://docs.chirpwireless.io/devices/commands/verification.md).

## Doing *and* telling, together

Acting doesn't mean you stop getting told. An automation can request that a valve closes **and** send you an alert about that request. A common shape:

| Step   | Node                  | What it does                                                            |
| ------ | --------------------- | ----------------------------------------------------------------------- |
| Notice | Start Event → Gateway | Watch the leak sensor; branch when it gets wet                          |
| Act    | Execute Command       | Send "turn off" to the water shutoff                                    |
| Tell   | Set Alarm             | Raise a Critical alert explaining why the shutoff command was requested |

A [Boundary Error Event](https://docs.chirpwireless.io/rules-engine/reference/automation-node-guide.md#what-is-the-boundary-error-event-node) can route errors returned by the command step to an alert. Check the command's execution record for later delivery or verification results; moving to the next automation step does not prove the device changed state.

## A home example

For a hypothetical basement setup, connect a humidity sensor and a compatible smart plug with a saved command. The Start Event watches the basement humidity sensor. A gateway routes any reading above 70% down a "too damp" branch. On that branch:

1. An **Execute Command** step sends "turn on" to the dehumidifier's smart plug.
2. A **Set Alarm** step tells you that the automation requested the plug to turn on.

Check the plug's reported state and the appliance's behavior when testing this setup. The alert records the request; it does not prove the dehumidifier started or that humidity has fallen.

## Related pages

* [Controlling Your Devices](https://docs.chirpwireless.io/devices/commands.md) — set up the commands an automation can run, and run them yourself
* [Automation Node Guide](https://docs.chirpwireless.io/rules-engine/reference/automation-node-guide.md) — every node, including Execute Command, in detail
* [CEL for Home Automations](https://docs.chirpwireless.io/rules-engine/reference/cel-for-home-automations.md) — the formulas behind dynamic values
* [Control widget](https://docs.chirpwireless.io/dashboards/adding-widgets/control-widget.md) — the same controls, right on your dashboard
