Random error can't locate source?

I have this error keeps appearing in my log = I’ve been through the rules files but can’t find anything that might be the cause. Any ideas on how I can find what it causing it?

2018-11-29 07:18:37.357 [ERROR] [model.script.actions.ScriptExecution] - Failed to schedule code for execution.
org.quartz.ObjectAlreadyExistsException: Unable to store Job : 'DEFAULT.2018-11-29T07:18:37.853+01:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: [ | {
  <XFeatureCallImplCustom>.sendCommand(<XStringLiteralImpl>)
} ]', because one already exists with this identification.
	at org.quartz.simpl.RAMJobStore.storeJob(RAMJobStore.java:279) ~[?:?]
	at org.quartz.simpl.RAMJobStore.storeJobAndTrigger(RAMJobStore.java:251) ~[?:?]
	at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:886) ~[?:?]
	at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:249) ~[?:?]
	at org.eclipse.smarthome.model.script.actions.ScriptExecution.makeTimer(ScriptExecution.java:133) ~[?:?]
	at org.eclipse.smarthome.model.script.actions.ScriptExecution.createTimer(ScriptExecution.java:92) ~[?:?]
	at sun.reflect.GeneratedMethodAccessor198.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1085) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeOperation(XbaseInterpreter.java:1060) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._invokeFeature(XbaseInterpreter.java:1046) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.invokeFeature(XbaseInterpreter.java:991) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.invokeFeature(ScriptInterpreter.java:143) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:901) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:864) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:223) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:219) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:219) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:459) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:243) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:219) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter._doEvaluate(XbaseInterpreter.java:446) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.doEvaluate(XbaseInterpreter.java:227) ~[?:?]
	at org.eclipse.smarthome.model.script.interpreter.ScriptInterpreter.doEvaluate(ScriptInterpreter.java:219) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.internalEvaluate(XbaseInterpreter.java:203) ~[?:?]
	at org.eclipse.xtext.xbase.interpreter.impl.XbaseInterpreter.evaluate(XbaseInterpreter.java:189) ~[?:?]
	at org.eclipse.smarthome.model.script.runtime.internal.engine.ScriptImpl.execute(ScriptImpl.java:82) ~[?:?]
	at org.eclipse.smarthome.model.rule.runtime.internal.engine.RuleEngineImpl.lambda$2(RuleEngineImpl.java:345) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]

This is likely to be happening in a timer. It looks like that you are declaring a timer variable twice.
Can you post your rules with timers in them, please?

I’ve stripped out all the timer rules from various rule files = but I can’t see anything odd…

rule "Masterbed TV Power On/Off"
when
    Item masterbed_tv received command
then
    if(receivedCommand == ON) {
    sendCommand(SONYTV, "Masterbed_TV_power_on")
    createTimer(now.plusSeconds(1),  [ |
    sendCommand(SONYTV,"Masterbed_TV_hdmi")
    ])
    }
    else {
    sendCommand(SONYTV, "Masterbed_TV_power_off")
    }
end

rule "Cinema Screen power off"
when 
    Item playroom_screen received command OFF
then
    if(virtual_playroom_screen.state == ON)
    {
    logInfo("TV_Theatre_Rules","Playroom_screen turned off and state is {} so close screen",virtual_playroom_screen.state)
    sendCommand(EPSONPROJECTOR, "Epson_Projector_off")
    sendCommand(SONYAMP,"Sony_AMP_video1")
    createTimer(now.plusSeconds(2),  [ |
    sendCommand(SONYAMP, "Sony_AMP_power_toggle")
    ])
    virtual_playroom_screen.postUpdate(OFF)
    }
    else
    {
    logInfo("TV_Theatre_Rules","Playroom_screen turned off and state is {} do nothing",virtual_playroom_screen.state) 
    virtual_playroom_screen.postUpdate(OFF)
    }
end 


rule "Playroom music off"
when 
    Item playroom_music received command OFF 
then
    if (virtual_playroom_music.state == ON)
    {sendCommand(SONYAMP,"Sony_AMP_video1")
    createTimer(now.plusSeconds(2),  [ |
    sendCommand(SONYAMP, "Sony_AMP_power_toggle")
    ])
    virtual_playroom_music.postUpdate(OFF)  
    }
    else {
    logInfo("TV_Theatre_Rules","Playroom_music turned off and state is {} do nothing",virtual_playroom_music.state) 
    virtual_playroom_music.postUpdate(OFF)   
    }
end


