To make this fit it was important to minimise the hardware footprint, have an integrated display interface and have a modular architecture.  Some of the choices are obvious, others are based on the best options I can find.

The Brain

The ESP32 Pic D4 is a low cost, small footprint IC with built in ADC, Wi-Fi and Bluetooth and also interfaces for SPI, UART, I2C that we need for adding lots of components.  Also I added a serial interface for programming using a CP2104 USB to UART IC. 

Radio Frequency 433MHz - CC1101

To control RF Plugs and receive RF signals (e.g. doorbell press) I need a Radio Frequency (RF) Rx and Tx board.  There are a few options separate board but to minimise the footprint with one board with a single antenna I selected a low cost CC1101 board.  These can transmit and receive on one board switching in software when transmitting.  There is also good support for this in OpenMQTTGateway.

InfraRed Receive and Transmit

This is useful if you have a spare remote for device control or want to transmit to control TVs.  The interface is fairly simple with plenty of examples in the web and lots of software support, again using OpenMQTTGateway.  This just requires a IR diode with an NPN transistor boost and am IR receiver with no additional circuitry beyond a passive resistor.

General Midi Synthesizer, SD Reader, MP3 Decoder, Microphone, Midi Input

It's a fairly old IC but the VS1053b is powerful with a lot of capability in a small package. I had been looking to build my own General Midi synth (I have nostalgic Monkey Island needs) so not going to miss the opportunity.  This chip also provides MP3 decoding, Microphone encoding in Ogg format and a midi input for controlling the General Midi synth.

It is not an easy chip to work with but Adafruit and Sparkfun provide example boards, code and circuit diagrams. Ralph S Bacon does a good YouTube video using one of these boards to build an internet radio.

There was no space in a light switch for a standard MIDI 5 pin din plug but TRS 3.5mm plug is now reasonably standard for MIDI input.  You can switch from standard to MIDI input mode in code with a VS1053b plug in.

Most of the VS1053b boards come with an SD card interface to load MP3 files, the fact that both the VS1053b and an SD card reader use SPI means that just an additional CS data line is needed to communicate with the SD reader.

Amplifier, Headphones and Speaker

If you have an MP3 and Midi Synthesiser on board then you need to be able to hear it.  The original design used a DFPlayer Mini for the MP3 player as it amplifier, SD reader, and speaker and headphone pins.  Changing to the VS1053b meant I needed to add an amplifier and the TPA2012 was compact and had a dev board with code and circuit diagrams from Adafruit with details on the additional passive components.  The TPA2012 has both headphone and line out so I used a special jack to switch to headphones when they are plugged in.  Look for 3.5mm PJ-307C 5 pin jack with the switching pins.

Programmable Led Interface

There are a few different programmable LED components available but I included 2 standard WS2821b's.  Including 2 either side of the display to allow for some feedback or alarm indication.  Also added a breakout to connect an external led chain. If the led chain is externally power then this could also power the light switch (remember, each WS2821b could use up to 60mA so best not to use the copper traces to power a strip).

Fingerprint Sensor

Integrating a door entry system into a light switch format with touchscreen keypad is fairly easy but adding a fingerprint sensor provides a quick authentication option.  There are lots of example of using a fingerprint sensor with a micro controller but this is mostly with an optical reader (AS608).  This won't fit in the light switch dimensions but there is a slimline capacitive board, the FPC1020A.  This has a simple serial interface, hard to get good example of this in use but Andrey Ovcharov's URU Key project shows a compact use of this as an authenticator.

Buzzer

As well as LED's and a speaker some audible feedback through a buzzer is useful to confirm button presses or fingerprint acceptance.  The selection of a passive buzzer provides some options to create a simple tune.  To keep the footprint small a surface mount buzzer was used (KLJ-5030) in conjunction with an NPN transistor pulling it up to 5V for max volume.  Also using IO0 on the ESP32 as this does not affect the boot sequence.

Temperature

There are a number of options for a temperature sensor e.g. DHT22 with humidity but the DS18b20 is smaller and more accurate. Both sensors only need one data line.  For this I am using IO15 with a 4.7k pullup.  You need to be careful with some IO pins on the ESP32, particularly IO15 but as this has a pullup it does not affect bootup.  Using an AHT20 might be a better option through the I2C interface so I may reconsider this.

Light

A light sensor is useful to decide if lights need to be switched on or just for measurement.  A simple Light Dependant Resistor (LDR) is used with the ESP32's ADC and this gives a good light level indication although it needs some calibration and the ESP32 does not have the best ADC.

Motion

InfraRed motion sensor are the normal method of checking for presence.  Space consideration make this a problem in the light switch space but there are cheap microwave motion detectors available that are on a small pcb, e.g. RCWL0516.  This just needs one IO port and I am using IO39 because it is one of the IO ports that is input only.  On YouTube Andreas Spiess does a great review of these Radar Sensors and Big Clive does a breakdown on how they work.  These do 'see' through walls so they may not be useful in all situations.

Touchscreen Display and Control

This has to replace a switch so we need an user interface, the Nextion 2.4 Resistive Touch screen provides that and more.  Couple this with the HASP code from Allen Derusha (now HASPOne) and it is possible to create and update your own mini home control panel using Home Assistant or directly using MQTT.  If you just want a touch screen light switch then Allen Derusha's HASP is great for this but I needed to port the core to ESP32 and integrate with OpenMQTTGateway since I was going to be adding a lot of modules.

Software

The core of the software is based on OpenMQTTGateway (OMG).  This provides a framework for communicating with any sensors attached to the ESP32, OMG covers a lot already and supports the ESP32.  A big advantage is that these sensors can be added and removed in a modular fashion. These sensors can be monitored and controlled using NodeRed or HomeAssistant/OpenHAB.

To configure and control the LCD display I have ported the MQTT control part of HASP to ESP32 and integrated it into OMG.  This works well but the openHASP project from fvanroie looks like a better longer term bet, it allows for cheaper open source hardware option.