[SOLVED] Rule with HTTP Actions

Dear all

I’m trying to set up a rule with a http action. I looks as follows:

rule "PV"
when 
	Time cron "0/5 * * 1/1 * ? *"
then
 	val csv = sendHttpGetRequest("http://192.168.178.140/realtime.csv").split(";")
 	val Temp = csv.get(12).trim
    PV_Temp.sendCommand(Temp/100)
end

However I get the following error in the log:

[ERROR] [untime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'PV': Unknown variable or command '/'; line 8, column 25, length 8

I guess that the val Temp has not the right format. But how can I convert Temp in a floatValue?

thank you in advance for your help

Best regards
Rolf

I’m not the best with numbers in a rule but maybe this will work.:crossed_fingers:

rule "PV"
when 
	Time cron "0/5 * * 1/1 * ? *"
then
 	val csv = sendHttpGetRequest("http://192.168.178.140/realtime.csv").split(";")
 	val Temp = csv.get(12).trim
        var nTemp = Temp / 100
    PV_Temp.sendCommand(nTemp)
end

or

rule "PV"
when 
	Time cron "0/5 * * 1/1 * ? *"
then
 	val csv = sendHttpGetRequest("http://192.168.178.140/realtime.csv").split(";")
 	val Temp = csv.get(12).trim
        var nTemp = ((Temp.state as QuantityType<Number>).doubleValue) / 100
    PV_Temp.sendCommand(nTemp)
end

Dear all

I found the solution:

rule "PV"
when 
	Time cron "0/5 * * * * ? *"
then
    logInfo("Sollvorlauftemperatur.rules", "ACHTUNG d: {}")
 	val csv = sendHttpGetRequest("http://192.168.178.140/realtime.csv").split(";")
 	val Temp = Float::parseFloat(csv.get(12).trim)
        PV_Temp.sendCommand(Temp/100)
end

Thank you anyway.

Best regards
Rolf

Glad you got it working.:+1:

Tick the square box on the post with the solution and I’ll edit the title to start with [Solved]. Maybe this will help others find a quick solution.

Thanks