Need Help! MQTT Non-Blocking

Hi,

I am working on my home automation project.
The intent is for the switch to work even when NOT connected to MQTT Server and WiFi.
I am using internal code to control the switch and relays.

But the MQTT loop is blocking the code.

Can you help with a code structure, the MQTT and WiFi connectivity should NOT block the switch function.

Appreciate your help.

Thanks,
Abhay

Have you looked at Switch Template?
You’ll be able to make a “fake” switch that switches on and off, even if it doesn’t get the right result.