OH2 rule for DHT22 not working in OH3

Hello

i just migrated from OH2 to OH3 and my temp sensor is not working anymore ,

The rules is looking like that :slight_smile:

root@stbserver:/etc/openhab/rules# cat temp.rules
rule “keller_temp”
when
Time cron “0 */1 * * * ?”
then
val TEMP = executeCommandLine("/usr/bin/sshpass","-p","$pass",“ssh”,"-o",“StrictHostKeyChecking=no”,"pi@192.168.1.111","’’/usr/bin/python3","/var/www/rfoutlet/temp.py’’",“5000”)
if (TEMP.toString().length <= 5) tmp_keller.postUpdate(TEMP)
Thread::sleep(5000)
val HUMID = executeCommandLine("/usr/bin/sshpass","-p","$pass",“ssh”,"-o",“StrictHostKeyChecking=no”,"pi@192.168.1.111","’’/usr/bin/python3","/var/www/rfoutlet/hum.py’’",“5000”)
if (HUMID.toString().length <= 5) humidity_keller.postUpdate(HUMID)
logInfo(“Keller”, “Temperatur:” + TEMP.toString() + “°C, Feuchte:” + HUMID.toString() + “%”)
end

In OH 3 i got this error :slight_smile:

2021-08-11 13:23:00.880 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘temp-1’ failed: ‘toString’ is not a member of ‘Object’; line 6, column 6, length 15 in temp

Looks like toString is not recognized anymore …Any idea ?

Thank you !

You seem to have missed the syntax change for executeCommandLine().
If you want a return value (and you do) you must use a timeout … but it goes first, and it’s not a simple number.

Thank you for you answer, do you have an example on my case ?

Thanks !

Changed like this, and is working now !

rule “keller_temp”
when
Time cron “0 */1 * * * ?”
then
var TEMP = executeCommandLine(Duration.ofSeconds(60), “/usr/bin/sshpass”,"-p",“hotsauce”,“ssh”,"-o",“StrictHostKeyChecking=no”,"pi@192.168.1.111","’’/usr/bin/python3","/var/www/rfoutlet/temp.py’’",“5000”)
if (TEMP.toString().length <= 5) tmp_keller.postUpdate(TEMP)
Thread::sleep(5000)
var HUMID = executeCommandLine(Duration.ofSeconds(60), “/usr/bin/sshpass”,"-p",“hotsauce”,“ssh”,"-o",“StrictHostKeyChecking=no”,"pi@192.168.1.111","’’/usr/bin/python3","/var/www/rfoutlet/hum.py’’",“5000”)
if (HUMID.toString().length <= 5) humidity_keller.postUpdate(HUMID)
logInfo(“Keller”, "Temperatur: " + TEMP + "°C, Feuchte: " + HUMID.toString() + “%”)

end

THANK YOU !