MQTT integration with multiple devices (Raspberry Pis)
Problem:
After Watchtower automatically updated Gladys from v4.66.8 to v4.70.0, the container started consuming ~60% CPU constantly – not just at startup, but permanently.
gladys 59.72%
The logs showed a flood of errors at startup:
NotFoundError: DeviceFeature mqtt:xxx not found
These appear to be a timing issue where MQTT retained messages arrive before Gladys has loaded its device feature cache. However, even after the startup errors stopped and logs were clean, CPU remained at ~60%.
Solution:
Downgraded back to v4.66.8 and pinned the version to prevent Watchtower from auto-updating:
yaml
gladys:
image: gladysassistant/gladys:v4.66.8
labels:
com.centurylinklabs.watchtower.enable: "false"
```
After downgrade, CPU dropped immediately to ~4%.
```
gladys 3.90%
Question:
Is this a known issue with v4.70.0? Are there plans to fix the CPU regression? I’d like to update eventually but not if it tanks performance again.
The CPU spike is very reproducible on my end. Here’s the before/after:
v4.70.0:
gladys 59.72%
v4.66.8 (same machine, same config, same moment):
gladys 3.90%
I’m running MQTT integration with 3 Raspberry Pis (relay boards + sensors). No Zigbee, no Z-Wave, Node-RED I do use.
One thing I noticed in the logs at startup with v4.70.0:
NotFoundError: DeviceFeature mqtt:xxx not found
This repeats for every MQTT device feature at every startup – looks like retained messages arrive before the device cache is ready. Could this flood of errors be causing the CPU spike? Maybe it’s specific to MQTT setups?
Your hardware is clearly good; on my side I’m on a Proxmox cluster and Gladys is on an LXE (equivalent of a VM, to keep it simple) with 6GB of RAM and 2 vCPU.
I’m not an expert for a thorough analysis, unfortunately.
However, regarding Gladys’s MQTT integration, do you use the internal integration?
From what I see in the error message, one (or several?) device is not found/recognized; you should check with MQTT Explorer whether it is visible and whether its configuration is still correct in Gladys’s MQTT integration.
Yes, I use the internal MQTT integration in Gladys.
Regarding the NotFoundError messages: I already investigated this thoroughly. The errors appear only at startup and are a timing issue – the MQTT broker delivers retained messages before Gladys has finished loading its device feature cache. After startup, the logs are completely clean and all devices work correctly. The RPis publish correctly, the topics are right, and everything is visible in MQTT Explorer.
The errors are not the cause of my problems – they’re a symptom of the startup timing. And more importantly: the CPU stays at ~60% permanently, not just during the error flood at startup.
The key point is the direct comparison:
v4.70.0 → 60% CPU constantly, same errors at startup
v4.66.8 → 4% CPU constantly, same errors at startup (timing issue exists in both versions)
So something changed between v4.66.8 and v4.70.0 that causes a CPU regression, at least on my setup with MQTT. The errors at startup are a separate (older) issue.