Sonoff Tasmota fails to connect to MQTT

I’ve been searching forums now for just over two weeks trying to connect and I just can’t seem to get my Tasmota (12.0.2.1) flashed Sonoff basic to connect to MQTT.

I have installed the Mosquitto addon.

In Console on my Sonoff I get this constant error message:

Hassio is installed on Raspberry Pi 4 which is sitting on reserved IP address of 192.168.86.58

My mosquitto settings:
{
“logins”: [
{
“username”: “Mqttuser”,
“password”: “Johndoe1”
}
],
“anonymous”: false,
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

My MQTT settings on Sonoff:

You didn’t read the addon instructions did you?

What error message, you forgot to say.

Also, 58 is not the same as 85.

Hi,
I’d start with a clean slate - re-flash the device (or Tasmota → Configuration → Reset Device), and delete the Mosquitto Add-on and reinstall.

HASS Mosquitto broker Add-In, MQTT integration, Tasmota Integration

Mosquitto broker Add-In

The recommended way to configure uses is shown on the Add-On Documentation tab - e.g. create a HASS user.
http://homeassistant.local:8123/hassio/addon/core_mosquitto/documentation

I personally use additional Mosquitto users, BUT these are configured not by JSON nor configuration.yaml, but again directly from the Mosquitto Add-On Configuration tab:
http://homeassistant.local:8123/hassio/addon/core_mosquitto/config
Here is a sample which can be directly pasted into the Logins text box, before restarting the broker (No JSON, just like this, with a long text password without characters you could mis-type !£$^"@~):

- username: tasmota
  password: ChangeThisPasword

HASS MQTT Integration

To get HASS to connect to Mosquitto, you need to install the MQTT integration. This is seperate from the Mosquitto broker Add-On.
This should detect settings automatically, as the broker is local to HASS.

HASS Tasmota integration

The Tasmota project is switching from HASS discovery (quite long winded, uses the MQTT integration), to Tasmota discovery (simpler, less memory) which needs the HASS Tasmota integration.
This should detect settings automatically, as the broker is local to HASS.

Tasmota

For modern Tasmota firmware, I’d recommend:

  • Leave Topic and Full Topic as default.
  • Under Configuration → Other, change Device Name and Friendly Name 1 to the name you want to see in HASS.
  • Configure MQTT user and password.
  • Go to the Tasmota Console and watch what happens.
    Tasmota should connect to Mosquitto on HASS and Just Work™.
    If not check user, password, and server host / IP address. No one changes port from 1883.
  • ONCE THE DEVICE CONNECTS AND WORKS, there are options to set the entity as a switch or light.
    • For a light, on the Tasmota console enter SetOption30 0
    • For a switch, on the Tasmota console enter SetOption30 1 (default)
    • The device SHOULD be set to Tasmota discovery by default SetOption19 0

If Tasmota doesn’t connect and you are stuck, try installing a MQTT tool like https://mqtt-explorer.com/ and see if that connects to Mosquitto. This is a great way of seeing how MQTT really works, and maintenance like removing retained configuration messages.

Tasmota advanced configuration

All settings can be entered into the console in one hit using Backlog commands:

# NB now use Tasmota integration so SetOption19 0
Backlog mqtthost 192.168.xxx.xxx; mqttuser tasmota; mqttpassword ChangeThisPasword; topic %topic%; hostname MyTasmotaName; FriendlyName MyTasmotaName; FullTopic %prefix%/%topic%/;SetOption19 0; setoption53 1;

SetOption19 0		# Use Tasmota discovery which requires the Tasmota Integration
SetOption30 0		# switch entities
SetOption30 1		# light entities

More information is in the Tasmota documentation, but is slightly confusing for the non-developer:
https://tasmota.github.io/docs/Home-Assistant/

If this helps, :heart: this post!

2 Likes

Thanks for the 58. It should be 85 and i fixed it. It is now showing connected to Home Assistant. But there is no SoneOff S31 device showing on the MQTT in the dashboard? Here is the tasmota console logs.
0:00:00.770 WIF: Connecting to AP1 Sasha Channel 1 BSSId 68:4A:76:AD:2E:06 in mode 11n as WashingMachinePlug…

00:00:03.544 WIF: Connected

00:00:03.755 HTP: Web server active on WashingMachinePlug with IP address 192.168.86.58

16:11:30.406 MQT: Attempting connection…

16:11:31.361 MQT: Connected

16:11:31.365 MQT: tele/WashingMachingPlug/LWT = Online (retained)

16:11:31.367 MQT: cmnd/WashingMachingPlug/POWER =

16:11:31.377 MQT: tele/WashingMachingPlug/INFO1 = {“Info1”:{“Module”:“Sonoff S31”,“Version”:“12.0.2.1(tasmota)”,“FallbackTopic”:“cmnd/DVES_F41931_fb/”,“GroupTopic”:“cmnd/tasmotas/”}}

16:11:31.382 MQT: tele/WashingMachingPlug/INFO2 = {“Info2”:{“WebServerMode”:“Admin”,“Hostname”:“WashingMachinePlug”,“IPAddress”:“192.168.86.58”}}

16:11:31.386 MQT: tele/WashingMachingPlug/INFO3 = {“Info3”:{“RestartReason”:“Software/System restart”,“BootCount”:1378}}

16:11:31.390 MQT: stat/WashingMachingPlug/RESULT = {“POWER”:“ON”}

16:11:31.394 MQT: stat/WashingMachingPlug/POWER = ON

16:11:32.235 QPC: Reset

16:11:35.168 MQT: tele/WashingMachingPlug/STATE = {“Time”:“2022-08-11T16:11:35”,“Uptime”:“0T00:00:11”,“UptimeSec”:11,“Heap”:27,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“Sasha”,“BSSId”:“68:4A:76:AD:2E:06”,“Channel”:1,“Mode”:“11n”,“RSSI”:100,“Signal”:-49,“LinkCount”:1,“Downtime”:“0T00:00:05”}}

16:11:35.179 MQT: tele/WashingMachingPlug/SENSOR = {“Time”:“2022-08-11T16:11:35”,“ENERGY”:{“TotalStartTime”:“2022-07-10T21:56:15”,“Total”:0.010,“Yesterday”:0.000,“Today”:0.000,“Period”: 0,“Power”: 0,“ApparentPower”: 0,“ReactivePower”: 0,“Factor”:0.00,“Voltage”:119,“Current”:0.000}}

16:16:36.208 MQT: tele/WashingMachingPlug/STATE = {“Time”:“2022-08-11T16:16:36”,“Uptime”:“0T00:05:12”,“UptimeSec”:312,“Heap”:24,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“Sasha”,“BSSId”:“68:4A:76:AD:2E:06”,“Channel”:1,“Mode”:“11n”,“RSSI”:100,“Signal”:-49,“LinkCount”:1,“Downtime”:“0T00:00:05”}}

