It seems you are looking for the associate feature of ZWave. This allows you to associate for example your motion sensor with the light switch. I think you can send a command to the main ZWave device to set associations, but you should also read the manual of your devices to see how to associate. (Some devices are sleeping devices, which may require you to press a button to wake up and receive command, like set association).
br,
sambuca