rule "Sonos Alarm M&D"
when 
	Item Sonos_AlarmIsRunning changed from OFF to ON
then
	if (Wakeup_MandD.state == ON)
	{
	logInfo("ALARM","Sonos Alarm Running = {} wake up M&D ", Sonos_AlarmIsRunning.state)
	masterbed_music.sendCommand(ON) 
    createTimer(now.plusSeconds(5),  [ |
    MasterbedwcShutter.sendCommand(UP)
    bedroom_blinds.sendCommand(ON) 
	Lt_Masterbed_Bath_Ceiling.sendCommand(ON)  
	])
	}
  	else
	logInfo("ALARM","Sonos Alarm Running = {} but wakup up MD off no alarm", Sonos_AlarmIsRunning.state)
end

rule "Sonos Alarm Dennis"
when 
	Item Sonos_AlarmIsRunning changed from OFF to ON
then
	if (Wakeup_Dennis.state == ON)
	{
	logInfo("ALARM","Sonos Alarm Running = {} wake up Dennis ", Sonos_AlarmIsRunning.state)
	createTimer(now.plusSeconds(10),  [ |
	dennis_music.sendCommand(ON) 
    Lt_Dennis_Mezz.sendCommand(ON) 
	])
	}
  	else
	logInfo("ALARM","Sonos Alarm Running = {} but wakup up Dennis off no alarm", Sonos_AlarmIsRunning.state)
end

rule "Sonos Alarm Timmy"
when 
	Item Sonos_AlarmIsRunning changed from OFF to ON
then
	if (Wakeup_Timmy.state == ON)
	{
	logInfo("ALARM","Sonos Alarm Running = {} wake up Timmy ", Sonos_AlarmIsRunning.state)
	createTimer(now.plusSeconds(15),  [ |
	timmy_music.sendCommand(ON) 
    Lt_Timmy_Walls.sendCommand(ON) 
	])
	}
  	else
	logInfo("ALARM","Sonos Alarm Running = {} but wakup up Timy off no alarm", Sonos_AlarmIsRunning.state)
end

rule "Wake Alarm Holiday From Calendar"  //every morning 0210 check if day is holiday and then turn off wakeup 
when 
Time cron "0 10 02 ? * MON-SUN"
then
if (Holiday.state == ON)  //should have rev'd a msg from IFTTT 
	{
	sendCommand(Wakeup,OFF)
	logDebug("ALARM","Today is a holiday so Alarm turned off")
	}
else {
	logDebug("ALARM","Today is not a holiday so Alarm left on")
	gMusic?.members.forEach(item,i|createTimer(now.plusSeconds(i*5)) [|sendCommand(item, OFF)]) //turn off all zones in case left on
}
end

rule "Dining room morning rule"
    when
    Item Oc_Dining_Room changed from OFF to ON
    then
    if(tRun === null &&
	vTimeOfDay.state == "MORNING" &&
    Auto_Lt_All.state == ON &&
    Lux.state < 200 ) 
    {
    logInfo("wakeup.rules","tRun = {} vTimeofDay = {} Lux = {} open blinds", tRun, vTimeOfDay.state, Lux.state)
	sendCommand(Lt_Island_Led,ON)
    sendCommand(Lt_Island_Spots,ON)
	gDownstairs_shutters?.members.forEach(item,i|createTimer(now.plusSeconds(i*2)) [|sendCommand(item, UP)
	])
	tRun = createTimer(now.plusHours(12), [|logInfo("wakeup.rules","Timer Off")	
	])
	}
	else{
	logInfo("wakeup.rules","tRun = {} vTimeofDay = {} Lux = {} don't open blinds", tRun, vTimeOfDay.state, Lux.state)
	}
end

Try adding a logInfo inside the timers lambdas
This way you will see which one is causing the problem

Also, you are really inconsistent in using sendCommand(item, command) and item.sendCommand(command)

Use the item.sendCoomand(command) method whenever possible and looking at you code, at first glance, I can see no instance where it can’t be used.

Thanks = I’ll try the loginfo. I’ve found the last timers but they also look normal. I’m slowly converting over to sendCommand…work in progress!

   rule "Masterbed Music"
    when
        Item masterbed_music received command
    then
        if(receivedCommand == ON) {
        sendCommand(YAMAHAAMP, "Yamaha_AMP_power_on")
        createTimer(now.plusSeconds(3),  [ |
        sendCommand(YAMAHAAMP, "Yamaha_AMP_mdcdr")
        ])
        }
        else {
        sendCommand(YAMAHAAMP, "Yamaha_AMP_power_off")
        }
    end

