Take a look at the Semantic model. It is very handy in associating related items without using the “naming pattern” trick. For example, you can send a command to all lights in the room where your motion sensor triggered.
Furthermore, jruby library makes working with semantics easier.