MQTT lights and covers not available after a while

Hello,

I have a huge problem with the recent version of Hass.io on my environment. All the lights and covers I’m using are randomly going unavailable through the day. Only way to fix it is to restart the MQTT broker or the OS. This happens about 2-5 times a day, so it’s very annoying.

What is happening is, that almost all MQTT devices go unavailable at the exact same time, and some of them recover from it shortly after, but some of them don’t. Sometimes all the devices go unavailable. Sometimes a few devices stay unaffected and online.

Weirdly enough, this is caused by the update of Home Assistant. If I restore the old version from the snapshot, then everything works fine and no device goes unavailable for many days. Then, after the update, within hours devices start to go unavailable. I do not change any configuration nor update any of the add-ons.

Can you, please, help me?

  • Home Assistant working version: 0.100.2
  • Home Assistant that are affected: 0.116.4 and 0.117.5 (latest)
  • Operating environment: Hass.io 4.14
  • MQTT broker: Add-on Mosquitto broker 5.1 (latest)
  • MQTT devices: Sonoff T1 EU 1C and 2C
  • MQTT devices OS: Tasmota 6.5.0 and 6.7.1

Following is the image of Home Assistant history, where you can see devices go unavailable. Notice the thin gray strip on most of devices (except the first 4 and the 6th). After which some devices recover and return to their previous states, but others stay gray.

Here is the MQTT log for that period of time. The gray strip ended at 1604815618 (Sun Nov 08 2020 07:06:58 GMT+0100):

