Using input MQTT node to execute command

Hi

I have quick question not sure if this possible. I have a output MQTT node on my remote server that send messages per topic to my RPi's remotely. The RPi's do receive the messages. My question is when the RPi receive the message is it possible to execute a command from the received MQTT message?

Thank you

yes - look at the exec node...

but be very careful here - you are now letting a remote device send potential random commands into your pi. so a) secure them, and the mqtt broker in the middle, b) don't just pass on the command - do verify it, sanitise it, restrict it to only setting parameters or something.

1 Like

Hi

Thank you for the response, yes what I want to do is that output mqtt will send a spesific command to the exec node. The node must only respond when that command is received.

I will take look and let you know.

the way your flow looks in the image, nothing will happen when you get a mqtt-in msg. If the idea is that depending on the message/topic coming in, you want one of those exex nodes to run, you might try connecting the mqtt-in node to a switch node and based on the results, send it to one of the other nodes.

1 Like

Thank you very much will try it. Very new to Node Red. First project.

Thank you it worked as expected :smile:

1 Like