TL;DR; I want a toggle switch in HA that is setup by MQTT discovery from ESPHome and does not bounce back when not receiving state topic.
I am building a battery powered ESP32-S2 board.
It will sleep for minutes to an hour, then wake up to send data then go back to sleep.
Wifi
Using API takes 3-10sec and time out (20sec) about 3/10 times.
MQTT takes 1-2sec and never time out, which means lots of power saved so thats what I decided to use.
I want to be able to use OTA, so I need to prevent it from sleeping.
I also want it to be plug and play, not having to setup Helper or MQTT switch in HA. Everything should be setup through MQTT discovery.
So, I have tried a switch, but it will toggle back to off after 3sec of not receiving state update. I dont know if there is a way for it to ignore state. I will try using the same command and state topic to trick it into thinking it received state, I have not tried yet.
I have googled and there are several attempts to do the same, but they all require some hands on and I want it all to be auto discovery.
The only way I found will work is a text input and then prevent if any text is sent and keep sleeping if empty. Not perfect, I would rather have a toggle switch.