How to create a plugin for a lighting system

I’ve got a LiteTouch centralized lighting system and want to control it via the serial port. I have the serial protocol. All switches need to be created manually because there’s no mechanism to get it to spit out what is configured.

Each load is defined with a number:
01-1 Entry Way
01-2 Kitchen Lights
02-4 Office Lights
etc

If I wanted to adjust the Office Lights, I would send the following over the serial port: " 10 02-4 100\r"
This will set the brightness to 100, on a scale of 0-250.

When someone adjusts things with a switch, unfortunately, it doesn’t automatically send me the updated load level. It would need to be queried on a recurring basis with this command:

18) Return Load Status: This command will return the current load level (or terminal load level in the case of a timed fade) of a single load on a specified control module. (NOTE: Relay loads are off when the level is 0, and on at all other levels.) OPTIONS: None EXAMPLE: ? 18 91-1 ↵ ? Requests the CCU to return the current level of output 1 of control module 91. RESPONSE: ?18 XXX↵? Where XXX is the load level (000-250)

Each load is either a dimmer or relay, so when I create the switches in Vera, I will need to specify which it is (and the commands to adjust will change accordingly).

In any case, the plugin needs to be able to allow me to manually create as many switch devices as required to get them all in there. Is there a template or something I can use to create this plugin?

Have you seen this thread? It concerns the modification of the Lutron Radio RA plugin which uses RS232 so may help you.