Syntax of transforming temperature items

I have temperature items of type: number:temperature
Before using them in rules they have to be transformed to a number like this:

(TemperatureItem.state as number).floatValue

I try to understand the syntax. As far as I know items are objects and there are methods that can be applied like TemperatureItem.state.toString. So TemperatureItem.state.floatValue or TemperatureItem.toNumber or something like this would be logical to me and I don’t understand the “as number” syntax. Is it because there is no direct method like .toNumber for a number:temperture item to transform to a pur number?
Can someone explain the Transformation syntax to me or where to find an explanation?

That’s right. The state of a Number:Temperature Item will be something like 10°C, it is a quantity and the units are part of the state. 10°C is the same as 50°F is the same as 283K. If you get “just the number”, should you expect 10 or 50 or 283?
There are ways to work with quantities without guessing or hoping -

1 Like