This article shows you how to connect an FTDI to the sonoff
http://tech.scargill.net/itead-slampher-and-sonoff/
From there, I think this tutorial will get you going
https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-nodemcu-lua
leading well into this project on Github, which, I think, is what you were referring to for MQTT on the Sonoff (all of this, of course, removes the original cloud functionality)