mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-11 05:41:52 +01:00
[DSL] Unique job key for createTimer in DSL rule (#972)
Fixes #943 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
a17d63ad64
commit
aebcc6cd9a
@ -44,6 +44,8 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public class ScriptExecution {
|
||||
|
||||
private static int timerCounter = 0;
|
||||
|
||||
/**
|
||||
* Calls a script which must be located in the configurations/scripts folder.
|
||||
*
|
||||
@ -120,7 +122,7 @@ public class ScriptExecution {
|
||||
private static Timer makeTimer(AbstractInstant instant, String closure, JobDataMap dataMap) {
|
||||
|
||||
Logger logger = LoggerFactory.getLogger(ScriptExecution.class);
|
||||
JobKey jobKey = new JobKey(instant.toString() + ": " + closure.toString());
|
||||
JobKey jobKey = new JobKey(getTimerId() + " " + instant.toString() + ": " + closure.toString());
|
||||
Trigger trigger = newTrigger().startAt(instant.toDate()).build();
|
||||
Timer timer = new TimerImpl(jobKey, trigger.getKey(), dataMap, instant);
|
||||
try {
|
||||
@ -137,4 +139,8 @@ public class ScriptExecution {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static synchronized String getTimerId() {
|
||||
return String.format("Timer %d", ++timerCounter);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user