Once you have installed the MQTT and Openhab 3, we are ready to configure it. In this tutorial we will use Sonoff Basic with Tasmota firmware.
Add MQTT Binding
To integrate MQTT in Openhab 3, login to Openhab interface and click settings.

Under add-ons, click Bindings. At the bottom right, click the blue circle with plus sine to add new add-ons bindings
Search for MQTT binding and install. Also search for Network Binding and install it.
Add an MQTT Broker
Now let us add an MQTT Broker. On Settings again, click Things >> Add (blue circle button) >> MQTT Binding >> MQTT Broker. You can change the label if you want.
Fill in Broker Hostname/IP with the IP address of MQTT Broker
192.168.1.10
Tick the Show Advance check box and scroll down below. Find and fill Username and Password:
Userame : mymqtt
Password : mypassword
Click Create Thing button to save.
Add Generic MQTT Thing
We will use basic Sonoff device with Tasmota firmware installed as our MQTT thing example. Remember that Sonoff should be connected on the same network.
Open the device web interface by typing the IP address of it in a web browser.
Go to configuration >> configure MQTT and update the configuration.
Host : 192.168.1.10
User : mymqtt
Password : mypassword
Topic : Bed-L1
*Topic: You can enter any topic of which you can think. For my topic, it means bedroom light 1.

Click save. After the device restart, go to console and see if your device is connected to MQTT broker.
Add Sonoff device to Openhab
Open Openhab interface and on Settings, click Thing >> Add >> MQTT Binding >> Generic MQTT Thing and make changes:
Label : Bed Light 1
Location : Bedroom
Bridge : MQTT Broker
Click the newly created thing Bed Light 1, click Channels tab >> Add Channel and fill the following:
Channel Identifier : cidBedL1
Label : Bed Light 1
Select On/Off Switch
MQTT State Topic : stat/Bed-L1/POWER
MQTT Command Topic : cmnd/Bed-L1/POWER
Click Create to save changes.
Under Channel tab > All tab you will see Bed Light 1. Click that >> Add link to Item >> Create a new Item and fill the following:
Category : lightbulb
Semantic Property : Light
Profile : Default

Click Link and Save (top right)
On the left panel, under Settings >> Items, you will see one item Bed Light 1, click it.
From here you can turn on and off your device.