Rather new to home automation, home assistant, Zigbee, MQTT, the lot. I might have a problem with MQTT. Or not.
My setup is a RPi 4B/2Gb/wired ethernet/ Raspbee(=Conbee) with Hass.io. 5 Trådfri bulbs. That’s all working quite nicely.
I have Raspberry Pi Zero (on wired ethernet) with a DHT sensor and a PIR sensor. And I have Mosquitto broker on a separate Raspberry Pi Zero W.
The sensors are working, I can send readings/detect motion and see both appear as MQTT messages on the broker and in HA.
I added an automation to HA (my first) to change the lights when movement is detected. It’s working…but…
It takes 5 seconds between the PIR being triggered and the MQTT msg to arrive at both the broker and HA. At first I suspected the Wifi, but after connecting the broker to wired ethernet, it’s the same. However, when I Publish a message from HA, it arrives at the broker instantly.
I’m unsure if the 5 second delay would be a real problem, although I can imagine 5 seconds is rather long for me, when half asleep stumbling into the bathroom in the middle of the night. For now, however, I just want to understand what’s going on, what’s causing the problem.
I don’t think it’s the PIR; i added a buzzer (should have mentioned that!) as an audible indicator. Between the beep (thus the PIR detected motion) and the msg arriving at the broker (and HA) there’s this 5 seconds delay.
…Just tested by removing the PIR and making the GPIO high by manually connecting it to 3.3V. The beep is instantly, the msg arrives 5 seconds later.
I also changed the GPIO pin, but same result: 5 seconds delay.
Additionally:
The Raspbian version I’m using is the full version; I just tested with the latest light version, but the delay remains the same.