Set up a MQTT Integration

Overview

TilliT does not send information over MQTT by default, you need to configure what types of information you want to be sent. This is done by creating an MQTT integration which will send an MQTT message when a specific event occurs. For instance when an Order Started event occurs or Shift Started.

Configure an MQTT Channel

Navigate to Settings > Integrations > Channels and create a Channel

Fill in the form and hit Save and Open

Name
Description

Name

The name of your channel

Type

Webhook, MQTT, or Sftp

Options

See below for general options and Sft channel options. It should be written as a json object

export type ChannelOptions = {
  username?: string;
  headers?: any;
  authType?: 'OAUTH' | 'BASIC' | 'TOKEN';
  tokenUrl?: string;
  clientId?: string;
  secretName?: string;
  scope?: string;
  grantType?: string;
  jsonata?: string;
};

export type SftChannelOptions = {
  tempFolder?: string;
  filePrefix?: string;
  host?: string;
  username?: string;
  port?: number;
  secretName?: string;
};

Example:
{
  "username": "myName",
  "tokenUrl": "tokenUrl.here"
}

Transform Payload

This is a jsonata expression. See their documentation here - https://jsonata.org/. It is used to reduce the payload size so that only the requirement data will be sent to the channel.

Now we need to create a subscription which will cause an MQTT message to be sent, for this example we want this to happen on any Equipment Stopped Event. Click Actions -> Create and fill in the following form.

Now whenever an Equipment Stopped event is raised, we can receive this event as an MQTT message.

You can also filter the subscription so you only receive events that meet a certain condition. The fields you fill in above will define how specific or broad the subscription is:

Name
Description

Event Type

Event trigger you want to use. If you only select an event type, you will receive payloads every time that event triggers. Using the other fields allows you to make more specific subscriptions.

Asset

A specific asset you want

Order

A specific order number you want

Activity Key

One Activity Key of your Activity Template.

Channel

The channel you are subscribing to

Site

A specific site you want

Asset Class

A specific asset class you want. It will filter for all assets under that class.

Parent Asset

It will filter for all assets that have this parent asset.

Activities Included

Note: This is not applicable for MQTT. This only applies for user email subscriptions. You must choose a channel that you created for your user profile if you want this option. If you are sending an email, TilliT will include the results of any activity result you have in the email. Maintain a list of comma-separated activity keys.

Receive the TilliT Event

We have now configured TilliT to send an MQTT message on the Equipment Stopped event. In previous steps we also described how to connect to the TilliT Broker and what topic to subscribe to receive the event. You can use the Javascript code snippet provided in Connect to the TilliT Broker and adjust to the steps outlined here.

Subscribe to the /tenant/+/+/Event/# topic

Manually raise an Equipment Stopped event in TilliT

See that you receive a similar payload body via MQTT as shown below

{
  "id": 177842,
  "createdAt": "2022-06-30T06:54:33.638Z",
  "updatedAt": "2022-06-30T06:54:33.638Z",
  "name": "Equipment stopped",
  "subtitle": "SCH457980 - 2000469",
  "activityKey": null,
  "priority": 2,
  "timestamp": "2022-06-30T06:54:33.590Z",
  "closedAt": null,
  "status": "ACTIVE",
  "asset": {
    "id": 2,
    "createdAt": "2020-12-14T05:51:58.589Z",
    "updatedAt": "2022-03-18T04:11:31.127Z",
    "name": "Depalletiser 1",
    "displayOrder": 1,
    "defaultRunRate": 60,
    "packml": true,
    "representsLineProduction": false,
    "representsLinePerformance": false,
    "allowMultipleOrders": false,
    "active": true,
    "type": "EQUIPMENT",
    "site": {
      "id": 1,
      "createdAt": "2020-12-14T04:49:27.159Z",
      "updatedAt": "2022-05-24T02:45:26.660Z",
      "name": "Bottling site 1",
      "displayOrder": 1,
      "timezone": "Australia/Adelaide"
    }
  },
  "eventType": {
    "id": 2,
    "createdAt": "2020-12-14T04:49:26.875Z",
    "updatedAt": "2020-12-14T04:49:26.875Z",
    "name": "Equipment stopped",
    "subtitle": null,
    "priority": 2,
    "displayOrder": 1,
    "systemEvent": "EQUIPMENT_STATUS_STOPPED",
    "closingEventId": 1
  },
  "order": {
    "id": 34785,
    "createdAt": "2022-05-18T01:10:10.731Z",
    "updatedAt": "2022-06-30T05:25:19.308Z",
    "name": "2000469",
    "orderDate": "2022-06-30",
    "orderNumber": "SCH457980",
    "operation": "DEPAL",
    "batchNumber": null,
    "quantityTarget": "280",
    "dueDateTime": null,
    "scheduledStart": "2022-06-30T01:14:08.000Z",
    "scheduledEnd": "2022-06-30T04:52:43.000Z",
    "actualStart": "2022-06-30T05:25:19.229Z",
    "actualEnd": null,
    "defaultRunRate": 60,
    "status": "RUNNING",
    "notes": null,
    "actualChangeoverStart": null,
    "actualChangeoverEnd": null,
    "scheduledChangeoverDuration": null,
    "previousOrderId": 34779,
    "schedulerOrderItemId": 2051,
    "segmentExternalId": "Produce",
    "routeExternalId": "Route 1",
    "material": {
      "id": 3,
      "createdAt": "2020-12-15T23:43:06.027Z",
      "updatedAt": "2022-06-29T17:39:52.490Z",
      "name": "459690 Merlot v01",
      "active": true,
      "canProduce": true,
      "canConsume": true,
      "externalId": "2000457",
      "barcodeReference": "1231231321231",
      "defaultRunRate": null,
      "displayOrder": 2
    }
  },
  "activityInstance": null,
  "changeOver": false,
  "eventReason1": null,
  "eventReason2": null,
  "eventReason3": null,
  "eventReason4": null,
  "downtimeType": null,
  "comments": null
}
	

Last updated