How to present temperature difference of two sensors

Hi,

I am very new to OpenHAB 2 and want to create my first rule but need some help.
I have a greenhosue with two temperature sensors. One is inside and the other one is outside.
Now I want to present the temperature values of both sensors and additionally the temperature difference.

The temperature values I already can show just by using the item and it’s value (no rule needed). But how to show the temperature difference? Can someone give me a hint how to do that?

Thanks…

One of many solutions could be:
Create a virtual TempDiff_Proxy item, not bound to any channels, then a rule with variables, calculate the difference and postUpdate to that virtual item:

rule "temp diff"
when
	Item TempIn received update or
	Item TempOut received update
then
	var Number tempinside = TempIn.state as DecimalType
	var Number tempoutside = TempOut.state as DecimalType
	var Number tempDiff = 0
	tempDiff = (tempoutside-tempinside)
	TempDiff_Proxy.postUpdate(tempDiff)
1 Like

Hi sihui,

sorry for replying so lately - finally I found some time to test your suggestions.

It works - thanks a lot!