Executing Shell Script from Rule Machine

I wrote a script that will grab a frame from one of my camera RTSP streams using FFMPEG on a raspberry PI. I'd like to be able to trigger that .sh script using Rule Machine.

I've been trying to set this up using HTTP POST and Node-RED based on what I've been able to find so far online, but I can't get it working for the life of me. Before I spend any more time, I figured I'd ask here as I probably am not even doing this the most efficient way.

What's the most efficient way to trigger a shell script on a raspberry pi using Rule Machine?


You can use a project called OmniThing. This setup allows you to execute a shell command when a virtual switch in Hubitat is changed.

Doing this from Rule Machine is only possible the way you have already tried. Are you not able to get node-red to receive the POST or are you not able to get the script to execute?

I'll have a look at that!

As for node-red, I can't seem to get either to work and I think it's just because this is a bit above my skill level.

Here's what I'm doing as the action in Rule Machine:

Here's the flow in node-red:

The HTTP IN Node:

The Exec node:

The script itself DOES work when ran locally or via ssh so it's not a script problem. I know that I'm just doing something wrong in one of the steps above, and would appreciate any guidance anyone has to offer.

Yeah...you're not setting up node-red to receive a POST message. You have to set up an endpoint which is a lot more complicated than that. I can tell you that OmniThing is a lot more user friendly.

I'll certainly give it a look - though I'm curious as to how I'm not setting it up to recieve a POST message as I thought that I did that properly in the HTTP IN Node?

You have to have certain elements to get this to work...and I don't think you have it all set correctly based on the way it is supposed to be set up.


Well you don't really need to guess.

Stick a debug block off of the HTTP in block, and watch the debug log in node red to see if it is ever triggered.

It's often the ssh to run the remote command that is the hardest to setup - especially if using node red in a docker container.

I do a number of post receiving in node-red, what you listed looks correct to me.

It doesn't have the response node.

:man_shrugging: I actively receive post commands from maker API and a number of other sources in node red. I know how I have mine set up, and it works.

I'll look at one of the flows a little bit closer tonight when I'm at home though. Maybe I'm missing something? It is hard to see on my phone.

I'm just going by the node-red cookbook.

So, you can either go by what you've seen or what the people who built it say you should do. The choice is yours. :man_shrugging:

The documentation is incomplete. A response node is only needed for get messages. It is not needed for post.


He is not SENDING a post. He is trying to RECEIVE a POST from Hubitat. Again....someone jumps in without reading the whole thing.

I suggest you read the whole thread. The OP is trying to use Node Red to execute a shell script based on an HTTP message from HE to Node-Red. So, node-red is the receiver, not the sender. So, it would in fact need a response node. Otherwise it won't send the HTTP response to the sender.

I know exactly what he is trying to do. Again, I receive data from hubitat via post messages in node-red all the time.

I'm not going to bother arguing about it. I'm already doing it, I know for a fact that it works.

I just looked, none of my nodes that are receiving data from a post have a response block. 0.

Have a good day.

What you linked to ALSO has a Response node.

So, I fail to see why you think one isn't necessary.

Then I maintain you are receiving timeout errors to your messages in Hubitat 100% of the time. Because both what you linked to and what I linked to both show an HTTP response node in them.

Maybe so. Don't care, and Hubitat doesn't log an error or warn event for it, so it can't be that bad.

Been doing it for months.

So maybe you should have a response block, but you most certainly do not have to have a response block.


Jason, thanks for your help - I'm sorry that others are being so hostile here. I'd appreciate it, when you do get home, if you wouldn't mind sending a screenshot of one of your flows so that I can compare? I don't understand why they would need a response when I'm only sending data in one direction. I guess I need to do more learning on HTTP POST/GET in general before I try to implement this.

How do I configure the debug module to show me if the HTTP Post is being received? Or should it show me that by default?

Just connect the pin from the debug block to the Http in block. If there are any messages sent out of the HTTP in block it should show up in the debug log. Make sure the debug block itself is also turned on.

I wouldn't assume that at all. If it's waiting for the ack this could seriously impact your lan traffic into/out of the hub.

I'm not the one with the potential problem so yeah, I'm fine.

That's what I did. Hm, so it looks like the POST message isn't getting to node-red, then. I suspect perhaps it's something wrong with how I'm sending from Rule Machine.