Thank you, @rossko57, for your investigations!
I found out that applying this approach by @psyciknz that you mentioned also solved the issue:
// (1) not working original:
// val Number taupunkt_delta = Taupunkt_Differenz.state as DecimalType
// (2) this already satisfies String::format expression:
// val Number taupunkt_delta = Taupunkt_Differenz.state as DecimalType + 0
// (3) providing a floatValue works as well:
val Number taupunkt_delta = (Taupunkt_Differenz.state as DecimalType).floatValue
var String test = String::format("%.1f °C", taupunkt_delta) // fails for (1)
logInfo("myrule.rules", "test=" + test)
I would prefer (3) because MyItem.state as DecimalType + 0
looks quite odd in the code.
I have used my Taupunkt_Differenz
item for your snippet. The log reads similar to yours
2019-09-16 06:42:37.715 [INFO ] [.smarthome.model.script.myrule.rules] - teststateA=class java.lang.Float
2019-09-16 06:42:37.721 [INFO ] [.smarthome.model.script.myrule.rules] - teststateB=class org.eclipse.smarthome.core.library.types.DecimalType
2019-09-16 06:42:37.728 [INFO ] [.smarthome.model.script.myrule.rules] - A formatted=2,6 °C
2019-09-16 06:42:37.733 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'format state': f != org.eclipse.smarthome.core.library.types.DecimalType
Now I am wondering why this error message does occur in your demo rule but not in my own code…