Sorry for being that stupid but for any reason I didn’t realize what you were trying to say me…
Anyway, now I changed the code according to your explanation and got the following results:
2015-12-01 19:28:15.982 [INFO ] [runtime.busevents ] - Licht_EG_Kueche_CtE received command ON
2015-12-01 19:28:19.167 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, now execute if/else
2015-12-01 19:28:19.302 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:19.357 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, 'else' executed=sendCommand(ON)
2015-12-01 19:28:19.447 [INFO ] [hab.model.script.Blinklicht ON] - Timer executed, rescheduled
2015-12-01 19:28:19.472 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:22.417 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, now execute if/else
2015-12-01 19:28:22.472 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:28:22.502 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, 'else' executed=sendCommand(ON)
2015-12-01 19:28:22.502 [INFO ] [hab.model.script.Blinklicht ON] - Timer executed, rescheduled
2015-12-01 19:28:22.602 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:28:25.502 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, now execute if/else
2015-12-01 19:28:25.502 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:25.947 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, 'else' executed=sendCommand(ON)
2015-12-01 19:28:25.947 [INFO ] [hab.model.script.Blinklicht ON] - Timer executed, rescheduled
2015-12-01 19:28:26.082 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:28.947 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, now execute if/else
2015-12-01 19:28:28.952 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:28:28.977 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, 'else' executed=sendCommand(ON)
2015-12-01 19:28:28.982 [INFO ] [hab.model.script.Blinklicht ON] - Timer executed, rescheduled
2015-12-01 19:28:29.102 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:28:31.982 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, now execute if/else
2015-12-01 19:28:31.982 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:32.012 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, 'else' executed=sendCommand(ON)
2015-12-01 19:28:32.012 [INFO ] [hab.model.script.Blinklicht ON] - Timer executed, rescheduled
2015-12-01 19:28:32.132 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:35.012 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, now execute if/else
2015-12-01 19:28:35.017 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:28:35.052 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, 'else' executed=sendCommand(ON)
2015-12-01 19:28:35.052 [INFO ] [hab.model.script.Blinklicht ON] - Timer executed, rescheduled
2015-12-01 19:28:35.167 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:28:38.052 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, now execute if/else
2015-12-01 19:28:38.052 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:38.082 [INFO ] [hab.model.script.Blinklicht ON] - Timer created, 'else' executed=sendCommand(ON)
2015-12-01 19:28:38.087 [INFO ] [hab.model.script.Blinklicht ON] - Timer executed, rescheduled
2015-12-01 19:28:38.202 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:38.667 [INFO ] [runtime.busevents ] - Licht_EG_Kueche_CtE received command OFF
2015-12-01 19:28:38.782 [INFO ] [.o.model.script.Blinklicht OFF] - timer was !=null, canceled timer
2015-12-01 19:28:38.837 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:28:38.892 [INFO ] [.o.model.script.Blinklicht OFF] - executed=sendCommand(OFF)
2015-12-01 19:28:38.942 [INFO ] [.o.model.script.Blinklicht OFF] - timer=null
2015-12-01 19:28:38.972 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
Just for understanding reasons here again my adapted code with enhanced logging:
var Timer timer = null
rule "Blinklicht ON"
when
Item Licht_EG_Kueche_CtE received command ON
then
if(timer != null)
{
timer.cancel
logInfo("Blinklicht ON", "timer was !=null, canceled timer")
}
timer = createTimer(now.plusSeconds(3))
[|
logInfo("Blinklicht ON", "Timer created, now execute if/else")
if(Licht_DG_Zi3_D.state == ON)
Licht_DG_Zi3_D.sendCommand(OFF)
else
Licht_DG_Zi3_D.sendCommand(ON)
logInfo("Blinklicht ON", "Timer created, 'else' executed=sendCommand(ON)")
timer.reschedule(now.plusSeconds(3))
logInfo("Blinklicht ON", "Timer executed, rescheduled")
]
end
rule "Blinklicht OFF"
when
Item Licht_EG_Kueche_CtE received command OFF
then
if(timer != null) {
timer.cancel
logInfo("Blinklicht OFF", "timer was !=null, canceled timer")
Licht_DG_Zi3_D.sendCommand(OFF)
logInfo("Blinklicht OFF", "executed=sendCommand(OFF)")
timer = null
logInfo("Blinklicht OFF", "timer=null")
}
end
I just checked it again: as soon as the rule is executed my switches receive all commands twice:
2015-12-01 19:28:48.592 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:28:48.732 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command ON
2015-12-01 19:29:04.462 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:29:04.637 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_D received command OFF
2015-12-01 19:29:10.372 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_W received command ON
2015-12-01 19:29:10.532 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_W received command ON
2015-12-01 19:29:11.917 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_W received command OFF
2015-12-01 19:29:12.092 [INFO ] [runtime.busevents ] - Licht_DG_Zi3_W received command OFF
Can you see in that information why all items get the commands twice? Can I provide any further information?