In most of my device handlers, the update() command does various things (e.g. updating device parameters), and it seems inefficient to run it twice. I am currently thinking of adding code to prevent update() running twice, say with 5 seconds, to prevent the double execution.
def updated() {
// Needed because updated() is being called twice
if ( (Calendar.getInstance().getTimeInMillis() - state.updatedDate) < 5000 ) return
/* MY CODE */
//Part of workaround because updated() called twice
state.updatedDate = Calendar.getInstance().getTimeInMillis()
}
Hi. I’ve been trying to use your fix, but I am getting an error saying:
error groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.lang.Long#minus.
Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[class java.lang.Character]
[class java.lang.Number] @line 223 (updated)