# Publish Order Progress

## Overview

An Order Progress is a TilliT Edge **timeseries entity** that tracks the **production counts** and **equipment status** every minute to create metrics such as performance, availbility and quality. This data can be published via MQTT into TilliT to give a live **up-to-date** view of your current production data.

## Payload

The Order Progress entity is shown below. You will need to find the **assetId** of the asset you are going to update, you may want to look at how to interact with our API to receive that data.

```javascript
{
  "format": 'json',
  "body":[{
      "assetId": number,
      "orderNumber": string,
      "orderId": number | null, //Is optional, if not supplied then the current running order is used.
      "shiftId": number | null,
      "timestamp": string, //(ISO Date Format)
      "totalCount": number,
      "rejectCount": number,
      "assetStatusCause?: string, // ('RUNNING', 'STOPPED', 'BLOCKED', 'STARVED')
      "EQUIPMENT_STATUS_READY": boolean,
      "EQUIPMENT_STATUS_RUNNING": boolean,
      "EQUIPMENT_STATUS_STOPPED": boolean,
      "EQUIPMENT_STATUS_COMPLETE": boolean,
      "EQUIPMENT_STATUS_SUSPENDED": boolean,
      "EQUIPMENT_STATUS_ABORTED": boolean,
      "EQUIPMENT_STATUS_STARVED": boolean,
      "EQUIPMENT_STATUS_BLOCKED": boolean,
      "EQUIPMENT_STATUS_FAULTED": boolean,
      "downtimeReason": string | null, //for automatic downtime assignment
      "reasonGroupId": number | null, //for automatic downtime assignment
      "stateStoppedSeconds": number, // seconds in which machine was stopped between reporting
      "currentRate": number | string
  }]
}
```

It is **not necessary** to send every field in the payload. It may be easier to start with just counts, stopped and running states. Take note that this **is an array**, where each element in the array has a unique asset. This allows you to send multiple order-progress messages for multiple assets in a single message.

## Sending to the MQTT Broker

{% hint style="warning" %}
**DO NOT** send order progress at an interval less than one minute. For best results, order progress is sent every minute.

**DO NOT** send multiple updates for an asset/order in a single order progress message.

**Batching** should be used as much as possible. Where multiple assets have an updated count/state in a minute, then include them all in the same order progress message.
{% endhint %}

The topic to publish on is constructed as per the following, replacing **ENV**, **TENANT** and **THINGNAME** with those that apply for you

```
$aws/rules/ENV_edge_data/TENANT/THINGNAME/order-progress


e.g $aws/rules/production_edge_data/bottling/TillitEdge-717503/order-progress
    $aws/rules/stage_edge_data/bakery/TillitEdge-a0163b/order-progress
```

You can find your thingName contained in the same file as the certificates supplied to you. You can also contact support to track down the thingName for you.

Now follow these steps to successfully simulate order progress

Find an **asset** to add order-progress to and record it's ID.

![](https://s3.amazonaws.com/helpscout.net/docs/assets/60208fd212248b2c96d50eeb/images/62bd33a7eabe9a7235b394a7/file-QJtdpCBa8C.png)

Ensure an order is in the **RUNNING** state on the asset (only nessecary if orderId is not included in payload)

![](https://s3.amazonaws.com/helpscout.net/docs/assets/60208fd212248b2c96d50eeb/images/62bd33cb0b51ec1ae83fbd98/file-RmO3zTujHF.png)

Publish the following **payload** on the topic specified prior (replace ids with yours and timestamp of today)

```json
{
  "format": 'json',
  "body": [{
    "assetId": 2,
    "timestamp": "2022-06-30T05:28:40.273Z",
    "totalCount": 10,
    "EQUIPMENT_STATUS_RUNNING": true,
    "EQUIPMENT_STATUS_STOPPED": false
  }]
}
	
```

You can now see **progress** on the order and asset card inside TilliT

![](https://s3.amazonaws.com/helpscout.net/docs/assets/60208fd212248b2c96d50eeb/images/62bd35bdeabe9a7235b394ae/file-f2PBgnySEn.png)

For a **rawer view**, you can navigate to History -> Orders and select the order that was running on the asset

![](https://s3.amazonaws.com/helpscout.net/docs/assets/60208fd212248b2c96d50eeb/images/62bd34e00b51ec1ae83fbd9c/file-V10XkoD14R.png)

Scroll and click on the **Progress Pane**, observe that there is a row with the order progress we sent via MQTT.

![](https://s3.amazonaws.com/helpscout.net/docs/assets/60208fd212248b2c96d50eeb/images/62bd354303382e4311cf000c/file-oHORF3JHxp.png)
