Great project! I’m using (read: stealing) your idea to use in my own setup here.
I currently have some switches that are wired with a neutral, and some that use a switched live. The ones with existing neutral will be easy to configure as you have, and I’ve come up with a solution for those that only have switched live. It basically involves using 2 Sonoff Basics, so may not be the best option, but to my eye it looks like it should work.
I have another question for you though… I understand the control wiring for the KY-040 (rotating and clicking the switch), but I’m getting a bit lost when trying to figure out the power for the KY-040. In the picture with your breadboard, those pins on the KY-040 are connected to the rails. But when making it for real, where have you connected those pins to on the Sonoff?
Sorry for the basic question - I’m new to all of this, but keen to learn!