[Solved] Rule - Timer - error reschedule not member of TimerImpl

Tags: #<Tag:0x00007fc8f6beaf70>

Issue of the topic
Hi all, I’m trying to use simple timer rule for light management. I’ve read many post in community and now I’ve cretaed this simple rule:

// Timer per gestione accensione automatica luci
var Timer timerlgBoxPiccolo = null
var idLuceBoxPiccolo = "LuceBoxPiccolo"

rule "Luce Box Piccolo"
when
	Item ctPIRBoxPiccolo changed from OPEN to CLOSED
then
	logInfo(idLuceBoxPiccolo, "Start rule")

	if(timerlgBoxPiccolo === null)
	{
		logInfo(idLuceBoxPiccolo, "Timer create")
		sendCommand(lgBoxPiccolo, ON)
		timerlgBoxPiccolo = createTimer(now.plusSeconds(120), [ |
			sendCommand(lgBoxPiccolo, OFF)
			timerlgBoxPiccolo = null
			logInfo(idLuceBoxPiccolo, "Timer end")
		])
		logInfo(idLuceBoxPiccolo, "Timer created")
	}
	else
	{
		logInfo(idLuceBoxPiccolo, "Timer reschedule")
		sendCommand(lgBoxPiccolo, ON)
		timerlgBoxPiccolo.reschedule(now.plusSeconds(120))
	}
	logInfo(idLuceBoxPiccolo, "end rule")
end

It runs (with a significanty delay from PIR movement detection and light on) but I’m getting this error in log:

2020-03-16 00:55:50.484 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Start rule
2020-03-16 00:55:50.491 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer create
2020-03-16 00:55:50.552 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer created
2020-03-16 00:55:50.561 [INFO ] [marthome.model.script.LuceBoxPiccolo] - end rule
2020-03-16 00:56:06.343 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Start rule
2020-03-16 00:56:06.353 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer reschedule
2020-03-16 00:56:06.361 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Luce Box Piccolo': 'reschedule' is not a member of 'org.eclipse.smarthome.model.script.internal.actions.TimerImpl'; line 436, column 3, length 50
2020-03-16 00:57:50.524 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer end

I’ve done some tests and a lot of search in community but I’m not able to figure out what is the problem.
Thanks for any hints.
f

* Platform information:
Overall: openHAB 2.2.0-1 (Release Build) - OpenHabIan

* Hardware: Raspberry Pi 3 Model B Rev 1.2
* OS: Raspbian GNU/Linux 9 (stretch) - Kernel Linux 4.9.59-v7+
* Java Runtime Environment:
	openjdk version "1.8.0_152"
  OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8.0_152-b76)
  OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, mixed mode, Evaluation)
* openHAB version: openHAB 2.2.0-1 (Release Build) - OpenHabIan

Nothing obvious amiss.

Is your global declaration (the var Timer .. line) in the head of your rule file, before any other rules?

Is your rule file being loaded successfully (look in openhab.log) or is an older copy of the rule still running?

Is the rule "name" unique, system-wide?

A copy-paste works for me

2020-03-16 11:17:57.964 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'doors.rules'
2020-03-16 11:21:06.254 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Start rule
2020-03-16 11:21:06.255 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer create
2020-03-16 11:21:06.257 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer created
2020-03-16 11:21:06.258 [INFO ] [marthome.model.script.LuceBoxPiccolo] - end rule
2020-03-16 11:21:46.578 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Start rule
2020-03-16 11:21:46.579 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer reschedule
2020-03-16 11:21:46.581 [INFO ] [marthome.model.script.LuceBoxPiccolo] - end rule
2020-03-16 11:23:46.581 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer end
2020-03-16 11:25:20.872 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Start rule
2020-03-16 11:25:20.873 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer create
2020-03-16 11:25:20.876 [INFO ] [marthome.model.script.LuceBoxPiccolo] - Timer created
2020-03-16 11:25:20.877 [INFO ] [marthome.model.script.LuceBoxPiccolo] - end rule
1 Like

Dear rossko57 thank you very much, your hints has opened a new way in my mind.
I’ve removed the rule from the single file that i was using and I’ve created a new file limiting copy/paste and changing variables and rules names.

Then i’ve stopped OH, changed the rules files; at the end I’ve cleaned the OH cache deleting the directories (Clear the Cache).

After restarting (and waited the startup time) the rules are running ok.
Thanks again.
f

Just for completion, this is the new rules file.

// Timer per gestione accensione automatica luci

var Timer timer4lgBoxPiccolo = null
var Timer timer4lgBoxGrande = null
var String idtimer4lgBoxPiccolo = "timer4lgBoxPiccolo"
var String idtimer4lgBoxGrande = "timer4lgBoxGrande"

rule "Luce_Box_Piccolo"
when
	Item ctPIRBoxPiccolo changed from CLOSED to OPEN
then
	logInfo(idtimer4lgBoxPiccolo, "Start rule")
	if(timer4lgBoxPiccolo === null)
	{
		sendCommand(lgBoxPiccolo, ON)
		timer4lgBoxPiccolo = createTimer(now.plusSeconds(120), [ |
			sendCommand(lgBoxPiccolo, OFF)
			timer4lgBoxPiccolo = null
			logInfo(idtimer4lgBoxPiccolo, "Timer end")
		])
		logInfo(idtimer4lgBoxPiccolo, "Timer created")
	}
	else
	{
		timer4lgBoxPiccolo.reschedule(now.plusSeconds(120))
		logInfo(idtimer4lgBoxPiccolo, "Timer reschedule")
	}
	logInfo(idtimer4lgBoxPiccolo, "end rule")
end

rule "Luce_Box_Grande"
when
	Item ctPIRBoxGrande changed from CLOSED to OPEN
then
	logInfo(idtimer4lgBoxGrande, "Start rule")
	if(timer4lgBoxGrande === null)
	{
		sendCommand(lgBoxGrande, ON)
		timer4lgBoxGrande = createTimer(now.plusSeconds(120), [ |
			sendCommand(lgBoxGrande, OFF)
			timer4lgBoxGrande = null
			logInfo(idtimer4lgBoxGrande, "Timer end")
		])
		logInfo(idtimer4lgBoxGrande, "Timer created")
	}
	else
	{
		timer4lgBoxGrande.reschedule(now.plusSeconds(120))
		logInfo(idtimer4lgBoxGrande, "Timer reschedule")
	}
	logInfo(idtimer4lgBoxGrande, "end rule")
end

1 Like