Hello Enris,
this has been discussed in every detail in various tutorials, articles and threads just like this one. Please use the search function t find everything you need.
- ITEAD Sonoff switches and sockets - cheap ESP8266 Wifi+MQTT hardware
- GitHub - arendst/Tasmota: Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
- MQTT Binding (v1.11) Getting Started 101