I did a search but really did not find anything. I apologize in advance if I missed it somewhere. I am new to SmartThings but am a heavy Linux user and use various bash scripts on a Raspberry PI to control my sprinkler system.
Is there any way I can run such scripts with SamrtThings?
I have been trying to figure out how to do this for the longest time. The only way that I have found to be able to do this is very, VERY complicated. So, Iâm just going to run through it at the Readerâs Digest level.
Hardware: You have to have an Android device that will stay at home and connected to your network at all times.
You need SharpTools to integrate with ST (yes, you will need the paid version)
You need Tasker for your Android device.
You need the SharpTools plugin for Tasker and one of the SSH plugins for tasker.
You then set it up so that when one of your ST devices changes to whatever you want, the SSH plugin in tasker executes the command on your Pi. This is WAAAAY too much trouble IMHO, so I havenât really done anything with it beyond testing. There are just so many failure points that it is going to be very error-prone. If you anre controlling your sprinklers with your Raspberry Pi, You might want to look at something like WebIOPi to integrate with ST. You could have a GPIOâs state set by WebIOPi and have whatever is controlling your sprinklerâs respond to the state of the pin. That way you wouldnât have to wire anything differently. It would mean youâd have to modify whatever was controlling the sprinklers to trigger of GPIO state. if you find an easier way to execute the scripts, please post back cause Iâm very interested to hear.
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.â
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:
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.
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.
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.
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.