Mqtt output edge workflow

Good morning

I have the following question, how can I send a command to a device through my edge compute gateway workflow?

I’m trying to publish in the topic exposed in the documentation but the mqtt output block presents an error in this topic, I would like to know what would be the correct topic to send a command to my device through the edge workflow, can anyone give me this information?

The MQTT Output Node cannot send messages to “losant” MQTT topics (the state and command topics).

Instead, if you wish to send a command to one or more devices, you can use the Device: Command Node.

Similarly, in an Edge Workflow, the MQTT Trigger will not respond to messages received on the command topic. Instead, you’ll want to use a Device: Command Trigger.

I found another way to do what I want, using the http block and creating an end point in the application. I have a problem with how to configure the block to be able to send a complete payload to the endpoint.

Hey @Lucas_Pinheiro,

Instead of an endpoint, I recommend your edge workflow publish to a custom MQTT topic. That message can then be picked up by an application workflow which sends a command using the Device: Command Node.

The reason I prefer the MQTT topic instead of an endpoint is for security. To use an endpoint you’ll have to incorporate some form of authentication to prevent anyone from randomly invoking your endpoint. MQTT connections are already authenticated and custom topics are controlled by your device’s access key. This gives you a high degree of confidence that it was indeed your own device that published the message.

Do you have any example of sending a custom topic through the edge workflow?

The Endpoint Retrieving Edge Data library template does have an example of an edge workflow publishing to custom MQTT topics. You can import that template into a different application and inspect the workflows to see how they work. The template’s README also has a section on how to allow custom topics for your device’s access key.