PCF8574 relay glitches on HA IoT
If you want people to view your pcb and schematic, then make it available as a pdf.
First thing that jumps out at me is no pullup resistors on the i2C. Should be two 2k2 resistors. Any bypass caps?
With the fluoro, I’d suggest placing a varistor (MOV) across the fluoro supply. Something like a S20K270 if the mains is 230VAC or a S20K140 if 110. You could scavenge some movs from a dead PC power supply. A bit of Googling should assist if you are unsure.
The root cause is most likely a transient when the mains is removed from the fluoro. This transient probably finds it way via the relay, across your circuit and back around via your power supply. Adding a mov provides a preferential path for the transient and soaks it up.
Other possible solutions are a snubber across the relay contacts using a 100nF mains rate cap and a 100R 2W metal film resistor.
Having not seen your pcb design, my guess is you don’t have enough creepage distance with your relay pins. The cheapy relays have the common pun between the low voltage coil pins. You need to ensure your pcb has slots to isolate the common from low voltage and that your lhigh voltage tracks do not come close to low voltage circuits.
Omron G2R style relays are much easier as they have sufficient distance between the coil and contacts.
I also hope you have adequate pcb track thickness and correct fusing so you don’t have a fire risk.
Keep your mains wiring away from the low voltage side.