You can find an optocoupler like this in almost every switching power supply. It is used to report the current output voltage to the input in an isolated manner. I also found the other components for the flasher in a defective switching power supply. On the back, you can see a wide insulation gap that is only bridged by two components, the optocoupler and an interference suppression capacitor.

While searching for a suitable power source, I came across a cell from an old lithium 9V block. 3 V fits very well and, like almost all the other parts, was salvaged from scrap. The flasher now produces a short flash of light every five seconds.