Can I use SmartThings to run bash scripts on my Raspberry PI

I am sure @leinax can explain how he does it. I don’t think it is too hard. He uses it to run various scripts on his linux server and workstation via a momentary button/switch within ST.

Well, yeah, you can do anything if you know how to code it. I think the OP was asking for an implementation that would be a little more “packaged” than, “yeah, just do it.”

1 Like

OmniThing allows you to create a switch that runs a “CommandExecuter” output. In the web configuration tool that runs on your pi locally, it allows you to specify any bash command you want for both “on” and “off” states. You enter the commands directly in the web browser.

In the case of running an arbitrary script already on the pi, the command can just be “/path/to/script.sh”. If you want, you can also write simple scripts directly in the browser (i.e. ‘echo “Task one”; echo “Task two”’).

In the SmartThings app, you will see a switch, and toggling it will run the appropriate script for on/off.

Example of how I turn my windows vm on/off with SmartThings from my linux host:

5 Likes

Sweet! Definitely going to give that a try. Thanks!

2 Likes

Thanks for the replies and the detailed how-to. I’ll give OmniThing a shot. My sprinkler system uses 5 Sonoff 4CH relays flashed with Espurna. It works over wifi and I can easily run a program or single zone via cron, a terminal in my phone, or whatever. I’d just like to tie it in with SmarThings, mostly just for fun. Thanks again.

1 Like

You could also flash your Sonoff with firmware that allows for direct control from ST.

You can easily do this using HousePanel with a one line update to the source code to invoke a PHP exec call when a tile is clicked… I had this in the code for calling a Python app to update my Arlo video hack but removed it when I found a more elegant solution. The only semi-hard part is getting HousePanel up and running if you are new to it. Otherwise making this work should be a walk in the park. I’ll post an example later this weekend.

But that’s not issuing it from ST. That’s issuing it from HousePanel. That’s not really automating it.

Yup, you’re right. However, using the built-in HP API one could query the status of anything authenticated and then based on results invoke whatever SH script of interest. It would be a lot of work but definitely possible. Personally I would use Python to do this instead of SH but either should work.

Http switch to send a post or get to node red. Can execute any script you like on the pi. Fairly simple to setup as well with a http switch driver.

may be simple if you’re a coder. but for those of us that are self-taught on this stuff it’s not all that easy.

Umm all the code exists. You just have to install the various programs. I’d you’d like some help pm me.

For the record I fall into this category. No coder. Self taught.

Yea… but now Chris you’re a coder dude!

High praise coming from you my friend. HP was my inspiration so you are to blame. :sunglasses:

Though I think I prefer the term tinkerer.

So @Ryan780 to make this work and appear to be happening from ST, start by making a few Virtual switches or virtual momentary buttons. Name them something appropriate like “Web Caller” or “HTTP Poster”

Next, get HousePanel installed and enable those virtual switches.

Third step is write a script on the rPI that loops and does a HP query API call and nothing else until the switch is on. Once on it should invoke the script you want. The tools Chris mentioned make this step relatively easy.

You won’t be able to poll the SmartThings cloud more than roughly twoce a minute so this technique will not give you instant reapomse. This means it is only useful for non time critical actions.

I decided not to worry about having ST initiate scripts on my Raspberry. I decided to have my sprinkler script remain controlled by cron/time and just added a line to reference a WebCore piston which checks for rain and wind. The piston turns on a single erocm1231 flashed Sonoff which makes the supply voltage to my other 5 4 channel Sonnoffs that are flashed espurna, if conditions are right. It works nicely and gives me the bit of “smart” function I was lacking.

I appreciate all the helpful posts and still intend to look into a few of the suggestions, especially node-red.

How can you create the endpoints? Could those be used with IFTTT? Maybe then I could connect SmartThings via webCoRE to IFTTT.

Found this in a Raspberry Pi group which makes your Pi discoverable as a WeMo device and will allow you to run python scripts but sadly I’ve got no idea how to code in python.

Trying this one out now.

Any luck with this?