Exec binding python script not executed

Hi there. I have installed the Exec binding and I am trying to run a python script when a switch in openhab is toggled. The python script is “python /home/pi/python/BS_LIGHTOUTPUT.py -p 19 -t 1” which is correct, in this sense that:

  • path is ok
  • it runs correctly in shell with user openhab
  • if I put the command in the openhab paper view between < >, I see an error in the log file that “Openhab cannot find the file” when I toggle the switch.

So to conclude: I am confident that the python script is called when switch is toggled, but not successfully executed.

Is there anything else I can log?
Is my configuration ok?
Maybe I need to insert some logging inside the python file so that I can actually see if it has been run.

What item is you thing linked to?
Can you publish the log?

Hi Vincent, one item is linked to it, a switch:

Logfile is empty, even in debug level. When I put the timeout time on purpose to 0, i see the following error appearing, which confirms the script is correctly called:
log:tail | grep BS_LIGHTOUTPUT.py
21:57:24.718 [DEBUG] [e.osgi.LoggingCommandSessionListener] - Executing command: ‘log:tail | grep BS_LIGHTOUTPUT.py’
22:04:22.964 [WARN ] [hab.binding.exec.handler.ExecHandler] - Forcibly termininating the process (‘python /home/pi/python/BS_LIGHTOUTPUT.py -p 19 -t 1’) after a timeout of 0 ms

If i set the timeout back to 1 sec or higher, nothing is logged that matches BS_LIGHTOUTPUT.py anymore.
When grepping on gpio, i see that the switch "GPIO’ (in openhab panel) is correctly triggered:
22:17:07.484 [INFO ] [marthome.event.ItemStateChangedEvent] - GPIO_Running changed from OFF to ON
22:17:07.487 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ o.e.j.s.h.ContextHandler@ca43b3{/static,null,AVAI LABLE}
22:17:07.490 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.core.audio_0.9.0.b5 [99], contextID=default]}
22:17:07.494 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui_0.9.0.b5 [136], contextID=default]}
22:17:07.496 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.icon_0.9.0.b5 [137], contextID=default]}
22:17:07.498 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=org.jupnp.transpor t.impl.osgi.DisableAuthenticationHttpContext@94b3f9}
22:17:07.506 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.ui.dashboard_2.1.0 [170], contextID=default]}
22:17:07.508 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.basic_0.9.0.b5 [180], contextID=default]}
22:17:07.510 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.eclipse.smarthome.ui.paper_0.9.0.b5 [181], contextID=default]}
22:17:07.516 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=org.openhab.io.net .http.SecureHttpContext@1f1937a}
22:17:07.517 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=org.openhab.io.net .http.SecureHttpContext@6d3f93}
22:17:07.519 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.core_2.1.0 [166], contextID=default]}
22:17:07.523 [DEBUG] [.jetty.server.handler.ContextHandler] - scope null||/rest/items/GPIO_Running @ HttpServiceContext{httpContext=DefaultHttpContext [bundle=org.openhab.ui.habpanel_2.1.0 [191], contextID=default]}
22:17:07.525 [DEBUG] [org.eclipse.jetty.server.Server ] - RESPONSE /rest/items/GPIO_Running 200 handled=true
22:17:07.792 [INFO ] [marthome.event.ItemStateChangedEvent] - GPIO_Running changed from ON to OFF

You need to add some print statements in your python file to check it is running properly.
If there is no error when you put the time out to 1 then it is running, just not doing what you want it to do. Time to debug…