> For the complete documentation index, see [llms.txt](https://docs.voltmasters.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.voltmasters.io/control-algorithms/cost-optimization/selling-energy-to-the-grid.md).

# Selling energy to the grid

Under [cost optimization](/control-algorithms/cost-optimization.md) the battery normally discharges to cover the **site's own consumption**, using stored energy instead of buying expensive grid energy. **Selling energy to the grid** (also called *battery injection sales* or *discharge to grid*) is an optional extension: when the **injection (feed-in) price** is high enough to be profitable, the EMS discharges stored energy **into the grid** to earn revenue, on top of self-supply.

{% hint style="warning" %}
This is **optional and off by default**. The battery only ever discharges purely to sell when you explicitly enable it (see below). With it disabled, the battery still discharges, but only to cover your own consumption.
{% endhint %}

## Enabling it

Selling energy to the grid is a per-project setting. Enable the **Battery injection sales** toggle under [Project settings](/voltmasters-platform/10.-project-settings/10.5-project-settings.md).

* **Disabled (default)**: the battery is never discharged just to feed the grid. Cost optimization only stores cheap/solar energy and releases it to cover the site's own deficits.
* **Enabled**: the cost-optimization planner additionally looks for profitable moments to inject stored energy into the grid, and plans extra discharge for them.

It only has an effect while the project runs **cost optimization** and **no** [**external signal**](/external-signal/external-signal.md) **partner is steering** the installation.

## Two ways to sell

Energy is always sold at the **most profitable moments**: the planner ranks the candidate slots by injection price and serves the **highest price first**. What differs between the two modes is *how much* of the battery is offered for sale.

### 1. Selling surplus energy

Part of what the battery stores is **not needed** for the site's upcoming consumption; that is **surplus** (for example, more solar was stored during the day than the evening will use). The surplus is sold at the moment the **injection price peaks**. This is the baseline behaviour whenever injection sales are enabled.

### 2. Selling beyond the surplus: price arbitrage

Energy that the plan would otherwise **keep** to cover a later deficit (so it can avoid buying at the future consumption price) can be sold **too**, but only when it clearly pays off: when the **injection price now is more than the minimum price difference above that later consumption price**. In that case the kilowatt-hour earns more sold now than it would save later, so the planner exports it and meets the later need from the grid instead.

### How it looks

<figure><img src="/files/Ju0KWLnE5PLxebuvVvNf" alt="Selling energy to the grid: market price, battery state of charge and energy destinations over a day"><figcaption><p>Over a day the battery charges on cheap/solar energy (<strong>1: store surplus</strong>) and powers the site through the day (<strong>2: self-consumption</strong>). In the highest-price window it injects extra energy to the grid (<strong>3</strong>): the surplus always (Mode 1), and, when the injection price beats the later consumption price by more than the minimum price difference, energy that would otherwise have been kept for later (Mode 2).</p></figcaption></figure>

### When a slot qualifies

The amount available for selling is budgeted **per recharge segment** (roughly per PV cycle/day): each segment can offer the energy it starts with plus its expected PV surplus, minus the deficits it must still cover and any reserve. A segment never sells energy that belongs to another, which keeps **multi-day plans stable**.

Within that budget, a slot is only used to sell when **all** of these hold:

* the **injection price is positive** and **clears the minimum price difference** (so the sale covers round-trip losses and battery wear);
* the **consumption price is not negative** (a negative price means it is cheaper to *charge*);
* the slot is **not already a charging slot** (a battery cannot charge and discharge at once);
* the slot is **not in the last four hours** of the forecast (too uncertain to commit storage to);
* there is **energy above the reserve** (the effective minimum state of charge, including any EV power-boost reserve), and the export stays **within the grid connection's injection limit**.

## Safeguards

Selling to the grid never runs away with your battery or your money:

* **Profit margin**: the minimum price difference guarantees every sale clears the round-trip loss and cycle wear.
* **Reserve & minimum SoC**: discharging stops at the effective minimum; reserves (such as an EV power-boost reserve) are off-limits.
* **Forecast tail exclusion**: no injection is planned in the final four hours of the horizon.
* **Grid export limit**: battery injection and PV export share one export budget, capped at the connection's injection limit.
* **Self-supply first**: energy is only sold when selling beats self-use; covering your own consumption otherwise takes priority.

## See also

* [Cost optimization](/control-algorithms/cost-optimization.md): the overall price-based strategy this extends.
* [Battery schedule](/control-algorithms/cost-optimization/battery-schedule.md): the forward plan, its event types and a worked example.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.voltmasters.io/control-algorithms/cost-optimization/selling-energy-to-the-grid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
