Hi all,
I need to convert an Item with a UoM to a String without UoM.
Item=10 W/m²
Desired String=“10”
Here is the Item: Number:Intensity WC_PWS_Current_Radiation "Solar Radiation [%.1f %unit%]"
And here is the rule: executeCommandLine("/usr/bin/python3.7","/srv/openhab-conf/scripts/e2.py","2023",now().format(DateTimeFormatter.ofPattern("MM")),WC_PWS_Current_Radiation.state.toString())
The script is expecting a number with just digits but toString() is converting the UoM too.
How can I remove the UoM?
I tried: (WC_PWS_Current_Radiation.state as Number).toString()
but I am still getting the number with it’s unit of measure. [=10 W/m²]
Can someone helps me to find the correct function to convert a number to a string without it’s UoM?
executeCommandLine should convert the primitives to strings for you so there should be no need to call toString(). Furthermore, the intValue is a primitive which doesn’t have a toString() method. So to convert that to a String you’d use either