Hi,
I am on OH 3.2 on a RPi4 and trying to have a dynamic calculation in a rule.
The rule sets timers individually per Door/Window contact once opened and issues a message to my phone and has Alexa remind me if the door/window has been open for x minutes.
So far I have only managed to set a hard value here like 5 minutes.
However I would like to have this value calculated depending on the outside temperature to set a very short time if it is freezing and longer times during warmer seasons (only up to say 15 °C).

So I came up with following formula but could not find the correct syntax for a variable in a rule:
Basically it should be 2 to the power of (outside temp. divided by 3) and its result rounded down to the next integer.
This gives some progressively rising minute values from 0 upwards.
(WeatherandForecast_OutdoorTemperature.state includes °C so must be first converted to number for the calculation)

I tried the following below but the logs say Math.IntDigit does not exist in Java (I found this in an xtend doc.). And I assume other stuff might be wrong too.

var Timer_Limit = Math.IntDigit ( 2.operator_power ( (WeatherandForecast_OutdoorTemperature.state as QuantityType<Number>).doubleValue/ 3 ) )

Can anyone help me here what the correct mathematical expressions in the rule would be?
Many thanks.

I have exactly this for my roof windows. But I would suggest that you use a separate rule to calculate the time, and then another rule where you use the item previously calculated. That way it is easier to debug.
I’ll try to post my code here, but I’m on the phone so maybe copying it from the shell will look weird…

rule "Adaptive_Window_Open_Time"
when
Item DELTA_TEMP_IN_OUT changed
then
var Number openTime
var Number a
var Number b
if((DELTA_TEMP_IN_OUT.state as Number) > 0.0){
a = 0.0875 * (DELTA_TEMP_IN_OUT.state as Number).doubleValue
b = Math.exp(a.doubleValue)
openTime = 30 - 4 * b
}
else{
openTime = 30
}
AdaptiveOpen.postUpdate(openTime)
//logInfo("math.rules","Recalculated adaptive window opening time to: "
+ openTime)
end

Note that I use an exponential function with empirical constants. It gets really cold in Germany and then you want the window to shut quickly (mine are automated)