Today we finished coding changes to use Autoflower with our fancy new wireless outlets. Here's a quick demonstration of me setting up a wireless outlet using Autoflower. First, we set up a new "light" device. After you add the device, you click the "pair" icon. Autoflower will repeatedly send out an on code for approximately 10 seconds after you click the button. Then you hold down the button on the wireless outlet until it goes into learning mode. Almost immediately it will receive the code and flash.
Some problems did arise during this because Autoflower needs to cycle through current device states and send out switching codes. If you were to put the outlet into learning mode during normal operation, it would learn the first of these codes that happened to be sent. Since the server and main program are separate threads, we just put a lock around the outlet switching code, so when the server gets a post to "/pair" the main program waits until it is finished repeating the code we want associated with the outlet.