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

Have you flashed this as well? Can you please tell me which usb to serial adapter you used and also the firmware version. Am new to all this hence these questions?

@Ramakrishnan_Manohar See the Top of this Topic. You will find all needed informations.

  1. Yes I flashed it
  2. 3.3V FTDI USB-to-Serial Converter/Programmer example example 2
  3. https://github.com/arendst/Sonoff-Tasmota/wiki

Just start reading :slight_smile:
A small tutorial

Hi guys,
I am not sure if my problem is on the right place here. But I think here are some guys who know what to do in my case.
I want to flash the tasmota firmware to a D1 mini ESP8266 board. I struggled a bit at the beginning, but now I can flash the board. At least Platformio tells me that the flashing procedure was successful. After restarting the mini the blue LED blinks one times and nothing more happens. I tried flashing with the internal USB port and an external FTDI. Both ways with the same result: flashing was successful and nothing more again after a restart. Wlan settings are set through the config file.
I am using a mac with macOS sierra and platformio.
The serial monitor shows me the following:

{d␀l��|␀�d�|␃␌␌␌�␌l�␌c|��␂�␒�r�b�␌c��gg�loo���␌c␜p��lslslp�o�␐␃␌␄�␄d␄��␄␄␄c␄o�|␃d�␄␄�b��nn�␀d��d`␃�␛␛oo␄d`␃
␏␃o{���n␄␄��`␃␎s��n␄␄��`␃␎s��gl�|��`␃␛�s�g�c�gcp␀�

Not very promising…

Are there any hints or a description from somebody who flashed successfully a mini?

Thanks for your help!

You just have to read the first posting :slight_smile:

Yes the 4CH is working just fine with Sonoff-Tasmota and openHAB. Also have a look at:

Here is a bit off topic, afterall it’s a thread about the Sonoff modules. You’d find better help in the Tasmota issue tracker. Please move your question there.
I did not flash Tasmota onto the D1 mini, so can’t help much.

braahhh! openHAB won’t connect to mosquitto:

2017-07-20 22:57:33.677 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mqttson'
2017-07-20 22:57:35.679 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to broker was lost
Connection lost (32109) - java.io.EOFException
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146)[197:org.openhab.io.transport.mqtt:1.10.0]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_121]
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(DataInputStream.java:267)[:1.8.0_121]
	at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65)[197:org.openhab.io.transport.mqtt:1.10.0]
	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107)[197:org.openhab.io.transport.mqtt:1.10.0]
	... 1 more
2017-07-20 22:57:35.682 [ERROR] [t.mqtt.internal.MqttBrokerConnection] - MQTT connection to 'mqttson' was lost: Connection lost : ReasonCode 32109 : Cause : null
2017-07-20 22:57:35.683 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting connection helper to periodically try restore connection to broker 'mqttson'

mqtt.cfg:

mqttson.url=tcp://localhost:1883
mqttson.clientId=OH2MQTT

installed mosquitto via openhabian-conf
and “systemctl status mosquitto” says it’s running.

are there more settings?

i already tried to delete the mqtt binding config via karafe console but the error remains :frowning:
what am i missing (again)…?

Hello i use three Sonoff Smart Switches flashed according to this tutorial.
However i have the “problem” that my wifi turns out at night and the switch starts blinking green when loosing the wifi connection.

Is there any software possibility to turn that off? I did not find any option in the WebUI.
Its driving me mad at night in my bedroom but I do not want to solder out the LED :wink:

Tape them? :smiley:

3 Likes

If there is no better solution I’ll need to :smiley:

Ah, there is your problem :smile:
Honestly, I’m pretty sure there is no option to turn the LED off. Just tape them.

If your using Snoff-Tasmota there are some commands that control the LED.

I found the best way to execute was via web browser to the sonoff and the goto the consol.

Try the command

LedState OFF

Not sure if this will work when wifi drops.

OK this is killing me. I have spent weeks trying to get 1 sonoff basic controlled from HABpanel. I have started from scratch 3-4 times. I have tried OH2 and OH2.1 stable. all I can think of is my mqtt binding is not installed. When I install it through the paper UI the indicator just spins and spins (2 hours last time I tried) until I refresh the screen. Then it says installed.

I then do the following:

mqtt.cfg

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

lights.items

Switch cord1 "Cord" 
    { mqtt=">[mosquitto:cmnd/diana/cord1/POWER:command:*:default],
            <[mosquitto:stat/diana/cord1/POWER:state:default]" }
            
            Switch cord1_Reachable "Cord: reachable" (gReachable)
    { mqtt="<[mosquitto:tele/diana/cord1/LWT:state:MAP(reachable.map)]" }
    
    Number cord1_RSSI "Cord: RSSI [%d %%]" (gRSSI)
    { mqtt="<[broker:tele/diana/cord1/STATE:state:JSONPATH($.Wifi.RSSI)]" }
    
    String cord1_Verbose "Cord: MQTT return message [%s]"
    { mqtt="<[mosquitto:tele/diana/cord1/INFO1:state:default],
            <[mosquitto:stat/diana/cord1A/STATUS2:state:default],
            <[mosquitto:sta/dianat/cord1/RESULT:state:default]" }

mosquitto.conf

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

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
connection_messages true

addons.cfg

# The installation package of this openHAB instance
# Note: This is only regarded at the VERY FIRST START of openHAB
# Note: If you want to specify your add-ons yourself through entries below, set the package to "minimal"
# as otherwise your definition might be in conflict with what the installation package defines.
#
# Optional. If not set, the dashboard (https://<yourserver>:8080/) will ask you to choose a package.
#
# Valid options:
#   - minimal  : Installation only with dashboard, but no UIs or other add-ons. Use this for custom setups.
#   - simple   : Setup for using openHAB purely through UIs - you need to expect MANY constraints in functionality!
#   - standard : Default setup for normal users, best for textual setup
#   - expert   : Setup for expert users, especially for people migrating from openHAB 1.x
#   - demo     : A demo setup which includes UIs, a few bindings, config files etc.
#
# See http://docs.openhab.org/configuration/packages.html for a detailed explanation of these packages.
#
package = standard

# Access Remote Add-on Repository
# Defines whether the remote openHAB add-on repository should be used for browsing and installing add-ons.
# This not only makes latest snapshots of add-ons available, it is also required for the installation of
# any legacy 1.x add-on. (default is true)
#
remote = true

# Include legacy 1.x bindings. If set to true, it also allows the installation of 1.x bindings for which there is 
# already a 2.x version available (requires remote repo access, see above). (default is false)
#
legacy = true
# A comma-separated list of bindings to install (e.g. "sonos,knx,zwave")
binding = mqtt
# A comma-separated list of UIs to install (e.g. "basic,paper")
#ui = 
# A comma-separated list of persistence services to install (e.g. "rrd4j,jpa")
#persistence = 
# A comma-separated list of actions to install (e.g. "mail,pushover")
#action = 
# A comma-separated list of transformation services to install (e.g. "map,jsonpath")
transformation = map,jsonpath 
# A comma-separated list of voice services to install (e.g. "marytts,freetts")
#voice = 
# A comma-separated list of miscellaneous services to install (e.g. "myopenhab")
misc = node-red

On my Sonoff basic

Sonoff Basic Module
cord1

 MQTT parameters 

Host (domus1)   openhabianpi
Port (1883)   1883
Client Id (DVES_970D9F)   cord1
User (DVES_USER) openhabian
Password •••••••••
Topic = %topic% (sonoff)  cord1
Full Topic (%prefix%/%topic%/)    diana/%cmnd%/%cord1%/

default.sitemap

sitemap default label="Diana" {
    Frame label="Date" {
        Text item=Date
    }
    Frame label="Demo" {
       Switch item=Lights icon="big_bulb" mappings=[OFF="All Off"]

any help is appreciated.

on your Sonoff config is an mistake I think
Host ( domus1 ) openhabianpi try the ip of the raspi

1 Like

You should try to subscribe with a mqtt tool to your broker and see with messages are coming from the SonOFF.

I use mqttspy for this. Just connected to the broker and subscribed to all messages. If you get messages from SonOFF half the way is done.

Next step is to manually send a message to the SonOFF. If this works your problem is OH based.

Based on you files i see the following mistakes:

mqtt.cfg:
Mosquitto.url is empty. Should be something like mosquitto.url=tcp://:1883
Maybe 127.0.0.1 is possibele to

Light items:
The verbose items has a mistake at the last line dianat instead of diana

Thomas

1 Like

Your full topic seems wrong to me. Maybe try %prefix%/diana/%topic%/ instead?

Thank you all for your observations.
Actually missed the Mosquitto url. It is and has been tcp://localhost:1883
I’ll fix the verbose line, use ip address, and change the full topic.
I have mqtt lens but am having trouble understanding how to use it.
How would I subscribe to all messages?

In either client you could subscribe to the topic #

1 Like

Hello @Travalon,
there are a few conflicts in your configuration, as the others already pointed out. I wonder if you’ve actually looked at your openhab.log and events.log ?? Something like this:

Should not be a problem at all because the log will state clearly if the binding was installed or not. In the same way you’ll see if there is a problem connecting to the broker or if item changes are received. There should never be the need to do something like “I have started from scratch 3-4 times.” if you know how to troubleshoot your issue…

What also rattles me: Why did you change so many settings? You shouldn’t need to edit addons.cfg, Why did you modify the Full Topic? If something doesn’t work would staying as default as possible not be the first step in finding the problem?

Last thing: Your sitemap doesn’t contain the item cord1… what are you expecting to see then?

1 Like

I was trying to make it conform to the plan in my head to keep things separate. Tried to follow the tasmota wiki for openhab2 integration.

I tried using the default settings on a newly flashed Sonoff only changing SSID and PW. Failed.

Good point. So many edits, dropped the ball on that one.
New simple sitemap

sitemap default label="Default" {
    Frame label="Lights" {
    Switch item=cord1 label="Cord"                   
        }                                            }

Have to look at the logs again.
Add-ons.cfg is gone. Messed with it to see if it made a difference. Thanks

OK looked at the logs and there’s a LOT crud in there from weeks of foolishness. Is it a bad idea to clear the out to make it easier to find the pertinent info?

I tried to get as simple as possible. Here’s my new configuration.

Sonoff Basic

MQTT parameters

Host : 192.168.1.200
Port: 1883
Client ID: (default) DVES_%60X
User: openhabian
Password:zxxxxxxxxx
Topic = %topic% (sonoff): sonoff
Full Topic (%prefix%/%topic%/):
%prefix%/%topic/


Mosquitto.conf

pid_file /var/run/lib/mosquitto/
log_dest /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
connection_messages true
allow_anonymous true


lights.items

Switch DVES_%60X "Trav's-lamp" { mqtt=">[mosquitto:cmnd/sonoff/POWER:command:*:default], <[mosquitto:stat/sonoff/POWER:state:default]" }


default.sitemap

sitemap default label="Default" {
      Frame label="Lights"  {
      Switch item=DVES_%60X label="Trav's lamp"
            }
}


mqtt.cfg

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

I uninstalled all bindings and actions. Only the transformations are left since I believe those were installed by default. Thinking of clearing out the log folder to see clearly what’s going on.Then reinstall the mqtt binding only.