On the sonoff basic example, line 108: Should be: previousButtonState = currentButtonState; and not the other way around!