Force a devide to temporarly disconnect from MQTT

I have a situation where an ESP32 device on micro-python is publishing temperature data to MQTT
https://github.com/AnthonyKNorman/Xiaomi_LYWSD03MMC_for_HA
It appear to have a function that makes it restart if disconnected from MQTT. Somehow it stops publishing the data but probably stays connected to MQTT because I need to power cycle to resume its operations. Unfortunately I cannot figure out the micro-python part so I am trying to find a way to write a script in home assistant to temporarily disconnect the device to force it to reboot.

Anyone have a suggestion?
I am not a fluent programmer.

I don’t think it can be done. HA is one mqtt client, your esp32 is another mqtt client.

If you are not a programmer, have you Seen the ESPHome project?

Much easier to set up ESP devices with short yaml config for each sensor / switch etc…

There is also a remote restart switch available. https://esphome.io/components/switch/restart.html

Not that I am not a programmer but I am not fluent at micro-python. I did try ESPHome but was not able to get it setup for my devices. I have Xiaomi bluetooth devices arround the house, the ESP32 picks up the info from the devices via bluetooth and then sends the info to MQTT via wifi. The Github link I indicated above was very simple to setup and worked right away. The only thing is after some time it stops publishing and I have to power cycle the ESP32 to bring it back. If I was fluent in micro-python I would write a function that force it to reboot every 24 hours. That would solve my problem.

You could ask the developer to implement a watchdog timer or similar. It seems there is already an issue open for your problem:

Openmqttgateway has implemented support for the LYWSD03MMC

1 Like

I did and someone else did as well, I figured I would ask on here for the MQTT part.