My HA install has been suffering from a lag issue that I can’t quite debug. It is related to MQTT devices as my HUE lights react immediately to control inputs. I use a stand alone install of mosquitto as the MQTT broker on my lan.
So one day my server PC died and I decided to replace it with a raspberry pi 3. After geeing mosquitto and HA running agina, low and behold the lag was gone. MQTT devices reacted almost immediately. Fast forward several months and the SD card of my pi3 dies and I have to re-install all over again. Now the MQTT device lag is back.
What’s strange here is neither my HA configuration, nor mosquitto config, nor my MQTT devices, nor my wifi (what all MQTT devices communicate over) have had changed. It’s just the server replacement that is the delta here.
I wrote a MQTT sniffer that I can run on the same Pi3 as the HA + mosquitto server and I can see the MQTT messages immediately after I do something in HA. However, it’s several seconds before I see the MQTT device respond (in my setup, all MQTT devices respond with a message indicating state of the device). I can reboot a given MQTT device and once it’s online again, it does respond immediately.
This all points to a problem with the device MQTT code. I’m exclusively using particle photon devices with the MQTT library in my code. I can see they are connected to the particle cloud by their status LEDs. If the cloud is up, so must be the MQTT connection on the device. I can’t imagine how re-configuring the mosquitto server triggers this latency on the end devices. Perhaps I need to make some new firmware for a target photon to have the LED reflect the MQTT server connection to debug this further.
Can anyone see anything I’m overlooking?