Working with mains power is stupid. Don't do it if you can avoid it, especially if you don't know what you are doing.
You can get a small remote power switch for $100 or so.
You can get a small remote power switch for $100 or so.
Edit: $45 on Amazon at present.
That's a very safe way of doing these things. If anyone else knows how I can reverse-engineer the signal, I'd appreciate it (I also want to make the Raspberry Pi open my garage door, same deal).