MQTT JavaScript API

Connector functions MQTT JS API guide

This API allows users to execute operations in the MQTT client from a connector function.

MQTT Object

The mqtt object is the main object of the MQTT client. It allows to publish messages to MQTT topic

mqtt Object Properties

Property Type Default Description
device string entity id Target device id
topic string odm/request Topic uri where to publish the message

mqtt Object Methods

publish (payload)

Publish a message on mqtt topic

Property Type Default Description
payload * Message to be sent. It can be string or a json object

Example of use with default values:

mqtt.publish({'operation_name':'custom_operation_request'});

Example of use with overriden values

mqtt.device='other_device';
mqtt.topic = 'destination/topic';
mqtt.publish('Message to be sent');