this block of code executes in an average of 352 ms for each device in list tD
on HE and 19 ms on ST. anything i could do to optimize this for HE?
tD.each {
ifDebug("${now() - time} ms")
def lastEvents
def deviceEventFound = false
for (def x = 1; x < 3; x++) {
def noOfEvents = Math.pow(5, x).toInteger()
if (hT == _SmartThings)
lastEvents = it.events(max: noOfEvents).findAll { it.eventSource == 'DEVICE' && it.date.after(cDT) }
else
lastEvents = it.events(max: noOfEvents).findAll { it.source == 'DEVICE' && it.date.after(cDT) }
if (lastEvents) {
deviceEventFound = true
break
}
}
if (!deviceEventFound) dHC = dHC + (dHC ? ', ' : '') + it.displayName;
}
thank you.