I installed openHAB 2 a few days ago to control my 433 Mhz sockets.
Before that i switched them using wiringPi and raspberry-remote, which worked pretty well. So my plan was to execute
using the binding-exec - 1.9.0.SNAPSHOT.
Running the command in Putty it works, but when the exec binding - installed via PaperUI - should do this for me nothing happens. The openHAB 2 log says
but at all it seems doing nothing. I assume exec outputs these as soon as I touch the switch.
I tried some other things like putting the command in a sh file, or just let exec create some file - nothing.
The Exec binding is one of the most difficult ones to get correct and working.
I assume you installed using apt-get?
If so then remember that OH is running under the OH user. Consequently you need to set up this user to have permission to run this command and use any and all resources this script uses.
Sometimes the Exec binding also requires one to replace spaces with @@.
Finally, you never get to see what the script you ran returned in the log. If you want to see what your script is actually returning, in this case the error messages, you need to stop using the Exec binding and instead use a Rule with:
Thank you, your advice helped me a lot!
Yes, I installed using apt-get, the offline edition.
I created a rule with your content - now the openhab.log looks like this:
2016-11-28 11:59:18.163 [INFO ] [.eclipse.smarthome.model.script.Exec] - wiringPiSetup: Must be root. (Did you forget sudo?)
operating in binary mode
using pin 0
just added a sudo in front of the command
2016-11-28 11:59:54.705 [INFO ] [.eclipse.smarthome.model.script.Exec] - sudo: no tty present and no askpass program specified
I added the openhab user to sudo group, but when I try this again the same message appears.
EDIT: I forgot to mention the openhab user should have permissions to run the command.
That error looks like you haven’t configured openhab in sudoers to not require a password for the command. You either need to pass the password as part of the command or configure sudoers to not require the password.
Okay, I the OH user should now be allowed to run the command.
So I tried again and this happened in the log:
2016-11-28 19:22:01.030 [ERROR] [ore.internal.events.OSGiEventManager] - Dispatching/filtering event for subscriber 'org.eclipse.smarthome.core.events.EventSubscriber' failed: unable to create new native thread
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)[:1.8.0_65]
at java.lang.Thread.start(Thread.java:714)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1368)[:1.8.0_65]
at org.eclipse.smarthome.core.common.QueueingThreadPoolExecutor.execute(QueueingThreadPoolExecutor.java:148)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)[:1.8.0_65]
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:185)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:79)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:63)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager.dispatchESHEvent(OSGiEventManager.java:188)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:163)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:146)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415)[3:org.apache.karaf.services.eventadmin:4.0.4]
at org.apache.felix.eventadmin.impl.tasks.HandlerTask.run(HandlerTask.java:90)[3:org.apache.karaf.services.eventadmin:4.0.4]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
2016-11-28 19:22:01.033 [ERROR] [ore.internal.events.OSGiEventManager] - Dispatching/filtering event for subscriber 'org.eclipse.smarthome.core.events.EventSubscriber' failed: unable to create new native thread
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)[:1.8.0_65]
at java.lang.Thread.start(Thread.java:714)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1368)[:1.8.0_65]
at org.eclipse.smarthome.core.common.QueueingThreadPoolExecutor.execute(QueueingThreadPoolExecutor.java:148)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)[:1.8.0_65]
at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous(SafeMethodCaller.java:185)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:79)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.common.SafeMethodCaller.call(SafeMethodCaller.java:63)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager.dispatchESHEvent(OSGiEventManager.java:188)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:163)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.eclipse.smarthome.core.internal.events.OSGiEventManager.handleEvent(OSGiEventManager.java:146)[96:org.eclipse.smarthome.core:0.9.0.201611272028]
at org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:415)[3:org.apache.karaf.services.eventadmin:4.0.4]
at org.apache.felix.eventadmin.impl.tasks.HandlerTask.run(HandlerTask.java:90)[3:org.apache.karaf.services.eventadmin:4.0.4]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
When is the last time OH has been restarted. You shouldn’t be getting out of memory errors regardless, but if there is a memory leak somewhere that would explain the problem and a reboot of OH will clear up the problem, at least temporarily.
Once you confirm that your script works, you should start monitoring your OH to see if it continues to grow in its memory use and create an issue on github.
One has to be very careful to see and understand which version of a binding one is using. All 2.0 version bindings are configured using Things and Channels on those things are mapped to the Items. All 1.9 bindings have no Things and have their configuration defined on the Item as you do above.
So you either need to convert your exec= from above to a Thing as described in the link above or switch to using the 1.9 version of the binding.
I think you will have to experiment to figure this out. The docs for this binding are not yet very detailed. It is a very new 2.0 binding so I’m not surprised.
As a workaround you can try to exec ssh pi@localhost “your command” But you should enable passwordless ssh access to localhost before. In that case you can write sudo without problems. That code is from my configuration: