ExecuteCommandLine : Passing Python Parameter within Rules

Hi
I am having an issue of passing a python parameter using executeCommandLine within rules. I tried various options ( as you can see below) but it’s not working…When I hard code the parameter value within quotes it works.Can you please let me know where I am going wrong?

rule "Control_Switch_Humidifier"
  when
        Item Humidifier_Threshold received command
  then
       var HT_Val = Humidifier_Threshold
       var string result_threshold = " "
//       results_threshold = "python2 /home/pi/MyWorkplace/Humidifier.py" + "\\ " + Humidifier_Threshold.toString
//       executeCommandLine(result_threshold,5000)
         results_threshold = executeCommandLine("python2 /home/pi/MyWorkplace/Humidifier.py --value" +Humidifier_Threshold.value ,5000)
//         results_threshold = executeCommandLine('python2 /home/pi/MyWorkplace/Humidifier.py' +Humidifier_Threshold+ ,5000)

        Humidifier_Threshold.postUpdate(receivedCommand)
        logInfo("Sendin  Humidity Threshold back to Ardino", result_threshold"..)

Humidifier_Threshold is an Item. That’s a complex object with label, name, group memberships, blah. I expect you are interested in using its state as your parameter, which you would want the string version of.

I tried that option as well. please ref below


results_threshold = "python2 /home/pi/MyWorkplace/Humidifier.py" + "\\" + Humidifier_Threshold.state
       executeCommandLine(result_threshold,5000)

Also, I tried below code but no change in the outcome.

results_threshold = executeCommandLine("python2 /home/pi/MyWorkplace/Humidifier.py --value" +Humidifier_Threshold.state ,5000)

and 
 results_threshold = executeCommandLine('python2 /home/pi/MyWorkplace/Humidifier.py' +Humidifier_Threshold.value+ ,5000)

Try writing the string to the openhab log by using

LogInfo(“label”, string)
It helped me very often to figure out what was going on.

Moreover try with

Item.State.toString

1 Like

Thanks , It worked!

Now I am able to pass the parameter.!