There are 2 ways to do it; c++ or GSD. Both are documented in our wiki. You can look at the src/CM11A and src/EIB to see an example done in c++ (X10/EIB), and look at the device template for Apex Destiny 6100 to see a GSD example (with Ruby).