The MQTT Publish Action Component allows you to publish messages to topics within an MQTT PubSub system.
Output Payload | Explanation |
---|---|
cv.Payload |
Outputs the output payload of the previous component as is. (Pass through) |
Component Properties
Name | Required | Description |
---|---|---|
Topic | True | MQTT Topic |
ClientId | True | MQTT ClientID |
QoS | True | QoS value |
Retain | True | Retain flag |
Timeout | True | Timeout (ms) |
MQTT Connection | False | MQTT Connection Settings from the Base Property Profile |
URL | True | URL |
Port | True | Port |
Username | False | Username |
Password | False | Password |
Certificate | False | Certificate |
Private Key | False | Private Key |
Private Key Passphrase | False | Private Key Passphrase |
Root CA | False | Root CA |
Google Cloud MQTT Example
Here is an example of how to publish messages to a Google Cloud MQTT System:
Navigate to your Google Cloud console and create a project:
Navigate to Google Cloud Platform IoT Core
Enable the Google IoT Core API.
Create a Device Registry
Enter the name of your registry, select the region and add the topics (here events
and states
for example):
Click on “Add Device” in this screen:
And you will see:
Create a certificate that you can paste into the field by entering this command in your command line:
openssl req -x509 -newkey rsa:2048 -keyout rsa_private.pem -nodes -out rsa_cert.pem -subj "/CN=unused"
This will create a file rsa_private.pem
and a file called rsa_cert.pem
Copy the contents of the rsa_cert.pem
file into the window:
We’re now ready to take on messages from Gravio.
Note: The MQTT Publish component will take the variables as payload and make one MQTT publish per variable. And if you use JSON or CSV the variable name will be the key/column.
Typically you can use the CreateRecord component to inject a variable into the MQTTPublish component.
To see how to retrieve MQTT messages, please refer to the MQTT subscription section of this documentation.