Problems with MQTT and Tasmota

I am going to tag in on this conversation if you don’t mind.
I have a similar but not exact problem that I seem to dumb to totally diagnose and correct.
My HA Core was running almost perfectly for 2 years in docker on an UnRaid system.
My unraid server borad got toasted last week so I had to quickly create a plan B. I built a system on a Lenovo ThinkCenter. I used the base of an Ubuntu Server, docker and HA.
I also added to my docker ESPhome, MQTT, and many more items that I had been using.

This is where my problem comes in I had to change the IP address of Home Assistant. Again this all worked well.

My problem is that I can no longer connect to any of my 60 plus Tasmota devices using MQTT.
The device are still reachable from my Unifi System, and I can type in the device IP and it loads.
I entered in the MQTT configuration the new IP, username, password. After a restart and going to the console I get an rc 2 error

Connect failed to 192.168.1.30:1883, rc -2. Retry in 120 sec

As well my time is off.

09:07:44.764 RSL: SENSOR = {"Time":"1970-01-03T09:07:44","ENERGY":{"TotalStartTime":"1970-01-01T00:00:00"

My server is set to the correct time and YES MQTT is working for all my other non Tasmota devices.

From reading many posts I THINK that my problems stem from the way I have my Unifi system setup.
Like DNS not being correct and not pulling the correct time server.

But to be honest I can not see a clear detailed way to fix it, or even what to look for.

Can any one give me a link or directions.
Thanks

Hi,

My problem is that I can no longer connect to any of my 60 plus Tasmota devices using MQTT.

MQTT works in exactly the reverse way - my guess is your 60x MQTT devices are trying to connect to the OLD IP address / DNS name of your old broker, and failing. I gave up trying to use DNS (stock Tasmota doesn’t support mDNS) and configured all my devices with IPv4 addresses (IPv6 didn’t work on the HASS hypervisor the last time I tried - bug report somewhere in GitHub).

If you can get the IPv4 of one Tasmota device, check the console tab - this should show the device trying to connect to the configured broker and failing. See what the messages say, and what hostname is being used.

There were some UniFi oddities (think something like limited bandwidth mode booting devices off the WLAN), but I’ve not had any issues with Tasmota or home-brew ESP8* or ESP32.

The good news is the fix might be easy:

  • If you can get to the console of your Tasmota devices, paste in commands to change the broker to an IPv4 address
    Backlog mqtthost 192.168.999.999; mqttuser <USER>; mqttpassword <SECRET>;

  • If you can get a temporary broker on the old IPv4 / DNS name, and get the clients to connect, a single command broadcast to the group topic can reconfigure all connected Tasmota devices to the new broker
    mosquitto_pub -d -h <BROKERIP --username '<USER>' --pw "<SECRET>" -t 'cmnd/tasmotas/mqtthost' -m '192.168.999.999'

Although your MQTT setup sounds otherwise complete, out of completeness, can I suggest a walk-though of all MQTT settings as a check?:

If this helps, :heart: this post!

1 Like

Thank you for the suggestions.
I will give it a try to see if it works.

If I reset the device as suggested will I physically need to pull the switch out of the wall and reflash, or will the IP settings remain so it can be done OTA

The suggestion is to change one setting only, then Tasmota will automatically restart and then try to connect to the MQTT broker - look at the device web interface tab to see the logs of connection attempts.

No need for an OTA firmware update (unless the firmware is very old - perhaps before v8 or v9 as this was when auto-discovery was added).