Troubleshooting delays - HA + AD + MQTT connectivity

Hello everyone

I am trying to pinpoint the reason for delays between the moment I press an RF433 Mhz wall switch and the actual toggle on a WiFi Sonoff Basic. The setup is

RF433 wall switch - Sonoff RF Bridge - HA - AppDaemon (automation / decision taking on events) - MQTT - Sonoff Basic
  • when flipping the switch in the HA web front the WiFi switch reacts immediately
  • the processing time of the RF Bridge is 9 ms so way smaller than the ~1s delay I observe

I therefore have suspicions in the HA <-> AD area. I will troubleshoot that but wanted to know beforehand:

  • how is AD listening to HA events? is it a fast pooling approach, websockets? In other words - will AD know about a HA even instantaneously?

  • to which topics is HA listening to? My MQTT config in HA is simply a broker line and sine I can, in AD, hook to self.listen_event(... MQTT_MESSAGE ...) I guess that all topics are subscribed to?

Thank you for any pointers!

websockets

It subscribes to the topic whenever you specify a state_topic, or the equivalent in sensor or switch, or in a trigger for and automation. Basically whenever the yaml specifies it should receive a message.

I found that the delay was in the processing of incoming mqtt messages to HA. For applications that are time dependent, I now receive the MQTT messages directly into AD and process them, rather than wait for sensor or switch state changes from HA. The response time is quite acceptable, even on a Raspberry Pi 1 B+