16:16:36.218 MQT: tele/WashingMachingPlug/SENSOR = {“Time”:“2022-08-11T16:16:36”,“ENERGY”:{“TotalStartTime”:“2022-07-10T21:56:15”,“Total”:0.010,“Yesterday”:0.000,“Today”:0.000,“Period”: 0,“Power”: 0,“ApparentPower”: 0,“ReactivePower”: 0,“Factor”:0.00,“Voltage”:119,“Current”:0.000}}

16:21:36.171 MQT: tele/WashingMachingPlug/STATE = {“Time”:“2022-08-11T16:21:36”,“Uptime”:“0T00:10:12”,“UptimeSec”:612,“Heap”:24,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“Sasha”,“BSSId”:“68:4A:76:AD:2E:06”,“Channel”:1,“Mode”:“11n”,“RSSI”:100,“Signal”:-49,“LinkCount”:1,“Downtime”:“0T00:00:05”}}

16:21:36.184 MQT: tele/WashingMachingPlug/SENSOR = {“Time”:“2022-08-11T16:21:36”,“ENERGY”:{“TotalStartTime”:“2022-07-10T21:56:15”,“Total”:0.010,“Yesterday”:0.000,“Today”:0.000,“Period”: 0,“Power”: 0,“ApparentPower”: 0,“ReactivePower”: 0,“Factor”:0.00,“Voltage”:120,“Current”:0.000}}

