This page last changed on May 11, 2013 by simnet.

Hi there,

I have a little question to finish an home automation concept. We have some LUA script or bash script on a linux computer and we need to integrate Openremote macro or command on it.

It's possible to call an Openremote command or macro through the shell ? I have read the REST API but i don't found a procedure to execute a command that is not linked to a design ...

Possible ?

Thanks a lot for your answer.


SMSalert.png (image/png)
Sensor-command.png (image/png)

As far as I recall the REST call to trigger a command is based on the button ID, which would fit to your findings.
You can create a panel though where you don't have any navigation towards it and place the button on that.
Then you should be able to trigger the button (command) through the REST API.

Posted by mredeker at May 12, 2013 11:03

Yes I thought of this solution. But it's not very usefull.
There is no way to execute openremote command through shell ? Like the drools syntax execute.command() ?

Posted by simnet at May 12, 2013 17:55

No. Shell would be an external process which only has access through REST.
Drools is running inside the controller and therefor can execute commands directly.

Posted by mredeker at May 12, 2013 19:29

If you want to execute a command from an external shell, just use the curl command to trigger the REST HTTP call.
I've done it in the past for demo purposes and it does work.

However, you already found one of the limitations that you need to have a (potentially unused) button to trigger a command or macro.
The other issue is that the REST API uses the button id, which is generated when saving the XML/syncing with the controller and will potentially change from one sync to the next.

The ideal solution is to add an additional REST call on the controller that could take e.g. the command name and execute it.
I'm afraid we don't have time to work on this right now, but if you (or somebody else) want to take a shot at implementing it, I'm happy to point you in the right direction.

Posted by ebariaux at May 13, 2013 12:47

Ok thanks.

Yes it can be a very nice solution to integrate Openremote macros with Crestron or other home automation system.

We look in our side how we can help you on this development.


Posted by simnet at May 15, 2013 08:04

FYI: we do support a close integration with AMX control systems for the Pro version.

What other system were you thinking about ?

Also, a closer integration with Crestron could be nice.

Posted by ebariaux at May 15, 2013 13:04

Hello team,

