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

Correct. Terms like “%prefix%” are just placeholders for the actual prefix word that will be inserted as part of the topic string.

@Travalon I’d recommend that you stay calm and read through documentation a bit more. Everything you need to get a working setup running is documented at all kinds of placed but especially under https://github.com/arendst/Sonoff-Tasmota/wiki/openHAB (also check out the linked URLs) - I’ve improved this article dozens of times to be complete and reproducible. The fact that your openHAB items config includes "%"s shows that you are too hasty. Do one step after the other and everything will work out.

Also @imhofa I’d not recommend to use the Topic “sonoff”. This is the standard topic used by newly flashed Tasmota modules. You will experience awkward behavior when adding a new Tasmota to your network (e.g. both lamps switching or reporting data to the same MQTT topic).

1 Like

Hello ThomDietrich,

I know that is not recommended to name it “sonoff”, but it would be a good starting point for @Travalon to get it working, because he doesn’t have to change too many things at once. If he gets it working with sonoff, it is only a little step to change it to whatever name he likes.

I use some Sonoff POW for appliances and named them after the appliance (dishwasher, washingmachine, dryer). This way it’s much easier to link a topic to the specific device…

Andreas

1 Like

Requirements

Done = Working openHAB installation (http://docs.openhab.org)

Done = Configured Sonoff-Tasmota module (i.e. module accessible from your local network)

Done, mosquitto = MQTT broker available (e.g. Eclipse Mosquitto via openHABian)

Donish = A basic understanding of MQTT

Done = Working and tested connection between openHAB and the MQTT broker

Done = (optional) Standalone MQTT client (e.g. mqtt-spy) to observe and identify messages on the MQTT broker

Done = If not done yet, you first need to install and activate the MQTT binding, the MQTT action and the JsonPath transformation, e.g. via the openHAB Paper UI Add-ons section.

This is where I am having problems.
Before continuing, please make sure you assigned unique MQTT “Topics” in the Sonoff-Tasmota configuration interface of each Sonoff module. The default MQTT topic is “sonoff”, in the examples below we will use names like “sonoff-A00EEA”. ( Mine is DVES_60X)

In the example Sonoff

Full Topic (%prefix%/%topic%)
/%topic%/%prefix%/

The prefix and topic are switched. Is that a typo?
If I wanted my topic to be cord1 ( to be easily identified in all text configurations), would I just go with
/%topic%/%prefix%/
and cord1 in the
Topic = %topic% field? (Since its an extension cord. 1 of 2 I made.)
I could make the unique ID the name of what it controls. I.E. kitchen, kitchenette, cord1, cord2, etc. And as long as my topic matches my unique ID there shouldn’t be a problem.

So for what I have now,
Unique ID = cord1
and
Topic = %topic%
cord1

And the other could be
Topic = %topic% and ID
cord2

And, in my lights.items it would look like:

Switch cord1 "Trav's-lamp" { mqtt=">[mosquitto:cmd/cord1/POWER:command:*:default], <[mosquitto:stat/cord1/POWER:state:default]" }


Switch cord2 "Trav's-other-lamp" { mqtt=">[mosquitto:cmd/cord2/POWER:command:*:default], <[mosquitto:stat/cord2/POWER:state:default]" }

Excellent :wink:

Good.

Nope that’s just how I’ve configured my system. The screenshot is not in line with the rest of the article but I’ve mentioned that beneath the picture. For me the order “tasmota/sonoff-lamp1/cmnd/power” just makes more sense. I had a long discussion with the developer of Tasmota about that a while back. Since then you can define the Full Topic freely but he stayed with the old default because for compatibility reasons…

But did you really? In this case you should have seen the messages on the right topics (without the %) like in the Example here: 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

No leading slash! Looking at your posted openHAB config the Full Topic should be %prefix%/%topic%/ - the default setting.
Yes, set “Client ID” and "Topic to “cord1” resp. “cord2”.

There is a typo in “cmnd”.

Once again: You should not be forced to configure these openHAB lines blindly. Connect to the broker with a client (mqtt-spy, lense, mosquitto_sub, whatever) and observe what is communicated. This way you’ll see all status data coming from the device and you can see the messages published by openHAB. If everything is configured correctly these will match and you’ll see your lamps switching. Just like in the example linked above.

Good luck!

@ThomDietrich
So in your topic is the leading tasmota required or is it for your reference?

Thank you by the way.

Short: It’s my preference. Not required.

Long: On MQTT you are able to subscribe to topics. A subscription can include wildcards, e.g. let’s say I want everything published by your cord1 device. I’d issue the following command on the console:

mosquitto_sub -h localhost -t "+/cord1/#" -v

However let’s say I want to subscribe to the POWER topic of all Sonoff-Tasmota devices. You can’t do that. I can:

mosquitto_sub -h localhost -t "tasmota/+/+/POWER" -v
1 Like

Just did it again with
Android app MQTT snooper subscribed to openhab/#,
ssh on same tablet subscribed to mosquitto_sub -u openhab -P habopen -t openhab/#
And ssh on phone publishing

[05:16:18] openhabian@openHABianPi:~$ mosquitto_pub -u openhab -P habopen -t openhab/command -m ON

Got ON In MQTTsnooper 3 times
And ON in my mosquitto_sub ssh 3 times
And when I publish from MQTTsnooper it’s received by my mosquitto_sub ssh.

Good… now do the same thing with the actual Sonoff traffic.

As you have a fresh MQTT setup with only openHAB and the Sonoffs accessing it, this should do the trick:

mosquitto_sub -u openhab -P habopen -t "#" -v

Btw. could you try to organize your postings a little bit better? Code fences are great for that. I’ve modified your last message so you know how.

Sorry doing this on a phone, sometimes it doesn't take.

Well crud! Now I get this

mosquitto_sub -u openhab -P habopen -t "#" -v          
    myhome/bedroom/switch1 0
myhome/bedroom/switch1/LWT Offline
xmas/switch1/LWT Offline
tasmota/tele/%sonoff-A00EEAA%/LWT Offline
tele/sonoff/LWT Offline
tele/cord1/LWT Online

I tried to shut down OH2 and remove the

/var/lib/openhab2/config/org/openhab/mqtt.config

Maybe I screwed it up. Ill try again.

Yea it went away. Same results. I then checked mqtt.cfg, mosquitto.config, addons, items,sitemaps, everything in the openhab2 directory, anything I may have edited and I find no reference to any of the items listed. I know at some point they were pasted and saved for future editing. I guess I do recognise cord 1 but it had // in front of it.

This is totally unrelated to openHAB. All of the above are “LWT - Last Will and Testament” messages.

You should read this article series, specifically:

1 Like

Still reading through ALL of hivemq’s blog a second time. Got the LWT issue understood.

On a better note I had an idea.
I subscribed to Everything in Mosquitto and used the Sonoff’s web page to toggle the lamp on and off.
Here’s what Mosquitto saw.

13:02:48] openhabian@openHABianPi:~$ mosquitto_sub -u openhab -P habopen -t "#" -v
myhome/bedroom/switch1 0
myhome/bedroom/switch1/LWT Offline
xmas/switch1/LWT Offline
tasmota/tele/%sonoff-A00EEAA%/LWT Offline
tele/sonoff/LWT Offline
tele/cord1/LWT Online
stat/cord1/RESULT {"POWER":"ON"}
stat/cord1/POWER ON
stat/cord1/RESULT {"POWER":"OFF"}
stat/cord1/POWER OFF

