MQTT - unstable Home assistant [easy fix]

Hello fellow HASS enthusiasts,

I would like to share with you my struggle the past weeks of getting and maintaining a stable HASS configuration.
The possibilities and future potential of Home Assistant kept me going.

The situation:
1 Raspberry Pi 3 with HASS.io (Started with VM - ubuntu - Home assistant in VE - switch to Pi because of struggle).
Multiple Wemos and Sonoff devices that all communicate through MQTT. (find some of my code here)
Embedded MQTT broker, configured as:

mqtt:

Problem: Memory and CPU usage slowly increases over time (measured with system monitor component) to the point that the response to button presses and switching lights on an off became slow and automations did not respond.
Resulted in timeout errors after 2 or 3 days, depending on your memory and CPU. And most importantly a low WAF and WAF trust.

This is where it gets tricky and what is not shared enough in my opinion (that is why I like to share this post).
Solution: There is a memory leak in the embedded broker and you should use an external one, for example HASS Mosquitto addon.

During my search I also see people automatically rebooting every night… I did not want to do that.
Hope this can solve some issues for these and other people that are searching.
I am not sure how I could have missed the simple solution of switching to another broker.

2 Likes

That’s kind of an accepted fact, it’s fancy to have an embedded MQTT broker, but for a real environment, it’s better to let a separate Mosquitto instance run.

Maybe this accepted fact should be written down somewhere, maybe as a note at the embedded MQTT page:

Find Pull request here, hope I do it right

1 Like