I'm now starting with rule programming. The first one I have tried was a rule that execute a bash script after an event happens (for example light status on). The problem I had was the script never runs. I have added a sentence to check if the rule works, sending a message to the log when the lights goes on, and it worked fine, but the script doesn't run. I have tested the script solely and work fine.
I have tried this rule in two ways, putting the script name in the execute.command sentence (execute.command ("script name with entire path"), other way was creating a command type "shell executing protocol" and calling it from the execute.command in the rule.
Have somebody any idea why this happens?
I have created a new device called ShellExecution and have added a command type "Shell execution protocol" pointing to my bash script. I have created a button with this command and didn't work either.

The script I have created is like this (echo "message" | gokii --sendsms "phone number"). I have a gsm module connected in the USB port of my raspberry-pi and I use gnokii to send SMS messages. The idea is (if finally the rule works) to add a door sensor and send alerts when door is open.

Thanks in advance

Abraham Martin

Posted by abrmartin at Sep 30, 2013 20:53

If the script doesn't execute even from a button then there's something wrong with the inter-process communication. I'd leave the rules out of it for now and just try to get the button to work first. It may be a permission issue – at the moment I can't think of other reasons why the button would fail to execute a script. Unless there are some specific errors in the logs.

Posted by juha at Oct 02, 2013 11:42

Hello Juha,

As I see in another forum I have added a SHELL command log in the log4j.. configuration file and I have no error messages from the shell execution: Here you are the output:
" DEBUG 2013-10-02 16:40:01,012 (Shell): Will start shell command: /home/pi/.config/gnokii/mensajes/ and use params: null
DEBUG 2013-10-02 16:40:01,075 (Shell): Shell command: /home/pi/.config/gnokii/mensajes/ returned:
DEBUG 2013-10-02 16:41:01,004 (Shell): Found cached ShellExe command with id: 480 "

I cant't understand why the result of the shell doesn't work. I have no SMS received in my mobile, but it seems to be executed correctly.

If you have any idea to test, it will be very appreciated.


Posted by abrmartin at Oct 02, 2013 15:49

Reading in another forum I have seen a problem like mine and the solution given was to create a new sensor type=custom and add the command that uses the "Shell execution protocol". After that I have an error in the shell.log file (I have no rule created only the sensor with the shell). The output is :

" DEBUG 2013-10-02 20:40:01,017 (Shell): Shell command: Rr returned:
DEBUG 2013-10-02 20:41:01,003 (Shell): Found cached ShellExe command with id: 484
DEBUG 2013-10-02 20:41:01,004 (Shell): Will start shell command: Rr and use params: null
ERROR 2013-10-02 20:41:01,012 (Shell): Could not execute shell command: Rr Cannot run program "Rr": error=2, No such file or directory
at java.lang.ProcessBuilder.start(
at java.lang.Runtime.exec(
at java.lang.Runtime.exec(
at org.openremote.controller.protocol.shellexe.ShellExeCommand.executeCommand(
at org.openremote.controller.protocol.shellexe.ShellExeCommand.send(
at org.openremote.controller.model.Command.execute(
at org.openremote.controller.model.Command.execute(
at org.openremote.controller.statuscache.CommandFacade.command(
at org.openremote.controller.statuscache.CommandFacade.command(
at org.openremote.controller.model.event.Rule_TurnLightOff_0.defaultConsequence(
at org.openremote.controller.model.event.Rule_TurnLightOff_0DefaultConsequenceInvoker.evaluate(
at org.drools.common.DefaultAgenda.fireActivation(
at org.drools.common.Scheduler$ActivationTimerJob.execute(
at org.drools.time.impl.JDKTimerService$
at org.drools.time.impl.JDKTimerService$
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(
at java.util.concurrent.ScheduledThreadPoolExecutor$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
Caused by: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(
at java.lang.ProcessImpl.start(
at java.lang.ProcessBuilder.start(
... 20 more
DEBUG 2013-10-02 20:41:01,019 (Shell): Shell command: Rr returned:
DEBUG 2013-10-02 20:41:14,438 (Shell): Found cached ShellExe command with id: 480
DEBUG 2013-10-02 20:41:14,448 (Shell): *** setSensor called as part of EventListener init *** sensor is: Sensor (Name = 'SMSAlert Sensor', ID = '3069850', State Mappings: {})"

The message "No such file or directory" I suppose is the key in this problem, but I don't know why it happens.


Posted by abrmartin at Oct 02, 2013 19:48

It could be that the openremote controller is started with a user that does not have exec rights on your shell script.

Posted by mredeker at Oct 02, 2013 19:52

I have reviewed the rights that the script has and it seems to be ok. Here you are a snapshot:

pi@openremote ~/.config/gnokii/mensajes $ ls -la
total 12
drwxr-xr-x 2 pi pi 4096 sep 29 00:34 .
drwxr-xr-x 3 pi pi 4096 sep 28 14:34 ..
-rwxr-xr-x 1 pi pi 84 oct 2 16:31



Posted by abrmartin at Oct 02, 2013 22:06

Your log says:

 Shell command: Rr returned: 

But your command is
It looks like your Button/Rule is triggering the wrong command or you have specified the wrong command path in the protocol.

Posted by mredeker at Oct 02, 2013 22:32

The command I have created is the next:

I have added the entire path to the command.

And the scrip is :


echo "Alert: lights on" | gnokii --sendsms 999999999

Posted by abrmartin at Oct 03, 2013 18:56

1. Your command should be /bin/sh
2. Your command parameter should be /path/
3. Inside the path to gnokii should be specified.

Posted by aktur at Oct 03, 2013 19:55

Something seems to be wrong at anywhere. I have deleted the command SMSalert and in the log appears the same error massage as before, pointing to the path given in the shell execution protocol attributes. I have checheck the time and are new entries to the log, not old ones. I can't understand why this happens if the command doesn't exist.
I have rebooted the raspberrypi and now the OR has installed other configuration that isn't the actual I have in the Designer. It's like the system store the configuration and didn't refresh after presing the command "Sync with online designer"

Is there a cache to clear? The command "Reload configuration and clear cache" I can't use because it returns me the error "failed to reload configuration and clear cache"


Posted by abrmartin at Oct 03, 2013 20:37

Is there a way to flush memmory after rule creation. After some modifications in the Designer, log continue showing the configuration as it was before the change. I have to reboot my raspberry to apply new changes.

Posted by abrmartin at Oct 03, 2013 21:49

Hi Michal,

When you write: "your command should be: /bin/sh" are you refering to the path?


Posted by abrmartin at Oct 03, 2013 21:56

Hi Michal,

With your suggestion and appliying the information I asked in my last post finally it works. Great!. I have spent more than two week with this issue. I have not solved yet how to say gnokii to send a message when the command is executed by OR, but now I have the certaninty that the scipts runs.

Thanks to everybody that help me with this problem.


Posted by abrmartin at Oct 03, 2013 23:24

Once solved the problem related with the Shell execution in rules I have the next issue related with rule scripting. Why the next rule works?

package org.openremote.controller.model.event

global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;

import org.openremote.controller.protocol.*;


rule "TurnLightOff"

timer (cron: 1 * * * * ?)


eval (true)


execute.command ("SMSalert") ;


and this one doesn't:

package org.openremote.controller.model.event

global org.openremote.controller.statuscache.CommandFacade execute;
global org.openremote.controller.statuscache.SwitchFacade switches;
import org.openremote.controller.protocol.*;

rule "Send Alert SMS" when

Event ( source == "Fibaro2-Luces_pasillo", value == "on" )


execute.command ("SMSalert");


"Fibaro2-Luces_pasillo" is a sensor with two possible values on/off

Thanks again.

Abraham Martín

Posted by abrmartin at Oct 06, 2013 05:44

Is that sensor of type:switch ?

Posted by pz1 at Oct 06, 2013 08:00

Yes, it is a type:switch sensor

Posted by abrmartin at Oct 07, 2013 08:11

Sorry, that the only thing that came up to my mind, except for checking once more if there isn't a typing error in the sensor name.
PS: For better readability enclose your rules within {code}..{code} tags(see markup instructions). Do not place a / inside the end tag. That makes the rules easier to read, which increases your chances to get an answer

Posted by pz1 at Oct 07, 2013 08:19

I just created a rule type:custom and worked fine. I don't know why but it worked!

Posted by abrmartin at Oct 07, 2013 08:54

There is something funny with this switch sensor. It is described as boolean, but has as values on and off instead of false/true what I would expect. Did you add any custom state items in the screen? If so which pairs did you enter?

Posted by pz1 at Oct 07, 2013 09:03

No, I haven't added nothing special. I only created a new sensor type:custom and added the same command that sensor type:switch had.


Posted by abrmartin at Oct 07, 2013 12:36
Document generated by Confluence on Jun 05, 2016 09:41