Just wish I understood it.

Also, in the Sonoff WiFi configuration menu,
There’s a field labeled ‘host’. Do I need to fill that in? If so with what?

Hi, Im saving a number that comes in via mqtt as a Number.
have another item to sendback the saved number

Number stage <humidity> (All) { mqtt="<[mosquitto:openhab/stage:state:default]" } 
Number stage_send <humidity> (All) { mqtt=">[mosquitto:test/stage:command:*:default]" } 

in rule, i want to send stage number, when system starts

rule "Restarting"
when
    System started
then
        Thread::sleep(2000)
        sendCommand(stage_send,"stage")
end

I dont know about the “stage” part, is that correct? I want to send the saved number.
and I also want to change stage number when some switch turns off

rule "reset1"
when
    Item soozani_s received command OFF
then
    sendCommand(stage, 0)
end

Im not sure if the stage item which bound with mqtt can get this command.

the reason i want to send 0 to stage, because when the switch turn off, means that i want to start from 0 stage, so I want to send 0 to stage to be saved, so when system restarts, the first rule send 0 via mqtt
I hope im addressing this correctley
tnx

dont know this is correct or not, but I made these changes:

Number stage <humidity> (All) { mqtt="<[mosquitto:openhab/stage:state:default]" } 
Number stage_send <humidity> (All) { mqtt=">[mosquitto:test/stage:state:*:default]" } 

var Number saved_stage

rule "Restarting"
when
    System started
then
        Thread::sleep(2000)        
        saved_stage = (stage.state as DecimalType)         
        stage_send.postUpdate(saved_stage)
