跳转到内容

Working with UNS Data

适用版本EdgeCloudEnterprise

此内容尚不支持你的语言。

Tier0 allows you to operate on the UNS through MQTT and APIs.

Tier0 enables MQTT clients to connect to the internal MQTT broker and operate on the UNS.

  1. Log in to Tier0, select Edge.
  2. Click New Credentials on the right side.
  3. Enter the Name and Description, and click Create.
  1. Install an MQTT client, such as MQTTX, MQTT Explorer and others.
  2. Use the credentials from Tier0 to connect the client.
  1. Install and open MQTTX.

  2. Click the + button at the upper-left corner to add a connection.

  3. Enter the broker information and the generated credentials.

    Terminal window
    {
    "Host": "mqtt.tier0.dev",
    "Port": 8883,
    "Client ID": "<generated client ID>",
    "Username": "<generated username>",
    "Password": "<generated password>"
    }
  4. Click Connect.

  1. Log in to Tier0, and go to Edge.
  2. Click the Clients tab and check the status of each client.
  3. Copy the topic of the data model under UNS, and publish a message to it through the client.
  4. Go back to UNS, check the data under the target topic.

Use RestAPI to operate on UNS data, flows and authentication.

  • /flow/create

    Create a SourceFlow or EventFlow. flowName and flowType are required.

    Terminal window
    const BASE_URL = process.env.TIER0_BASE_URL;
    const API_KEY = process.env.TIER0_API_KEY;
    const response = await fetch(`${BASE_URL}/flow/create`, {
    method: 'POST',
    headers: {
    'content-type': 'application/json',
    'x-api-key': API_KEY,
    },
    body: JSON.stringify({
    flowName: 'Manufacturing source flow',
    flowType: 'SourceFlow',
    description: 'Collects UNS source data from the plant.',
    template: '{}',
    }),
    });
    const result = await response.json();
    console.log(result.data.id, result.data.brokerID);
  • /flow/list

    List flows and optionally filter by flowType or keyword. Use this to find the flow id before update or get operations.

    Terminal window
    const BASE_URL = process.env.TIER0_BASE_URL;
    const API_KEY = process.env.TIER0_API_KEY;
    const response = await fetch(`${BASE_URL}/flow/list`, {
    method: 'POST',
    headers: {
    'content-type': 'application/json',
    'x-api-key': API_KEY,
    },
    body: JSON.stringify({
    flowType: 'SourceFlow',
    keyword: 'Manufacturing',
    }),
    });
    const result = await response.json();
    console.log(result.data.list);
  • /flow/update

    Update a flow by id. Send only the fields you want to change.

    Terminal window
    const BASE_URL = process.env.TIER0_BASE_URL;
    const API_KEY = process.env.TIER0_API_KEY;
    const flowId = 123;
    const response = await fetch(`${BASE_URL}/flow/update`, {
    method: 'POST',
    headers: {
    'content-type': 'application/json',
    'x-api-key': API_KEY,
    },
    body: JSON.stringify({
    id: flowId,
    flowName: 'Manufacturing source flow v2',
    description: 'Updated source flow description.',
    isFavorite: 1,
    }),
    });
    const result = await response.json();
    console.log(result.data.success);
  • /flow/get

    Get one flow by id.

    Terminal window
    const BASE_URL = process.env.TIER0_BASE_URL;
    const API_KEY = process.env.TIER0_API_KEY;
    const flowId = 123;
    const response = await fetch(`${BASE_URL}/flow/get`, {
    method: 'POST',
    headers: {
    'content-type': 'application/json',
    'x-api-key': API_KEY,
    },
    body: JSON.stringify({ id: flowId }),
    });
    const result = await response.json();
    console.log(result.data);