I’m working with the latest stable version of OH and I’m trying to setup a timer to turn off my sprinklers after a variable delay period.
The period is based on the current temperature (from the ‘Number Day1AirTemperature’ item in the BOM plugin). After lots of testing I’ve got to this point:
var int current_temp = 0
var int delay = 0
current_temp = Day1AirTemperature.state
delay = current_temp / 10
This gives an error on the last line of code above:
Could not invoke method: org.eclipse.xtext.xbase.lib.IntegerExtensions.operator_divide(int,int) on instance: null
Now I’m not sure what object this is referring too since it’s an expression, so I’m not sure what is ‘null’.
This is all very odd because ‘current_temp’ and ‘10’ both appear to be integers, so I though I’d add this line to test the type the variable.
logInfo(“my.rules”, “Type of current_temp =’”, typeof(current_temp), “’”)
Running this rule gives the error:
[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Test’: current_temp
So it seems that you can’t get the typeof a variable…
What am I missing?