Download HACS

In HACS, search for Sonoff LAN.
Connect the Sonoff S31 via the ewelink app and configure the smart switch accordingly
Login to Ewelink in homeassistant and the devices should appear.