end


rule "reset1"
when
    Item soozani_s received command OFF
then
    stage.postUpdate("0")
end

@ThomDietrich
So I started with a fresh install i had.
Here’s everything I configured and the results of testing.

Mosquitto.conf

pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

allow_anonymous true

sonoff.items


Switch sonoffDVES_06X "cord" <light> (LR,gLight)
    { mqtt=">[mosquitto:cmnd/sonoffDVES_06X:POWER:command:*:default],
            <[mosquitto:stat/sonoffDVES_06X/POWER:state:default]" }
            
            Switch sonoffDVES_06X_Reachable "cord: reachable" (gReachable)
    { mqtt="<[mosquitto:tele/sonoffDVES_06X/LWT:state:MAP(reachable.map)]" }
    
    Number sonoffDVES_06Xt_RSSI "cord: RSSI [%d %%]" (gRSSI)
    { mqtt="<[mosquitto:tele/sonoffDVES_06X/STATE:state:JSONPATH($.Wifi.RSSI)]" }
    
    String sonoffDVES_06X_Verbose "cord: MQTT return message [%s]"
    { mqtt="<[mosquitto:tele/sonoffDVES_06X/INFO1:state:default],
            <[mosquitto:stat/sonoffDVES_06X/STATUS2:state:default],
            <[mosquitto:stat/sonoffDVES_06X/RESULT:state:default]" }

mqtt.cfg

mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhabian
mosquitto.user=openhabian
mosquitto.qos=0
mosquitto.retain=true
mosquitto.async=false

default.sitemap

 sitemap default label="cord" {
Frame label="Lights" {
    Switch item=DVES_06X label="Cord"  
                      
                         }
}

Sonoff Basic

Sonoff Basic Module

Sonoff

 MQTT parameters 

Host (domus1)
192.168.1.200

Port (1883)
1883

Client Id (DVES_970D9F)
DVES_06X

User (DVES_USER)
openhabian

Password
•••••••••

Topic = %topic% (sonoff)
sonoffDVES_06X

Full Topic (%prefix%/%topic%/)
sonoffDVES_06X/POWER
Tried (%prefix%/%topic%/) too

I subscribed to both

mosquitto_sub -u openhab -P habopen -t "#" -v
and
mosquitto_sub -u openhabian -P habopen -t sonoffDVES_06X/# -v

when I toggle the light from HABpanel

[22:24:48] openhabian@openHABianPi:~$ mosquitto_sub -u openhabian -P habopen -t "#" -v
cmd/sonoffDVES_06X/POWER OFF
cmnd/sonoffDVES_06X/POWER OFF
sonoffDVES_06X/POWER/LWT Online
sonoffDVES_06X/POWER/STATE {"Time":"2017-08-14T04:29:27", "Uptime":0, "Vcc":3.252, "POWER":"OFF", "Wifi":{"AP":1, "SSID":"Travalon", "RSSI":100, "APMac":"30:5A:3A:A0:4A:18"}}
sonoffDVES_06X/POWER/STATE {"Time":"2017-08-14T04:34:27", "Uptime":0, "Vcc":3.249, "POWER":"OFF", "Wifi":{"AP":1, "SSID":"Travalon", "RSSI":100, "APMac":"30:5A:3A:A0:4A:18"}}
cmnd/sonoffDVES_06X/POWER OFF
cmnd/sonoffDVES_06X/POWER ON
cmnd/sonoffDVES_06X/POWER OFF
cmnd/sonoffDVES_06X/POWER ON
cmnd/sonoffDVES_06X/POWER OFF

and 

openhabian@openHABianPi:~$ mosquitto_sub -u openhabian -P habopen -t sonoffDVES_06X/"#" -v
sonoffDVES_06X/POWER/LWT Online
sonoffDVES_06X/POWER/STATE {"Time":"2017-08-14T04:29:27", "Uptime":0, "Vcc":3.252, "POWER":"OFF", "Wifi":{"AP":1, "SSID":"Travalon", "RSSI":100, "APMac":"30:5A:3A:A0:4A:18"}}

and nothing in

[22:37:46] openhabian@openHABianPi:~$ mosquitto_sub -u openhabian -P habopen -t sonoffDVES_06X/POWER:*: -v
^C
[22:40:29] openhabian@openHABianPi:~$ mosquitto_sub -u openhabian -P habopen -t sonoffDVES_06X/POWER -v

when I toggle the light from the sonoff home page

openhabian@openHABianPi:~$ mosquitto_sub -u openhabian -P habopen -t "#" -v
cmd/sonoffDVES_06X/POWER OFF
cmnd/sonoffDVES_06X/POWER OFF
sonoffDVES_06X/POWER/LWT Online
sonoffDVES_06X/POWER/RESULT {"POWER":"ON"}
sonoffDVES_06X/POWER/POWER ON
sonoffDVES_06X/POWER/RESULT {"POWER":"OFF"}
sonoffDVES_06X/POWER/POWER OFF

 openhabian@openHABianPi:~$ mosquitto_sub -u openhabian -P habopen -t sonoffDVES_06X/# -v
sonoffDVES_06X/POWER/LWT Online
sonoffDVES_06X/POWER/RESULT {"POWER":"ON"}
sonoffDVES_06X/POWER/POWER ON
sonoffDVES_06X/POWER/RESULT {"POWER":"OFF"}
sonoffDVES_06X/POWER/POWER OFF

and nothing from

openhabian@openHABianPi:~$ mosquitto_sub -u openhabian -P habopen -t sonoffDVES_06X/POWER -v

and nothing in MQTTlens with same subscriptions.

events.log

2017-08-13 22:01:59.387 [ItemStateChangedEvent     ] - sonoffDVES_06X_Verbose changed from NULL to {"Module":"Sonoff Basic", "Version":"5.5.0", "FallbackTopic":"DVES_06X", "GroupTopic":"sonoffs"}
2017-08-13 22:02:00.562 [ItemStateChangedEvent     ] - sonoffDVES_06X_Verbose changed from {"Module":"Sonoff Basic", "Version":"5.5.0", "FallbackTopic":"DVES_06X", "GroupTopic":"sonoffs"} to {"POWER":"OFF"}
2017-08-13 22:02:07.565 [ItemStateChangedEvent     ] - sonoffDVES_06Xt_RSSI changed from NULL to 100
2017-08-13 22:02:33.431 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:02:33.447 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:02:39.312 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:02:39.327 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:03:16.356 [ItemStateChangedEvent     ] - sonoffDVES_06X_Verbose changed from {"POWER":"OFF"} to {"POWER":"ON"}
2017-08-13 22:03:17.025 [ItemStateChangedEvent     ] - sonoffDVES_06X_Verbose changed from {"POWER":"ON"} to {"POWER":"OFF"}
2017-08-13 22:03:29.200 [ItemStateChangedEvent     ] - sonoffDVES_06X_Verbose changed from {"POWER":"OFF"} to {"POWER":"ON"}
2017-08-13 22:03:34.838 [ItemStateChangedEvent     ] - sonoffDVES_06X_Verbose changed from {"POWER":"ON"} to {"POWER":"OFF"}
2017-08-13 22:07:08.228 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:07:08.249 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:07:08.979 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:07:08.992 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:07:09.307 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:07:09.323 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:07:09.755 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:07:09.771 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:07:29.338 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:07:29.351 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:07:30.020 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:07:30.033 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:07:30.526 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:07:30.544 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:07:30.991 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:07:31.009 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:07:31.442 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:07:31.461 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:07:31.883 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:07:31.897 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:09:19.595 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:09:19.610 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:09:29.425 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:09:29.441 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:10:16.504 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:10:16.523 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:18:31.611 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:18:31.628 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:25:21.026 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:25:21.103 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from NULL to ON
2017-08-13 22:30:51.393 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:30:51.425 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:30:52.028 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:30:52.056 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:30:52.603 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:30:52.631 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:31:25.157 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:31:25.175 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:31:25.548 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:31:25.563 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:31:25.829 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:31:25.839 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:31:26.038 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:31:26.048 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:31:26.274 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:31:26.283 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:34:09.227 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:34:09.250 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:34:10.010 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:34:10.029 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:34:58.217 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:34:58.231 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:35:16.362 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:35:16.373 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:35:17.380 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:35:17.394 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:35:17.654 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:35:17.671 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:36:03.290 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:36:03.322 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from NULL to OFF
2017-08-13 22:36:04.103 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:36:04.120 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:36:29.197 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:36:29.220 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:38:06.923 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:38:06.940 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:38:11.508 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:38:11.524 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:40:48.451 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:40:48.467 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:40:51.658 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:40:51.676 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:40:53.214 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:40:53.229 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:40:54.098 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:40:54.117 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:42:15.771 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:42:15.790 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:42:16.262 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:42:16.278 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF
2017-08-13 22:42:16.512 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command ON
2017-08-13 22:42:16.525 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from OFF to ON
2017-08-13 22:42:16.789 [ItemCommandEvent          ] - Item 'sonoffDVES_06X' received command OFF
2017-08-13 22:42:16.802 [ItemStateChangedEvent     ] - sonoffDVES_06X changed from ON to OFF

openhab.log

	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:914)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:886)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:873)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:132)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:940)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:740)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:674)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:429)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:403)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:278)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)[31:org.apache.felix.scr:2.0.6]
	at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)[31:org.apache.felix.scr:2.0.6]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482)[org.osgi.core-6.0.0.jar:]
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415)[org.osgi.core-6.0.0.jar:]
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)[org.osgi.core-6.0.0.jar:]
	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)[org.osgi.core-6.0.0.jar:]
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:902)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:466)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.Module.start(Module.java:457)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
2017-08-13 22:35:46.879 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'sonoff.items'
2017-08-13 22:35:46.980 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'sonoff.items'

