I have some in-wall scene controllers that I built that use a XIAO ESP32-C3 with a PCF8574 chip to create a matrix keypad. I have binary sensors crated for the on_press actions and the switches work. The issue I run into is that sometimes the switches will stop responding. The problem is that these are in-wall switches and to reboot them I have to take the whole wall switch out of the wall to cycle power.
I thought of a couple options to fix this. One would be to check for a long press on one of the keys that would cause the ESP32 to reset iself. Another option would be to have a heartbeat check-in with Home Assistant and if the heartbeat is lost, have the device reboot itself. I was trying to do the long press of one of the keys, but I can’t figure out how to impliment this. I thought I could use a “min_length: 5000ms” on the on_press action, but that doesn’t work. Also, I am not sure on how to do a full reboot of the C3 in code. How can I implement one or both of these options?
reboot_timeout (Optional, Time): The amount of time to wait before rebooting when no client connects to the API. This is needed because sometimes the low level ESP functions report that the ESP is connected to the network, when in fact it is not - only a full reboot fixes it. Can be disabled by setting this to 0s. Defaults to 15min.
Why this happens is what you should be investigating: