# Test MQTT topic

## About test&#x20;

Data reading and writing examples here below assumes that you are using the Eclipse Mosquitto client CLI, available at the official page <https://mosquitto.org>

## Code placeholders

Code here follows uses placeholders that must be replaced with the actual values. \
So you should know in advance these variables:

* **\<realm-id>**: identifier of the organization (see [Get organisation-id](/things5/integrations/devices-and-provisioning/get-realm-id.md))
* **\<device\_id>**: identifier of the machine (see [Get device-id](/things5/integrations/devices-and-provisioning/get-device-id.md))

machine ssl certificates names, contained in the zip file (see [Get ssl certificates](/things5/integrations/devices-and-provisioning/get-ssl-certificates.md) )

* **\<certificate\_crt>**: named as xxxxxxxxxxxx-certificate.pem
* **\<private\_key>**: named as xxxxxxxxxxxx-private.pem
* **\<cafile\_crt>**: AmazonRootCA1.pem is the current file name

## Publish data&#x20;

{% hint style="warning" %}
**timestamp** must be expressed in milliseconds\
Sent data by here below snippet are: Cabinet\_probe: 55, Evaporator\_probe: 85

Further about [machine variables](/things5/device/manage-firmware/machine-variables.md) in documentation page.
{% endhint %}

```
mosquitto_pub \
-h mqtt.things5.digital \
-q 1 \
-p 8883 \ 
-t things5-production/v1/devices/<device_id>/data_req \
-i things5-production-machine-<device_id> \
-m "{\"metrics\":[{\"timestamp\":0000000000000,\"data\":[{\"name\":\"Cabinet_probe\",\"value\":"55"},{\"name\":\"Evaporator_probe\",\"value\":"85"}]}]}" \
--cafile <cafile_crt> \
--cert <certificate_crt> \
--key <private_key> 
```

Visit monitoring page at this url (*replace placeholders with their real values*) to see published data

```
https://<realm-id>.things5.digital/machines/<device_id>/monitoring
```

### Data stream monitor

Things5 lets you monitor device-broker-device message exchange as shown in this help section [MQTT Diagnostic](/things5/integrations/devices-and-provisioning/mqtt-diagnostic.md)

## Read configuration

Subscribe this topic to let Things 5 read configuration dataset from device (you'll also have to send the right response as explained in the API documentation)

```
mosquitto_sub \
-h mqtt.things5.digital \
-q 1 \
-p 8883 \ 
-t things5-production/v1/devices/<device_id>/cmd/read_variables_req \
-i things5-production-machine-<device_id> \
-v \
--cafile <cafile_crt> \
--cert <certificate_crt> \
--key <private_key> 
```

Visit configuration page at this url (*replace placeholders with their real values*) to see read data

```
https://<realm-id>.things5.digital/machines/<device_id>/configuration
```


---

# Agent Instructions: 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://admin-things5.gitbook.io/things5/integrations/devices-and-provisioning/test-mqtt-topic.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.