16:25:44.615 CMD: SetOption19 0

16:25:44.621 MQT: stat/WashingMachingPlug/RESULT = {“SetOption19”:“OFF”}

16:25:49.739 CMD: SetOption19 1

16:25:49.745 MQT: stat/WashingMachingPlug/RESULT = {“SetOption19”:“ON”}

16:27:09.676 MQT: stat/WashingMachingPlug/STATUS4 = {“StatusMEM”:{“ProgramSize”:621,“Free”:380,“Heap”:23,“ProgramFlashSize”:1024,“FlashSize”:4096,“FlashChipId”:“16405E”,“FlashFrequency”:40,“FlashMode”:3,“Features”:[“00000809”,“8F9AC787”,“04368001”,“000000CF”,“010013C0”,“C000F981”,“00004084”,“00001000”,“14000020”,“00000000”],“Drivers”:“1,2,3,4,5,6,7,8,9,10,12,16,18,19,20,21,22,24,26,27,29,30,35,37,38,45,62”,“Sensors”:“1,2,3,4,5,6”}}

16:27:09.684 MQT: stat/WashingMachingPlug/STATUS5 = {“StatusNET”:{“Hostname”:“WashingMachinePlug”,“IPAddress”:“192.168.86.58”,“Gateway”:“192.168.86.1”,“Subnetmask”:“255.255.255.0”,“DNSServer1”:“192.168.86.1”,“DNSServer2”:“0.0.0.0”,“Mac”:“E8:68:E7:F4:19:31”,“Webserver”:2,“HTTP_API”:1,“WifiConfig”:4,“WifiPower”:17.0}}

16:27:09.689 MQT: stat/WashingMachingPlug/STATUS6 = {“StatusMQT”:{“MqttHost”:“192.168.86.85”,“MqttPort”:1883,“MqttClientMask”:“DVES_%06X”,“MqttClient”:“DVES_F41931”,“MqttUser”:“Mqttuser”,“MqttCount”:1,“MAX_PACKET_SIZE”:1200,“KEEPALIVE”:30,“SOCKET_TIMEOUT”:4}}

16:27:09.696 MQT: stat/WashingMachingPlug/STATUS7 = {“StatusTIM”:{“UTC”:“2022-08-11T15:27:09”,“Local”:“2022-08-11T16:27:09”,“StartDST”:“2022-03-27T02:00:00”,“EndDST”:“2022-10-30T03:00:00”,“Timezone”:"+01:00",“Sunrise”:“05:37”,“Sunset”:“20:12”}}

16:27:09.701 MQT: stat/WashingMachingPlug/STATUS9 = {“StatusPTH”:{“PowerDelta”:[0,0,0],“PowerLow”:0,“PowerHigh”:0,“VoltageLow”:0,“VoltageHigh”:0,“CurrentLow”:0,“CurrentHigh”:0}}

16:27:09.709 MQT: stat/WashingMachingPlug/STATUS10 = {“StatusSNS”:{“Time”:“2022-08-11T16:27:09”,“ENERGY”:{“TotalStartTime”:“2022-07-10T21:56:15”,“Total”:0.010,“Yesterday”:0.000,“Today”:0.000,“Power”: 0,“ApparentPower”: 0,“ReactivePower”: 0,“Factor”:0.00,“Voltage”:119,“Current”:0.000}}}

