Recipe for a Remote Control Socket that Senses Current and LightThis Recipe uses a Digi XBee Smart Plug to give on/off control over a light or appliance. The Smart Plug is a wirelessly controlled electrical socket, and it also monitors electrical current and senses ambient light. IngredientsFor this recipe you will need:
Before installing the Smart Plug, inspect the Smart Plug case until you find its serial number label. It often has a bar code at the top, and has a string underneath that begins with "SN:(S)". The serial number follows the "SN:(S)" and is a string with the digits 0-9 and the letters A-F. The serial number is a 16 digit (64 bit) hexadecimal number (a number in base 16). Write the serial number down, as you will need it for this Recipe. Plug the Smart Plug into an electrical socket where you wish to control a light or appliance, and plug the XStick into a USB port on your host computer. Keep the XStick and the Smart Plug less then a few tens of feet apart to begin with, as the two are wireless devices and can get out of range. Once you have things working, you can experiment over greater distances. Here is the Script you need to run for this Recipe:
To run this Script, you need two parameters, the "plug_address" and the "coordinator_port". The plug_address parameter is the serial number of the Smart Plug. To convert the serial number to the plug_address parameter, strip any leading zeros from the serial number and replace them with "0x". The coordinator_port parameter is the name of the USB port of the Coordinator. On *nix hosts, the USB port name is in the "/dev" directory. To see the devices in order of their creation, type "ls -lrt /dev" at a shell prompt and look near the bottom of the list for your Coordinator's USB port. As an example, for a Coordinator at USB port "/dev/cu.usbserial-00002006" and a Smart Plug with serial number "0013A200406B0263", the Script parameters are:
Running the ScriptRun the Script. Go to the Device Explorer, expand the "smart_plug" device, and click on its "1" terminal. In the dialog box, enter |