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?
I’m not the best with numbers in a rule but maybe this will work.
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
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