mqtt (function)

Last updated: Fri, May 19, 2023 1:17 pm
Return to Knowledgebase

Purpose

Used to publish a message to an MQTT broker. - Deprecated in favor of the MQTT plugin which re-includes this function.

Location

users/helpers/us_helpers.php

Version Information

Deprecated v5.5.8

Parameters

# Parameter Data Type Required Description
1 $id integer Yes The ID of the MQTT server as defined in the mqtt table of the Userspice database.
2 $topic string Yes The topic to publish the message to.
3 $message string Yes The message to publish.

Returns

Data Type Description of Returned Data
nothing

Further Documentation:

Example usage:

$id = 1; // The ID of the MQTT server in the database
$topic = 'test/topic';
$message = 'Hello, World!';

mqtt($id, $topic, $message);



This will publish the message "Hello, World!" to the MQTT broker defined in the mqtt table of the Userspice database with the ID of 1, using the topic test/topic.