rule  "Shower music"
when Item shower_music received command
then
if(receivedCommand == ON)
    {
    Denon_command.sendCommand("ST06CONT")
    createTimer(now.plusMillis(500),  [ |
    Denon_command.sendCommand("SI05BUSM") 
    ])
    }
else
   {
    Denon_command.sendCommand("SI05AUX")
    if(bathroom_music.state == OFF)
    {
    createTimer(now.plusMillis(500),  [ |
    Denon_command.sendCommand("ST06OFF")
    ])
    }
    else {}
}
end

rule  "Bathroom music"
when Item bathroom_music received command
then
    if(receivedCommand == ON){
        Denon_command.sendCommand("ST06CONT")
        createTimer(now.plusMillis(500),  [ |
        Denon_command.sendCommand("SI06BUSM")
        ])
    }
else
    {
    Denon_command.sendCommand("SI06AUX")
    if(shower_music.state == OFF)
    {
    createTimer(now.plusMillis(500),  [ |
    Denon_command.sendCommand("ST06OFF")
    ])
    }
    else{}
    }
end

rule  "Dennis music"
when Item dennis_music received command
then
    if(receivedCommand == ON){
        Denon_command.sendCommand("ST08CONT")
        createTimer(now.plusMillis(500),  [ |
        Denon_command.sendCommand("SI07BUSM")
        ])
    }
else
    {
    Denon_command.sendCommand("SI07AUX")
    if(timmy_music.state == OFF)
    {
    createTimer(now.plusMillis(500),  [ |
    Denon_command.sendCommand("ST08OFF")
    ])
    }
    else{}
    }
end

rule  "Timmy music"
when Item timmy_music received command
then
    if(receivedCommand == ON){
        Denon_command.sendCommand("ST08CONT")
        createTimer(now.plusMillis(500),  [ |
        Denon_command.sendCommand("SI08BUSM")
        ])
    }
else
    {
    Denon_command.sendCommand("SI08AUX")
    if(dennis_music.state == OFF)
    {
    createTimer(now.plusMillis(500),  [ |
    Denon_command.sendCommand("ST08OFF")
    ])
    }
    else{}
    }
end

rule  "Nell Music"
when Item nell_music received command
then
    if(receivedCommand == ON){
        Denon_command.sendCommand("ST10CONT")
        createTimer(now.plusMillis(500),  [ |
        Denon_command.sendCommand("SI09BUSM")
        ])
    }
else
    {
    Denon_command.sendCommand("SI09AUX")
    if(lily_music.state == OFF)
    {
    createTimer(now.plusMillis(500),  [ |
    Denon_command.sendCommand("ST10OFF")
    ])
    }
    else{}
    }
end

rule  "Lily Music"
when Item lily_music received command
then
    if(receivedCommand == ON){
        Denon_command.sendCommand("ST10CONT")
        createTimer(now.plusMillis(500),  [ |
        Denon_command.sendCommand("SI10BUSM")
        ])
    }
else
    {
    Denon_command.sendCommand("SI10AUX")
    if(nell_music.state == OFF)
    {
    createTimer(now.plusMillis(500),  [ |
    Denon_command.sendCommand("ST10OFF")
    ])
    }
    else{}
    }
end

These music rules are a lot of repeating code:

Let’s try to make this better:
Put the following items in a group called gMusic: shower_music, bathroom_music, dennis_music, timmy_music, nell_music and lily_music

Then only ONE rule:

rule "Generic Music"
when
    Member of gMusic received command
then
    val String room = triggeringItem.name.toString.split("_").get(0)
    val roomCommand = room + receivedCommand.toString
    Denon_command.sendCommand(transform("MAP", "denon.map", roomCommand + "1"))
    createTimer(now.plusMillis(500), [ |
        Denon_command.sendCommand(transform("MAP", "denon.map", roomCommand + "2"))
    ])
end

and a MAP file called denon.map in the transform folder
I only did the codes for the shower but you’ll get the idea and can work out the rest:

showerON1=ST06CONT
showerON2=SI05BUSM
showerOFF1=SI05AUX
showerOFF2=ST06OFF

The only rule that stays the same is the first one. ALL the denon related ones can be condensed into one

1 Like

Thanks that makes a lot of sense! I’ve got lots of rules that that which I think I can tidy up!

You are welcome.
From 132 lines of code to 11!!
For the cost of 1 group item and a simple map file.
If you have problems with condensing other sets of rules send me a PM