[SOLVED] String formatting in a rule of numbers

I’ve got a description value I’m trying to create
heating_morning_description.postUpdate(String::format("Morning: Time on: %s Time off: %s Max Temp: %1s °C",heating_morning_time_on.state,heating_morning_time_off.state,max))

max is a var Number (only done because leaving just the item .state or putting item .state as DecimalType wouldn’t work.
So as it stands, the max value in the description becomes: 18.199999999999985 °C
I’d like to push that down to 1 decimal place.

I’ve tried Max Temp: %f and get f != org.eclipse.smarthome.core.library.types.DecimalType
I’ve tried Max Temp: %d and get d != org.eclipse.smarthome.core.library.types.DecimalType

Where am I going wrong?

Ahh I got it, I changed the definition of max from
var Number max = ((heating_morning_maximum_setpoint.state) as DecimalType)

var Number max = ((heating_morning_maximum_setpoint.state) as DecimalType).floatValue

and it worked as now it’s a float. I would have thought that DecimalType was already a float type


float is a decimal type - and integer is also…

Thx, worked for me too :+1: