Check if value Integer or 1 - 2 - 4 - 8 - 16 - 32 iterations


i’m trying to ckeck if value Integer or not.
Check from java do not work in OH. From OH itself i did not found according function.

I see only way to use JS transformation with function inside, but it is not beautiful way that will slow down the rule.

Maybe someone know the better way?

In fact i need to fire a trigger on 1 - 2 - 4 - 8 - 16 - 32 and so on iteration.
for this i use

repeatTimer = (repeatTimer * 2).intValue 
repeatCounter = (repeatCounter + 1).intValue

and if

(repeatTimer / repeatCounter) is Integer

i would fire a trigger.
Maybe someone has alrerady other solution for this.

Thanks a lot!

This is a common interview question for developer positions. There are plenty of solutions on the Internet!