I think I found the problem.

Sonoff syslog after reboot/

01:21:01 MQTT: Attempting connection...
01:21:02 mDNS: Query done with 0 mqtt services found
01:21:02 MQTT: Connected
01:21:02 MQTT: cmnd/sonoff/LWT = Online (retained)
01:21:02 MQTT: cmnd/sonoff/cmnd/POWER = 
01:21:02 MQTT: cmnd/sonoff/INFO1 = {"Module":"Sonoff Basic", "Version":"5.5.0", "FallbackTopic":"DVES_06X", "GroupTopic":"sonoffs"}
01:21:02 MQTT: cmnd/sonoff/INFO2 = {"WebserverMode":"Admin", "Hostname":"sonoff-3487", "IPaddress":"192.168.1.202"}
01:21:02 MQTT: cmnd/sonoff/INFO3 = {"Started":"Software/System restart"}
01:21:03 MQTT: cmnd/sonoff/RESULT = {"POWER":"OFF"}
01:21:03 MQTT: cmnd/sonoff/POWER = OFF
01:21:10 MQTT: cmnd/sonoff/STATE = {"Time":"2017-08-16T01:21:10", "Uptime":0, "Vcc":3.251, "POWER":"OFF", "Wifi":{"AP":1, "SSID":"Travalon", "RSSI":100, "APMac":"30:5A:3A:A0:4A:18"}}
01:26:10 MQTT: cmnd/sonoff/STATE = {"Time":"2017-08-16T01:26:10", "Uptime":0, "Vcc":3.250, "POWER":"OFF", "Wifi":{"AP":1, "SSID":"Travalon", "RSSI":100, "APMac":"30:5A:3A:A0:4A:18"}}

