I need an advice, so I have a plan to change all of the lamp switch in my room using relay. But I don't quite understand if using relay for a long term usage is safe. How do I know if it's safe and if it doesn't, how to make it safer or how to make the safety system? Thanks!
The relay contacts are isolated from the coil so it is safe to switch power line voltage.
Of course it has to be rated to handle the voltage & current (some safety margin is a good idea) and it has to be wired correctly and insulated do you can’t touch the lethal voltages, etc.
Most of the “danger” is when you are building and testing/troubleshooting the thing… That’s when you are most likely to touch a dangerous voltage or short something out. I don’t always do this, but once when I was playing-around with a new power-line circuit I wired-up a 12VAC transformer with a 12V light bulb so I could test everything at low voltage AC first.
Although regular relays are mechanical, they can last many-many years. I’ve been working in electronics for a long time and I think I saw a relay "go bad"only once (in a car’s engine compartment).