Cast problem Rain mm/h to float

Rain is defined like

Number:Speed        weather_current_rain                "Regen"

if I use following query

	if (weather_current_rain.state > 0.05 | "mm/h" ) 

it’s working like expected.

Due to the fact that a huge number of decimal places are shown in .state I would like to cast 0.01570000125600000 to 0.016 or 0.015 for output

I tried the following:

		var String Ausgabe = String::format("%.2f", (weather_current_rain.state as DecimalType).floatValue())

unfortunately I get following error:

 Could not cast 0.016000012800000 mm/h to org.eclipse.smarthome.core.library.types.DecimalType; line

If I use the same for temperature it’s working without problem. What is wrong?

Got it:

just change to:

		var String Ausgabe = String::format("%.2f", (weather_current_rain.state as QuantityType).floatValue())

it*s working.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.