Exec Binding fails to execute python script after update

Hi there,

I migrated to OH3 and now I’m having problems with the call of a python script with an additional parameter. I’d like to set the Volume of my LG-TV via Serial Port (yeah… no smart TV, but it works).

rule "LG Volume"
when
    Item LG_Volume received command
then
    var Number = LG_Volume.state.toString;
    logInfo("lgvolume.rules", "TV Lautstärke gesetzt auf" + Number)
    Thread::sleep(500)
    executeCommandLine("/home/to/fernseher_lautstärke.py " + Number)
end

A similar script to power on / off works. I can also call the script from the command line using “/home/to/fernseher_lautstärke.py 13”, also as user openhab.

However, when openhab tries to invoke the script it fails and the log says:

021-01-24 13:00:28.428 [WARN ] [rg.openhab.core.io.net.exec.ExecUtil] - Error occurred when executing commandLine '[/home/to/fernseher_lautstärke.py 13]'
java.io.IOException: Cannot run program "/home/to/fernseher_lautstärke.py 13": error=2, No such file or directory

It worked before the update and the call seems right. What am I missing? Did anything change hiere?

My python script looks like this, but I suppose the error is somewhere else because calling it from the console works…:

#!/usr/bin/env python

import serial
import sys

ser = serial.Serial(

   port='/dev/LGTV',
   baudrate = 9600,
   parity=serial.PARITY_NONE,
   stopbits=serial.STOPBITS_ONE,
   bytesize=serial.EIGHTBITS,
   timeout=1
)
temporaer = hex(int(sys.argv[1]))
temporaer2 = temporaer.replace("0x","")
ser.write('kf 01 %s\r'%(temporaer2))

Thanks for your support!

Yes, there are quite a few threads in this forum about new syntax for OH3 for executeCommandLine(), as well as the breaking changes release notes.

Oh, missed the breaking change there. Thank you!
The thread you linked is helpful in the end (however people are trying stuff not working).

I solved it like this:

    var Number = LG_Volume.state.toString;
    val cmnd = "/home/to/fernseher_lautstärke.py " + Number
    executeCommandLine(cmnd.split(" "))

This works for me again. :slight_smile: