Toggling RGB scripts with Fibaro Dimmer (FGD211) S2 doesn't work as expected

For the last four hours, I’m trying to toggle my RGB leds with the use of PLEG and the 2nd button on my Fibaro Dimmer (FGD211), but it still not works as expected.

I’m trying to initiate the LUA script ‘randomRGB()’ by pressing the 2nd button once. After the (randomized) lightpattern is shown, a single press on the same button should reset all 3 RGB lights back to off (0).

The outcome I’m now experiencing ranges from endless loops in which the RGB change color every second to a state in which only one color is shown and the button doesn’t work any more.

I’m using the example used on http://forum.micasaverde.com/index.php?topic=17409.0 and I’ve attached the current PLEG export. Can someone help me out?

I have already fixed the ‘toggle’ option by moving this function to an external LUUP script. It seems the script is now only run once when the button is pressed. problem solved…