Trouble with Automation for Dimmer

So I spent most of last night trying to get my light to dim/brighten when holding my Xiaomi switch - but I just cannot make it work.
I’m using the scripts / automation noted here; Finally - a cheap WIRELESS switch that dims! Xiaomi Switch Gen1

As soon as I hold the switch to generate the long press event my system goes crazy, it seems to be firing the scripts thousands of times, which instantly takes my bulb offline.
So I’ve tried adding a 1 second delay in the script just after the ‘stop script’ call, but that didn’t help either, the log now reports there is an instance of the script already running.

Is there a simpler way to do this? - as a beginner with home assistant, I have to confess that HA’s automations seem to be overly complicated for what they are, compared to say openhab’s rules engine.