The file to which you provided a link no longer exists. Can you please upload it again?
I got your message about the solution to this. I wanted to share it with the community as it might help other users. If you believe that the following has answered your questions, please mark this as a solution.
You can use the following function in place of $add_device. The following can only be used inside the device generator code as it requires initialization of some internal data structures.
gen_name : string, // Same as "name" argument to $add_device
loc : ic_transform, // Vector [@to, [x,y], @flip, “<flip_specifier>”, @rotation, <rotation_in_degrees>] where "<flip_specifier>" can be the string "none", "horizontal", "vertical", or "both"
params : optional vector, // Vector of vectors containing parameter name values, i.e. [["name1", "value1"], ["name2", "value2"]]
instance_name : string // Same as $add_device
Let me verify and reply back in a couple of days as I'm currently swamped with work.