Rule - just triggering once per second

Hello,

I use the Modbus-Binding, where the Items are polled every 3 seconds. In case of a user input the Items should be polled more freqently. I also use group-switches where a lot of items change their state, where I also would like that the refresh data procedure should also be called also once, but I have some troubles to realize this.
Here is my code:

import org.eclipse.xtext.xbase.lib.Procedures
import org.eclipse.smarthome.core.types.RefreshType

var Timer lockRefreshC1 = null
var long lastExecution

val Procedures$Procedure0 refreshDataC1 = [ |
// All data things in the poller coils are refreshed
lightAccountingRoom1.sendCommand(RefreshType.REFRESH)
return null
]

rule “Refresh modbus coils data quickly after changing settings”
when
Item lightAccountingRoom1 received command or
…some more Items
Item lightGarageCellar1 received command
then
if (receivedCommand != RefreshType.REFRESH) {
/*
// Update more frequently for a short while, to get
// refereshed data after the newly received command
if(lockRefreshC1==null) {
lockRefreshC1 = createTimer(now.plusSeconds(1)) [|
lockRefreshC1 = null // reset the timer
]
refreshDataC1()
createTimer(now.plus(100), refreshDataC1)
createTimer(now.plus(200), refreshDataC1)
createTimer(now.plus(300), refreshDataC1)
createTimer(now.plus(500), refreshDataC1)
}
else {
return;
}*/
// Update more frequently for a short while, to get
// refereshed data after the newly received command
if(lastExecution==null) {
lastExecution = now.millis
}
if(now.millis>=(lastExecution+500)) {
logWarn(“myLog”, “refreshData”)
lastExecution = now.millis
refreshDataC1()
createTimer(now.plus(100), refreshDataC1)
createTimer(now.plus(200), refreshDataC1)
createTimer(now.plus(300), refreshDataC1)
createTimer(now.plus(500), refreshDataC1)
}
else {
lastExecution = now.millis
}
}
end