Error in rules file

Hello,

I’m trying to setup a automated rule to get the price and calculate the total value of my rdd.
The only thing that isnt working is the calculation part, i get this error:

[ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘rdd’: For input string: “0.00631479”

This is my rule:

rule "rdd"

        when
                Time cron "0 0/1 * * * ?"
        then

        var String HTTPString = "https://api.cryptonator.com/api/ticker/rdd-usd"
        var  jsonString = HTTPString.sendHttpGetRequest(10000)
        var valusd = transform("JSONPATH","$.ticker.price",jsonString)
        logInfo("RDD Value is $",valusd)

        var amount = 18792.4;
        var aantal = amount.toString()
        logInfo("Total amount $",aantal)

        var prijs = Integer::parseInt(valusd.toString)
        var Number totval = amount*prijs
        logInfo("Total wallet value: $",totval.toString)
        rdd.sendCommand(prijs)
        rddown.sendCommand(aantal)
        rddval.sendCommand(totval)
end

Help would be appreciated

looks wrong for me because Number is a complex Item not a “number/integer”

Try:

var Integer totval = amount*prijs

or

logInfo("Total wallet value: ", amount*prijs)
rddval.sendCommand(amount*prijs) //if rddval is a number item

I think valusd is a string “0.00631479” with a float value and

var prijs = Integer::parseInt(valusd.toString)

crashed.

Please put more debug log after every line to see which line is the crashing line.

I do it in a different way by using the http binding.

Number Bitcoin  "Bitcoin: [%.2f BTC]" 	{ http="<[https://apiv2.bitcoinaverage.com/indices/global/ticker/short?crypto=BTC&fiat=EUR:3600000:JSONPATH($.BTCEUR.last)]" }

This will give me a Number item directly. Then you have to do some math after Item changed event.

So what would u suggest to change?

removed

What’s about

=Float::parseFloat(

I managed to fix it!

i used

=Float::parseFloat(

and adjusted the logInfo

thank you to both of you :stuck_out_tongue: