HomeHome AutomationConfigure OpenHab 3 and MQTT on a Raspberry Pi 4

Configure OpenHab 3 and MQTT on a Raspberry Pi 4

DIYHobi
May 2, 2026
20 Min Read
Configure OpenHab 3 and MQTT on a Raspberry Pi 4
AdvertisementDIYHOBI_AD_UNIT

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

configure mqtt openhab binding

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
configure mqtt openhab tasmota

Click Link and Save (top right)

Add Generic MQTT Thing

Click Things >> Add (blue circle button) >> MQTT Binding >> Generic MQTT Thing. On the Bridge Selection, select the MQTT Broker we created earlier.

configure mqtt openhab add thing

Click Link and Save (top right)

Add Sonoff device to Openhab

Click the Generic MQTT Thing we created earlier and click Channels tab. Click Add Channel.

configure mqtt openhab mqtt thing channels

Fill in the following for Sonoff device:

  • Channel Identifier: sonoff_basic_1
  • Label: Bed Light 1
  • Channel Type: On/Off Switch
  • MQTT State Topic: stat/sonoff_basic_1/POWER
  • MQTT Command Topic: cmnd/sonoff_basic_1/POWER

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.

AdvertisementDIYHOBI_AD_UNIT