Exec Won't Accept Number Item

I’m running an Exec thing that executes a curl command and returns only decimal numbers (ex: 62.3). There are no weird trailing spaces or anything, just the numbers and decimal point. When I create a corresponding item, I can create a String item without problem, but then the .state is a string and I have to use Double::parseDouble to use it in rules. When I change the item type to Number, it errors out (no specific logged errors, it just will not update the item). What am I doing wrong?

Edit: This seems to be a known issue: https://github.com/openhab/openhab2-addons/issues/2149
Is there a workaround?

For this reason you have to create a Dummy-Item (Type:Number). And in the the Rule you have to adress the Dummy, like in my example below.

rule "OpenhabPi Temperature String to Number"
    Item CPU_Temp changed
    CPU_Temp_num.postUpdate(Float::parseFloat(String::format("%s",CPU_Temp.state).replace(' ','')))

where I changed the String-Item “CPU_Temp” to Number-Item “CPU_Temp_num”. That’s it.:wink:

1 Like