1604815603: New connection from 192.168.0.51 on port 1883.
1604815603: New connection from 192.168.0.43 on port 1883.
1604815603: New connection from 192.168.0.45 on port 1883.
1604815603: New connection from 192.168.0.44 on port 1883.
1604815603: New connection from 192.168.0.46 on port 1883.
1604815603: New connection from 192.168.0.36 on port 1883.
1604815603: New connection from 192.168.0.47 on port 1883.
1604815603: New connection from 192.168.0.41 on port 1883.
1604815603: New connection from 192.168.0.38 on port 1883.
1604815603: New connection from 192.168.0.53 on port 1883.
1604815603: New connection from 192.168.0.35 on port 1883.
1604815603: New connection from 192.168.0.49 on port 1883.
1604815603: New connection from 192.168.0.40 on port 1883.
1604815603: New connection from 192.168.0.37 on port 1883.
1604815603: New connection from 192.168.0.30 on port 1883.
[INFO] found sonoff-30 on Home Assistant
1604815606: New client connected from 192.168.0.30 as DVES_650758 (p2, c1, k10, u'sonoff-30').
[INFO] found sonoff-31 on Home Assistant
1604815607: New client connected from 192.168.0.31 as DVES_C1BEEF (p2, c1, k10, u'sonoff-31').
[INFO] found sonoff-33 on Home Assistant
1604815608: New client connected from 192.168.0.33 as DVES_C1BF37 (p2, c1, k10, u'sonoff-33').
[INFO] found sonoff-51 on Home Assistant
1604815610: New client connected from 192.168.0.51 as DVES_919E94 (p2, c1, k10, u'sonoff-51').
[INFO] found sonoff-43 on Home Assistant
1604815611: New client connected from 192.168.0.43 as DVES_6509C7 (p2, c1, k10, u'sonoff-43').
[INFO] found sonoff-45 on Home Assistant
1604815612: New client connected from 192.168.0.45 as DVES_C1CC77 (p2, c1, k10, u'sonoff-45').
[INFO] found sonoff-44 on Home Assistant
1604815613: New client connected from 192.168.0.44 as DVES_9F0DDB (p2, c1, k10, u'sonoff-44').
[INFO] found sonoff-46 on Home Assistant
1604815614: New client connected from 192.168.0.46 as DVES_91B0F4 (p2, c1, k10, u'sonoff-46').
[INFO] found sonoff-36 on Home Assistant
1604815616: New client connected from 192.168.0.36 as DVES_6508E4 (p2, c1, k10, u'sonoff-36').
[INFO] found sonoff-47 on Home Assistant
1604815617: New client connected from 192.168.0.47 as DVES_9F06F1 (p2, c1, k10, u'sonoff-47').
1604815617: New client connected from 192.168.0.41 as DVES_91B0F3 (p2, c1, k10, u'sonoff-41').
1604815617: New client connected from 192.168.0.38 as DVES_650963 (p2, c1, k10, u'sonoff-38').
1604815617: New client connected from 192.168.0.53 as DVES_C1C082 (p2, c1, k10, u'sonoff-53').
1604815617: New client connected from 192.168.0.35 as DVES_65072F (p2, c1, k10, u'sonoff-35').
1604815617: New client connected from 192.168.0.49 as DVES_91B11A (p2, c1, k10, u'sonoff-49').
1604815617: New client connected from 192.168.0.40 as DVES_91AD5E (p2, c1, k10, u'sonoff-40').
1604815617: New client connected from 192.168.0.37 as DVES_9F08F7 (p2, c1, k10, u'sonoff-37').
1604815617: Client DVES_650758 already connected, closing old connection.
1604815617: New client connected from 192.168.0.30 as DVES_650758 (p2, c1, k10, u'sonoff-30').
1604815617: Socket error on client DVES_C1BEEF, disconnecting.
1604815617: Socket error on client DVES_C1BF37, disconnecting.
1604815617: Socket error on client DVES_919E94, disconnecting.
1604815617: Socket error on client DVES_6509C7, disconnecting.
1604815617: Socket error on client DVES_C1CC77, disconnecting.
1604815617: Socket error on client DVES_9F0DDB, disconnecting.
1604815617: Socket error on client DVES_91B0F4, disconnecting.
1604815617: Socket error on client DVES_6508E4, disconnecting.
1604815617: Socket error on client DVES_9F06F1, disconnecting.
1604815617: Socket error on client DVES_91B0F3, disconnecting.
1604815617: Socket error on client DVES_650963, disconnecting.
1604815617: Socket error on client DVES_C1C082, disconnecting.
1604815617: New connection from 192.168.0.34 on port 1883.
1604815617: New connection from 192.168.0.31 on port 1883.
1604815617: New connection from 192.168.0.33 on port 1883.
1604815617: New connection from 192.168.0.51 on port 1883.
1604815617: New connection from 192.168.0.32 on port 1883.
1604815617: New connection from 192.168.0.42 on port 1883.
1604815617: New connection from 192.168.0.43 on port 1883.
1604815617: New connection from 192.168.0.45 on port 1883.
[INFO] found sonoff-34 on Home Assistant
1604815618: New client connected from 192.168.0.34 as DVES_C936A4 (p2, c1, k30, u'sonoff-34').
1604815618: New client connected from 192.168.0.31 as DVES_C1BEEF (p2, c1, k10, u'sonoff-31').
1604815618: New client connected from 192.168.0.33 as DVES_C1BF37 (p2, c1, k10, u'sonoff-33').
1604815618: New client connected from 192.168.0.51 as DVES_919E94 (p2, c1, k10, u'sonoff-51').
1604815618: Client DVES_C1BF0F already connected, closing old connection.
1604815618: New client connected from 192.168.0.32 as DVES_C1BF0F (p2, c1, k10, u'sonoff-32').
1604815618: Client DVES_C1C0A1 already connected, closing old connection.
1604815618: New client connected from 192.168.0.42 as DVES_C1C0A1 (p2, c1, k10, u'sonoff-42').
1604815618: New client connected from 192.168.0.43 as DVES_6509C7 (p2, c1, k10, u'sonoff-43').
1604815618: New client connected from 192.168.0.45 as DVES_C1CC77 (p2, c1, k10, u'sonoff-45').
1604815618: Socket error on client DVES_C936A4, disconnecting.
1604815618: New connection from 192.168.0.44 on port 1883.
1604815618: New connection from 192.168.0.46 on port 1883.
1604815618: New client connected from 192.168.0.44 as DVES_9F0DDB (p2, c1, k10, u'sonoff-44').
1604815618: New client connected from 192.168.0.46 as DVES_91B0F4 (p2, c1, k10, u'sonoff-46').
1604815619: New connection from 192.168.0.36 on port 1883.
1604815619: New client connected from 192.168.0.36 as DVES_6508E4 (p2, c1, k10, u'sonoff-36').
1604815621: New connection from 192.168.0.47 on port 1883.
1604815621: New client connected from 192.168.0.47 as DVES_9F06F1 (p2, c1, k10, u'sonoff-47').
1604815627: New connection from 192.168.0.41 on port 1883.
1604815627: New client connected from 192.168.0.41 as DVES_91B0F3 (p2, c1, k10, u'sonoff-41').
1604815627: New connection from 192.168.0.38 on port 1883.
1604815627: New connection from 192.168.0.53 on port 1883.
1604815627: New client connected from 192.168.0.38 as DVES_650963 (p2, c1, k10, u'sonoff-38').
1604815627: New client connected from 192.168.0.53 as DVES_C1C082 (p2, c1, k10, u'sonoff-53').
1604815629: New connection from 192.168.0.34 on port 1883.
1604815629: New client connected from 192.168.0.34 as DVES_C936A4 (p2, c1, k30, u'sonoff-34').
1604817376: Saving in-memory database to /data/mosquitto.db.
1604819177: Saving in-memory database to /data/mosquitto.db.
1604820979: Saving in-memory database to /data/mosquitto.db.
1604822779: Saving in-memory database to /data/mosquitto.db.
1604824580: Saving in-memory database to /data/mosquitto.db.
1604826382: Saving in-memory database to /data/mosquitto.db.
1604828182: Saving in-memory database to /data/mosquitto.db.
1604829983: Saving in-memory database to /data/mosquitto.db.

Example of the light config:

- platform: mqtt
  name: "sonoff_33"
  availability_topic: "tele/sonoff-33/LWT"
  command_topic: "cmnd/sonoff-33/POWER"
  json_attributes_template: '{{ {"Uptime": value_json.Uptime, "Vcc": value_json.Vcc, "SSId": value_json.Wifi.SSId, "BSSId": value_json.Wifi.BSSId, "Channel": value_json.Wifi.Channel, "RSSI": value_json.Wifi.RSSI} | tojson }}'
  json_attributes_topic: "tele/sonoff-33/STATE"
  payload_available: "Online"
  payload_not_available: "Offline"
  qos: 1
  state_topic: "stat/sonoff-33/POWER"