var Timer timerAlarm = null
rule "Alarm Clock"
when
Item AlarmClock changed
then
if (newState instanceof DateTimeType) {
val epoch = newState.toLocaleZone.zonedDateTime.toInstant.toEpochMilli
logInfo("alarm", "Scheduling alarm for {} ({})", newState.toLocaleZone, epoch)
if (timerAlarm !== null) {
logInfo("alarm", "Reschedule alarm")
timerAlarm.reschedule(newState.toLocaleZone.zonedDateTime)
} else {
logInfo("alarm", "New alarm")
timerAlarm = createTimer(newState.toLocaleZone.zonedDateTime, [ |
// Turn on stuff, e.g. radio or light
logInfo("alarm", "Alarm expired")
timerAlarm = null
])
}
} else {
if (timerAlarm !== null) {
timerAlarm.cancel
timerAlarm = null
}
logInfo("alarm", "Alarm canceled")
}
end
Error into log:
An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.ScriptExecution.createTimer(org.joda.time.base.AbstractInstant,org.eclipse.xtext.xbase.lib.Procedures$Procedure0) on instance: null
Do you have any imports? There is nothing obviously wrong with that rule and there is no direct reference to org.eclipse.smarthome.model.script.actions.ScriptExecution.