You’re trying to set a variable totalMinTillDimStart
by performing maths with this same variable (totalMinTillDimStart - SunriseWakeUpDimFadeInTime
) - does openHAB handle this well? Have you tried using a differently named variable to store the result?
EDIT:
Hmmm, no, that’s not it. I tried the below rule, and it outputs without error:
rule "Test rule1"
when
Item sTestSwitch changed
then
val hours = 7
val minutes = 7
val SunriseWakeUpDimFadeInTime = 35
val totalMinTillDimStart = (hours * 60) + minutes
logInfo("Test","1. totalMinTillDimStart: " + totalMinTillDimStart)
totalMinTillDimStart = totalMinTillDimStart - SunriseWakeUpDimFadeInTime
logInfo("Test","2. totalMinTillDimStart: " + totalMinTillDimStart)
end
Triggering this shows the following in the log:
15:48:55.496 [INFO ] [g.eclipse.smarthome.model.script.Test] - 1. totalMinTillDimStart: 427
15:48:55.513 [INFO ] [g.eclipse.smarthome.model.script.Test] - 2. totalMinTillDimStart: 392
However, when saving the rules file I do get a validation issue in the log:
15:49:03.449 [INFO ] [del.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'test.rules', using it anyway:
Assignment to final variable
EDIT2:
Also worth noting that according to this, val
cannot be re-assigned, whilst var
can. Not sure why the above code worked, then…