ITEAD Sonoff switches and sockets - cheap ESP8266 Wifi+MQTT hardware

following a hunch here: There is a bug where a wrong configuration is not fully purged from the openHAB memory. Please double check that your mqtt.cfg config file is correct, unistall the MQTT binding, delete the file /var/lib/openhab2/config/org/openhab/mqtt.config (linux apt installation), then restart openHAB and reinstall the binding.

Thanks for getting back to me. Did as you said it seemed to have removed that error message but still can not turn on sonoff relay from openhab2. You probably have heard it all before (see post from Travalon). Basically I have flashed sonoff basic as per your instruction using arduino ide, all went well. Started with a brand new installation of openhab2 with mosquito on raspberry pi3. Loaded site map and items file. All okay up to this point. Went into openhab2 basic ui and operated switch to turn sonoff relay on…MQTT.fx reports that it has received message from openhab2 but relay still not coming on. When i operate the sonoff relay with physical button on switch, relay operates and I get a message on MQTT.fx that it has received that message… MQTT binding installed along with MQTT actions…NEED HELP PLEASE…Include mqtt.cfg file, items file, sitemap…

# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.

# Optional. User id to authenticate with the broker.

# Optional. Password to authenticate with the broker.
broker.pwd=password (not really)

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

site map

sitemap home label="Woodys-SmartHouse"
       Frame label="Gamesroom"
	       Switch item=DVES_A7FA7E


//This is the Items File

