Reverse engineering of a mains power controller.