If you want to have a degree of manual control over Sonoff devices, but you dont feel like writing the code from a scratch, you can use Tasmota firmware.