If you’re in the US (or other country which has similar electrical codes, which many do): I would bet that the sonoff is not UL Listed, at least it looks like it is not. Imagine putting an esp8266 based controller or something like this in your wall, then an unrelated fire breaks out for some other reason. Your insurance company will say that you have something that is not UL listed in the wall, and you are probably breaching their terms. So even if it’s safe (it may not be, see overheating issues on some esp8266 boards), it’s not to code. This is a multi hundred thousand dollar (or more) gamble, and smart people don’t take those best, even with good odds. Just my 0.02, because I wanted to go this route and did some research. It was a no go, because it’s just not very smart IMO.
If I’m wrong and it’s UL listed, then game on. Otherwise, it’s gambling with a few hundred thousand.