Switch DVES_A7FA7E "Gameroom" <light> (LR,glight)
    { mqtt=">[broker:cmnd/DVES-A7FA7E/POWER:command:*:default],
            <[broker:stat/DVES-A7FA7E/POWER:state:default]" }

your explanation sounds a bit confusing. Are you sure the Sonoff is connected to the MQTT broker? Did you try to manually switch the Sonoff from MQTT.fx?

You will see that everything is easier if you go at it step by step…

Thats my biggest problem, not knowing how MQTT works. I know that I put a “#” in the box and subscribe and it shows me the status of each device, or "cmnd/DVES_A7FA7E/POWER will just show me the status of that device, but thats it i,m afraid to say. Could you please tell me how I get MQTT.fx to speak directly to my device?. Would the command be

mosquitto_pub -h -t cmnd/DVES_A7FA7E/power -m 1

if so not sure what server name is or where to put this command in MQTT.fx…
Sorry to be a pain…

Ok, I’m just beginning to understand MQTT a little, it took me a couple of hours toget automatic updates/restart/queryFW to work, but getting it running gave a good feeling!:smiley:
Is the name you use as your topic correct? (DVES_A7FA7E), when I look at mij Sonoff Basic’s web interface i see this:


When I wan’t to use it I send something to MQTT Topic “sonoff-5” ie, “cmnd/sonoff-5/” and NOT to DVES_9D57D0


1 Like

That’s understandable. When new to the world of home automation you are confronted with dozens of technologies and methods you need to understand. Nonetheless, the best way to bet comfortable with them and to enjoy tinkering with your smarthome, you need to learn how XYZ (here: MQTT) works.

I’d advice to go back to MQTT Binding (v1.11) Getting Started 101 and go through the initial list of resources. There you’ll find the MQTT Essentials. An online article series containing everything you need to know. Nothing will replace the few minutes you invest reading these.

Could you please tell me how I get MQTT.fx to speak directly to my device?

There is no such thing. MQTT follows the publish-subscribe principle. Equal clients connect to a broker, then subscribe to topics and publish messages to topics. When a message is being published to a topic a client has subscribed, this client will then react on it. Therefore what you need to do to switch the Sonoff-Tasmota device is (see here) publish an “ON” or “OFF” payload message to the topic cmnd/DVES-A7FA7E/POWER.
That will become clear during the Essentials series.

1 Like

Many thanks to "X-Ray181, and "ThornDietrich. Yep I guess I need to go back to the books (ebooks) to read and understand. Once again Thanks to both of you, have it working now but going back to study…P.S yep you were right X-Ray181, got confused with topic, and fallback topic…

1 Like

Looks like there is a way to reflash without soldering (haven’t tested it yet):

Got the info from here:


Jup, never used it though. Also see:


I have flashed Sonoff B1 bulb with SonOTA, worked quite well.


I just flashed a Sonoff Basic with this. Worked like a charm.

1 Like

is possible to have a bindings of SONOFF without flashing?

No. The original firmware is proprietary and only works with the provided app.
Sonoff-Tasmota on the other hand is free, open and extremely versatile.

1 Like

with this?

I see. Well that’s fun and all but I’d strongly suggest to install Sonoff-Tasmota. It’s a tested and working solution without wild hacks and the way to integrate in openHAB is completely described in the first posting of this thread.

Hi all, Just got my first Sonoff relays set up though im miffed if I know how to control a Sonoff Dual - could someone post and example of their .items for a dual? Not sure how to refer to the two relays!


my first post :wink:

Hey James!

Welcome to the community!
The solution is simple:

// Sonoff Dual
Switch WZ_Eulenlicht_Unten "Eulenlicht Unten" <light> (WZ,gLight) ["Lighting"] { mqtt=">[broker:tasmota/sonoff-E7659E/cmnd/POWER1:command:*:default], <[broker:tasmota/sonoff-E7659E/stat/POWER1:state:default]" }
Switch WZ_Eulenlicht_Oben "Eulenlicht Oben" <light> (WZ,gLight) ["Lighting"] { mqtt=">[broker:tasmota/sonoff-E7659E/cmnd/POWER2:command:*:default], <[broker:tasmota/sonoff-E7659E/stat/POWER2:state:default]" }
Number WZ_Eulenlicht_RSSI "Eulenlicht RSSI [%d %%]" (gRSSI) { mqtt="<[broker:tasmota/sonoff-E7659E/tele/STATE:state:JSONPATH($.Wifi.RSSI)]" }
Switch WZ_Eulenlicht_Unreach "Eulenlicht unreachable" <siren> (gUnreach) { mqtt="<[broker:tasmota/sonoff-E7659E/tele/LWT:state:MAP(]" }

Besides that I guess it would be great for you to know how to be able to find the solution by yourself. I’ve documented the process here:
Let us know if something stayed unclear!

Best! Thomas

Thomas, thank you for your reply - super speedy
Ahh that simple huh - awesome

Thanks for the link too!

1 Like

Hi guys,

I’ve setup my first Sonoff POW and am just starting off getting the on/off functionality working. Can someone take a look at my item entry below? At the moment the switch in my sitemap activates the POW just fine but I’m noticing that the updates are not showing in other user interfaces.

For example if I turn on the POW using OpenHAB app on my phone then the relay acivates but the state change is not reflected in the basic UI in my browser on my machine… If I refresh my browser and reload the page then the state is updated.

Switch SonoffPOW01 "Washingmachine" <washer> { mqtt=">[mosquitto:cmnd/sonoffpow01/POWER:command:*:default],<[mosquitto:stat/sonoffpow01/POWER:state:default]" }


If you switch it directly on the Sonoff (via hardware button), does it change status in OpenHAB (with or without refresh)? I’ve had problem with reporting status change when using hardware button, and then I’ve found out that my topic’s syntax differs from the examples I’ve found. This is a switch configuration for my Sonoff Touch with Tasmota firmware:

Switch Lights_Switch_Lobby “Lobby” {mqtt=">[mosquitto:cmnd/SonoffTouchLobby/POWER:command:*:default], <[mosquitto:tasmota/SonoffTouchLobby/stat/POWER:state:default]"}

The best way to find relevant topics (both in and outgoing) is to use mosquitto_sub, to have those topics reported when used (in case topics are the problem you’re having).

Best regards,