Rule DSL calculation problem

Hello all,

I am currently converting my smart home to Openhab 4.0.

In the living room are 2 heating thermostats installed, which measure the room temperature.
For the display of this temperature and the room control I would like to determine the average temperature.

This I tried with a DSL Rule. The following error occurs.

The temperatures of the individual thermostats are read out correctly (each approx. 22° C).
With addition of the temperatures however values of approx. 600 ° C come out.

can someone tell me how the problem can be solved?

The code of the DSL Rule:

var WZTemp = ((Thermostat_Wohnnzimmer_Ost_Current_temperature.state as Number) + (Thermostat_Wohnnzimmer_Ost_Current_temperature.state as Number))/2
  
postUpdate(MQTT_Wohnzimmer_Durchschnittstemperatur, WZTemp)

kind regards

Johannes Röding

You can use a group item to do that for you. Here’s the documentation for groups.

Note: when you read the documentation, make sure you look at the 4.0 version.

image

if you’re just getting started with openHAB then I recommend building your system in the UI instead of using text files. It’s super easy to make a group item that averages temperatures.

1 Like