The simplest way is with SonOTA - however it looks like the newer firmware versions are starting to put things in place to stop this from being as easy, but there’s pins on the board that you can program using a USB-Serial adapter.
Check out the big thread here too
I currently have 6x Sonoff Basic, 1x TH16 and 1x T1 The TH are quite nice because they give you mains switching and temp/humidity in a single unit
I think I’m going to stick with mains-powered lights - a bigger range available. I’ve never found a need for dimming in anything other than one of our bedrooms, so everywhere else is just currently basic LED bulbs - so I might leave that as is and just have controllable on/off - if I even feel a need for automated lights! (Not convinced I’ve found a usage case for it yet, but time may tell!)