Question?
I am using the arendst/Sonoff-Tasmota.
When using the Web interface Console, I can type status 2 and it will display firmware information.
Can / How can I trigger this “status 2” command via mosquitto_pub ?

Wiki says

NOTE For many commands, an empty payload is a query. If you are using mosquitto_pub, you can issue an empty payload using the “-n” command line option. If your MQTT client cannot issue an empty payload, you can use the single character “?” instead.

What I tried so far.

mosquitto_sub -h 127.0.0.1 t -t 'stat/sonoff-80786B/STATUS2'

I can see the message, when I trigger status 2 via Web Console

mosquitto_pub -h 127.0.0.1 -t 'CMND' -m 'status 2'
mosquitto_pub -h 127.0.0.1 -t 'cmnd/sonoff-90786B/STATUS2' -n
mosquitto_pub -h 127.0.0.1 -t 'cmnd/sonoff-90786B/' -m 'status 2'
mosquitto_pub -h 127.0.0.1 -t 'stat/sonoff-90786B/STATUS2' -n

Ideas ?

If you just want to get the running fw version please check the earlier example here

Here we’re also using fw information for maintenance purposes: 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

1 Like

Hey guys… Hardware question…

I’m thinking of wiring up a sonoff basic to my outside lights but I’d still want a physical switch on the wall so visitors can still use the old school method to switch the lights on and off.

I’m thinking of getting something like this led push button switch but I’m wondering if anyone has any ideas on how to power the LED on the button? For now I think I’m okay with soldering the actual button to the physical button on the sonoff but I’d really like the LED in my custom button to glow in certain scenarios.

Has anyone maybe seen a much lower voltage version?

UPDATE : Okay managed to find a 3V version on eBay…


Now need to figure out what voltage the onboard LED on the Sonoff runs at and if I can piggy back off that.

You should be able to use the PCB headers to get your voltage and use GPIO14 as the Switch input. No actual need to hack the existing button or LED.
How do you want your LED illuminated? Always on? On when light off? Either connect it to VCC or yet another output pin (eg Tx). Good luck :wink: