Eliminating redundant device events

Hi

I have started on a driver [BETA] IKEA TRADFRI Shortcut Button.

I am having trouble with the button sending multiple ZigBee (cluster 0x0006) messages at every push. The parse() method is activated 3 times within ~10ms.

Do you have any suggestions how to eliminate the redundant events without synchronization or mutex available? The messages happen within too short a timespan to use state or device.eventsSince().

Thanks,
Martin

Use something like now() to calc the time elapsed after the last event. If the difference is less than 20 ms: Ignore the new event.

Or just wait it out, e.g.:

@Field static Boolean isParsing = false

def parse(...) {
if (isParsing) return
isParsing = true

// do your things here, e.g. fire sendEvent

pauseExecution 20 //ms
isParsing = false
}

2 Likes

Thanks, I went with the latter suggestion.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.