> ## Documentation Index
> Fetch the complete documentation index at: https://docs.amps.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart charging

> Hand charging times to the charger's own price or solar optimiser, and read back which mode it is running.

Push an `auto.*` command and the charger picks the hours itself, using the tariff set in the manufacturer's app or what the solar array is producing. Use a [windowed `charge`](/cookbooks/ev-charger/start-stop-session) instead when you want to own the timing.

| Command | The charger optimises for |
| - | - |
| `auto.charge_tariff` | Price. Charges in the cheapest hours of the home's configured tariff. |
| `auto.charge_surplus_only` | Zero import. Charges from spare solar and pauses when it runs out, so the car may not fill. |
| `auto.charge_surplus_first` | A full car. Uses spare solar first, then tops up from the grid. |

## 1. Check the device supports it

```bash theme={null}
curl https://api.amps.ai/ev-charger/device_abc123 \
  -H "x-api-key: $AMPS_API_KEY"
```

```json theme={null}
{
  "success": true,
  "data": {
    "id": "device_abc123",
    "commands": {
      "auto.charge_tariff": { "parameters": {}, "execution": ["immediate", "scheduled"] },
      "auto.charge_surplus_first": { "parameters": {}, "execution": ["immediate", "scheduled"] }
    }
  }
}
```

A mode missing from `commands` returns `422 DEVICE_NOT_CAPABLE`. Modes take no parameters and no `end`: they run until another command replaces them, and either one also returns `422 DEVICE_NOT_CAPABLE`.

## 2. Send the command

```bash theme={null}
curl -X POST https://api.amps.ai/ev-charger/device_abc123 \
  -H "x-api-key: $AMPS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "action": { "command": "auto.charge_tariff" } }'
```

```json theme={null}
{
  "success": true,
  "data": {
    "id": "action_esFwvosZG6",
    "command": "auto.charge_tariff",
    "parameters": null,
    "state": "acknowledged"
  }
}
```

Add a `start` to switch modes later, such as `"start": "2026-07-30T18:00:00"` in plant-local time. To leave the mode, push `idle`, `charge`, or another `auto.*`. See [Conflicts](/guides/push/conflicts) if you get a `409`.

## 3. Confirm

The mode is armed, and nothing may flow for hours. Read the device to see which mode holds it:

```json theme={null}
{
  "success": true,
  "data": {
    "id": "device_abc123",
    "state": {
      "status": "scheduled",
      "isConnected": true,
      "isCharging": false,
      "notChargingReason": "schedule",
      "activeControlMode": "auto.charge_tariff"
    }
  }
}
```

The charger is waiting for a cheap hour, so show "waiting for off-peak", not "not charging". `activeControlMode` is absent on chargers that don't report it. See [Why isn't it charging?](/cookbooks/ev-charger/why-not-charging) for the other reasons.

## Next steps

<CardGroup cols={2}>
  <Card title="Start and stop a session" icon="plug" href="/cookbooks/ev-charger/start-stop-session">
    Charge inside a window you choose.
  </Card>

  <Card title="Why isn't it charging?" icon="circle-help" href="/cookbooks/ev-charger/why-not-charging">
    Read the reason a plugged-in car takes no power.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.