Virtual 3-way switching in ESPHome w/ HA Random Toggles Occuring

I’m trying to get some virtual 3-way and 4-way switching working with ESPHome and Home Assistant but I am running into some difficulty in doing so and would appreciate some help. I had this previously working with Tasmota using DeviceGroups for the 3way functionalty but am in the process of migrating my devices to ESPHome.

Essentially for the setups I have loads attached to some Treatlife SS01S switches. I also have remote/secondary SS01S switches with no loads attached. I want to replicate the functionality of a 3-way switch setup where a press of the remote switch will toggle the load on the primary switch.

I have created some automations which trigger on the “Secondary Switch Button turned on” and have an action of “Toggle the Primary”. These seem to work fine…except I am getting random toggles periodically.

Based on the logs this seems to happen right after reboots of the secondary switch “Secondary Switch became unavailable”. I’m guessing the switches are loosing connections and rebooting and when they reboot they send a button press as the pins are initialized. Ideally of course the switches wouldn’t loose connections, but that’s a problem for future times and may be unavoidable so I’d like to try concentrating on other things.

The way I see it there are two possible ways to rectify this but I am not sure how to go about doing either one. First, and preferably, it would be possible to put a block in ESPHome that would prevent the devices form sending any button press messages over the API until X seconds after rebooting. Is there a way to do this?

Second, is it possible to put a condition on the automation in HA which blocks the automation from triggering if a device has gone unavailable for X seconds after it becomes available again?

I think the first solution would be better is the ESPHome device is generating the button press but if HA is generating the button press when the device comes back available there may be no way around doing it in HA.


Is there any information I did not provide that would be useful in answering my question?