If you are anything like me then you have tried to automate everything everything in your house. As someone who's family lives in the iOS ecosystem, using anything but Apple's Homekit isn't an option.
Homebridge is an open source project written in NodeJS that runs on your home network and interfaces with Apple's Homekit by emulating its API. Homebridge's GitHub wiki page has great instructions on getting Homebridge up and running on a Raspberry Pi.
The Sonoff units come pre flashed with their own code to be used with their EWlink app system. That can easily be changed.
At the heart of the Sonoff is the maker friendly ESP line of microcontrollers which is just begging for us to hack it.
The motherboard board conveniently provides pins on the motherboard for a serial connection, all you have to do is solder a header to it.
The ESP isn't 5V tolerable, so you have to make sure you use a 3.3V USB UART TTL Converter/Programmer when programming it or terrible things just might happen.