# Calculating with temperatures

I tried this rule:

val Number Solltemperatur = 23 |°C
val Number Hysterese = 1 |°C
var Number Temperatur
rule “Heizung”
when
Item Buero_Bewegungsmelder changed
then
Temperatur = Solltemperatur + Hysterese
logInfo(“Heizung”, “Temperatur ist = {}” , Temperatur)
if (Buero_Klima_Innentemperatur.state <= Solltemperatur + Hysterese){
logInfo(“Heizung”, “Die Klima Innentemperatur ist <= 23°C”)
}
if (Buero_Klima_Innentemperatur.state > Solltemperatur){
logInfo(“Heizung”, “Die Klima Innentemperatur ist > 23°C”)

}
end
The log result for Temperatur ist : 570,30. It seams that there ist a conversion from °C to °K
How could I avid this conversion and get the right result?

How is the item defined? Are you using `Number:Temperature `?

Also, make sure your country and region are set.

The item is Number:Temperature.
Country and region are set properly.

I reduced the problem:

``````val Number Solltemperatur = 23 |°C
val Number Hysterese = 1 |°C
var Number Temperatur
rule "Temperatur"
when
Item Buero_Bewegungsmelder changed
then
Temperatur = Solltemperatur + Hysterese
end
``````

The log result for Temperatur ist : 570,30
Is there a possibility to calculate mit temperatures getting the expected result 24°C ?

But how is the Item defined? Please provide the line form an .items file or screenshot from Paper UI.

I have found a solution: Defining the variables and constants as numbers makes it possible to calculate with them correctly. Comparing them with an Number:Temperature item in an if clause is possible if the value of the item is transformed to an floatValue or intValue as in the example below.

``````val Number Solltemperatur = 23
val Number Hysterese = 1
var Number Temperatur
rule "Heizung"
when
Item Buero_Bewegungsmelder changed
then
Temperatur = Solltemperatur + Hysterese