Check out my method of doing a similar thing with actual Sonoff… Note how I have a flag routine to prevent sequential action when holding the button down… or reacting to both button press and release.