I’ve managed to hook up an AC doorbell to a digital pin of an ESP32 via a PC817 optocoupler. This appears to work, however since the doorbell is AC, when it is pressed the optocoupler is activating at the frequency of the AC supply. Hence the ESPHome binary sensor is flicking on/off as the button is pressed.
Before I try a HW approach using diodes and a capacitor to rectify (?) the signal coming out of the optocoupler, is there a software solution I can use via ESPhome? Perhaps a template sensor on top of a pulse sensor that stays on? Or perhaps a sensor that waits for a stable signal before transmitting?
Or should I approach this via HW?