Suggestion on Power supply design
That's not going to work. 500mA is way too much to ask of a transformerless supply.

Use a phone charger for your 5V and find a 5V relay, or if you must use a boost converter to make 12V.