16:27:09.716 MQT: stat/WashingMachingPlug/STATUS11 = {“StatusSTS”:{“Time”:“2022-08-11T16:27:09”,“Uptime”:“0T00:15:45”,“UptimeSec”:945,“Heap”:21,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“Sasha”,“BSSId”:“68:4A:76:AD:2E:06”,“Channel”:1,“Mode”:“11n”,“RSSI”:98,“Signal”:-51,“LinkCount”:1,“Downtime”:“0T00:00:05”}}}

16:27:09.767 MQT: stat/WashingMachingPlug/RESULT = {“NtpServer1”:“pool.ntp.org”}

16:27:09.792 MQT: stat/WashingMachingPlug/RESULT = {“FullTopic”:"%prefix%/%topic%/"}

16:27:09.842 MQT: stat/WashingMachingPlug/RESULT = {“SwitchTopic”:“0”}

16:27:10.893 MQT: stat/WashingMachingPlug/RESULT = {“MqttRetry”:10}

16:27:10.918 MQT: stat/WashingMachingPlug/RESULT = {“SensorRetain”:“OFF”}

16:27:11.944 MQT: stat/WashingMachingPlug/RESULT = {“TelePeriod”:300}

16:27:11.975 MQT: stat/WashingMachingPlug/RESULT = {“Prefix1”:“cmnd”}

16:27:12.025 MQT: stat/WashingMachingPlug/RESULT = {“Prefix2”:“stat”}

16:27:12.054 MQT: stat/WashingMachingPlug/RESULT = {“Prefix3”:“tele”}

16:27:12.168 MQT: tele/WashingMachingPlug/STATE = {“Time”:“2022-08-11T16:27:12”,“Uptime”:“0T00:15:48”,“UptimeSec”:948,“Heap”:24,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“MqttCount”:1,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“Sasha”,“BSSId”:“68:4A:76:AD:2E:06”,“Channel”:1,“Mode”:“11n”,“RSSI”:100,“Signal”:-50,“LinkCount”:1,“Downtime”:“0T00:00:05”}}

16:27:12.179 MQT: tele/WashingMachingPlug/SENSOR = {“Time”:“2022-08-11T16:27:12”,“ENERGY”:{“TotalStartTime”:“2022-07-10T21:56:15”,“Total”:0.010,“Yesterday”:0.000,“Today”:0.000,“Period”: 0,“Power”: 0,“ApparentPower”: 0,“ReactivePower”: 0,“Factor”:0.00,“Voltage”:119,“Current”:0.000}}

16:27:13.101 MQT: stat/WashingMachingPlug/RESULT = {“StateText1”:“OFF”}

16:27:13.127 MQT: stat/WashingMachingPlug/RESULT = {“StateText2”:“ON”}

16:27:13.155 MQT: stat/WashingMachingPlug/RESULT = {“StateText3”:“TOGGLE”}

16:27:13.206 MQT: stat/WashingMachingPlug/RESULT = {“StateText4”:“HOLD”}

16:27:14.259 MQT: stat/WashingMachingPlug/RESULT = {“Command”:“Unknown”}

SetOption19 0 enables Tasmota’s native discovery method (which also uses MQTT but doesn’t employ Home Assistant’s MQTT Discovery method). Ensure you have installed the Tasmota integration.


NOTE

The Tasmota project deprecated support for Home Assistant’s MQTT Discovery method in favor of their own method (that’s why you need the Tasmota integration). Future releases of the Tasmota compiled firmware will no longer include support for Home Assistant’s MQTT Discovery.

  • Learn how to add code fences to posts to make logs readable - e.g. ```
  • Read the section I compiled for you on HASS Tasmota integration
1 Like

This does not work. I spent a lot of time getting MQTT BLE sensors into Home Assistant, the auto discover never listened to the packets. I was able to manually add them to my configuration.yaml but it was painful.

So create a new thread and don’t coat-tail on one from 2022.

BTLE implies not IP-based so not the Tasmota via MQTT discussed here.

My development with HASS & Tasmota discovery is INSTANT. Yes, really!