> For the complete documentation index, see [llms.txt](https://docs.tricloudnexus.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tricloudnexus.io/management-portal/oee/equipment/tag-mapping/state-and-error-codes.md).

# State & Error Codes

Wire the Equipment Run State tag and choose how Error Codes are tracked — single events, intervals, or open/close pairs.

The **State & Error Codes** group of Tag Mapping drives Availability. It tells the OEE engine:

* Which tag carries the **Equipment Run State** (translated into Availability Categories on the [States Mapping](/management-portal/oee/equipment/states-mapping.md) tab).
* How the equipment’s **error codes** arrive — as point-in-time events, as intervals on a single tag, or as paired open/close events on two tags.

***

## Equipment Run State

| Field                   | Required                           | Notes                                                                                                                                                                                                                                                                                               |
| ----------------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Equipment Run State** | Yes (when Availability is enabled) | The tag whose value identifies the current run state — typical examples: a string tag emitting `Running`, `Stopped`, `Idle`; a numeric tag emitting state codes; or a [Calculation](/management-portal/oee/equipment/tag-mapping/calculations.md) like `a>b` that evaluates to a boolean run state. |

The values this tag emits are translated to Availability Categories on the [States Mapping](/management-portal/oee/equipment/states-mapping.md) tab. Until each emitted value is mapped, the engine treats it as an unknown state and does not credit Availability for it.

{% hint style="info" %}
Many machines don’t expose a single "is-running" tag but do expose a cycle-start and cycle-end timestamp. In that case, configure the Equipment Run State as a [Calculation](/management-portal/oee/equipment/tag-mapping/calculations.md) such as `a>b` over `(StartCycle, EndCycle)`. Boolean expressions reach the engine as the numeric `1` (true) and `0` (false), so the matching rows on [States Mapping](/management-portal/oee/equipment/states-mapping.md) are `1` and `0`.
{% endhint %}

***

## Error code tag configuration

The **Error code tag configuration** dropdown chooses how error codes are reported. The fields below it adapt to the selected mode.

| Mode                             | What the tag emits                                                           | Required tags                       |
| -------------------------------- | ---------------------------------------------------------------------------- | ----------------------------------- |
| **Single Event (point-in-time)** | One event per error occurrence: timestamp + error code value.                | Error Code                          |
| **Single Event (start & end)**   | One event with a start and end timestamp on the same tag (interval mode).    | Error Code                          |
| **Event Pair (start & end)**     | Two separate tags — one fires when an error opens, the other when it closes. | Error Code Open + Error Code Closed |

### Single Event (point-in-time)

Use this for systems where each error is a momentary event. The engine treats each emission as an instant and assumes the error is no longer active until the next emission. This is the simplest mode and suits most stop-cause workflows.

### Single Event (start & end)

Use this when the source carries both timestamps in one payload — typical with MQTT events or OPC events that wrap an interval. In this mode the JSONata Value Parser exposes optional `Start Timestamp` and `End Timestamp` expressions so you can pull both bounds out of one structured payload. See [Tag Mapping](/management-portal/oee/equipment/tag-mapping.md#single-tag-jsonata-for-string-tags) for the JSONata details.

### Event Pair (start & end)

Use this when opening and closing an error are two separate signals. Selecting Event Pair mode reveals a second field — **Error Code Closed** — so you can wire the second tag.

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2Fgit-blob-a368e1f05dd8e6589def358b30abd6fc2abae518%2Foee-error-code-event-pair.png?alt=media" alt=""><figcaption><p>Event Pair mode — Error Code Open and Error Code Closed shown side by side</p></figcaption></figure>

The two tags are matched by their emitted code: an Error Code Open emission with value `101` is closed by an Error Code Closed emission with value `101`. The interval between them is what the engine attributes to the corresponding Stop Cause via [Error Code Mapping](/management-portal/oee/equipment/stop-causes-and-error-codes.md#error-code-mapping).

***

## Validation

| Condition                                                                     | Behavior                                                                                                  |
| ----------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| Availability pillar enabled and Equipment Run State unset                     | Field is flagged required, **State & Error Codes** group shows invalid, Save is blocked.                  |
| Error code tag configuration is **Event Pair** but Error Code Closed is unset | Same — required, blocks save.                                                                             |
| Source tag is no longer present in the asset hierarchy (deleted or renamed)   | The trigger row shows the saved hierarchical path with no value; reopen the dialog to pick a current tag. |

***

## Related

* [Stop Causes & Error Codes](/management-portal/oee/equipment/stop-causes-and-error-codes.md) — translate the values these tags emit into business-friendly stop reasons.
* [States Mapping](/management-portal/oee/equipment/states-mapping.md) — translate Equipment Run State values into Availability Categories.
* [Calculations](/management-portal/oee/equipment/tag-mapping/calculations.md) — derive the run state when no single tag carries it.
