Inconstant delays between frontend commands and physical switching via MQTT

Hi there,
I am currently using home assistant (running on a docker container) with one MQTT switch, properly configured into my YAML files.

I have experienced when i turn on the switch in the frontend lovelace interface, this not always responds with the same timing: it looks like it enters a sort of “stand-by mode” when it doesn’t receive an input for a certain amount of time (for example 15 minutes).

Typical scenario: the switch hasn’t been toggled for a while.

  1. I toggle it via the frontend;
  2. The physical switch actually responds after 5 to 10 seconds.
  3. I toggle it again on the frontend and now it’s responding as fast as i expect (but only if not too much time has passed since last action on it).

So, when my switch is already warmed up it’s physically responding nearly synchronously with the frontend UI.
If too much time elapses between one command and another, the new command will take an annoying amount of extra time to actually propagate to the physical switch.

I don’t know the technical specs of mqtt protocol and i’d understand if the session between the broker and the subscriber ends after a certain timeout. This pushes me to think about an automation script which could revive every mqtt connection before the timeout expires…or maybe i am interpreting everything wrong so the real issue is elsewhere.

Anyway, my objective is to fix this issue and/or to find a workaround to avoid that excessive extra delay between the frontend command and the actual physical switching operation. I am sure and pretty confident it can be done somehow!
Is there anyone who already knew a similar issue or maybe a practical motivation to such kind of behaviour? Any advice to fix this in a suitable way?

What kind off MQTT? Internal or mosquitto?
If internal, i would first try it with mosquitto in another docker container.

Sorry i forgot to mention…i already have Mosquitto running in another docker container

I don’t think this related to MQTT and HA.
Maybe the switch has some sleep delay? Wifi problems?
I had some tasmota Sonoff’s that permanently lost the wifi connection.
Sometimes there was a delay when i switched them on while they were reconnecting.

1 Like

I would connect another client to the broker to read the messages coming out of HA to see if the delay is happening within HA or with the connection to the switch.

1 Like