Can I create child devices from a driver?

I'm using the Elk driver as a template for this. The Elk driver has an associated app that creates the child devices. I'd like to avoid the app altogether and just create the devices when I set up the driver.

Looking at using this for inputs:

preferences {
	input("ip", "text", title: "IP Address", description: "ip", required: true)
	input("port", "text", title: "Port", description: "port", required: true)
	input("switches", "text", title: "Switches", description "e.g. 01-1,01-2,02-A", required: true)
	input("dimmers", "text", title: "Dimmers", description "e.g. 03-1,03-2,04-A", required: true)
}

When I save these settings, can I have the driver create all of these child devices? Or do I still have to do it via an app? If I can do it in the driver, if I make a modification to the switches or dimmers list, can it delete or create devices as needed?

You can get some code ideas from this thread..

Andy

What I'm trying to do is to rewrite this driver for Vera (written in LUA) to Hubitat.

I wrote this like 6 years ago. It's a basic integration that talks over a serial port. With Hubitat, I can't hook up a USB->serial converter. So, I have an ethernet->serial converter sitting here doing nothing right now. I think I have the connection part of the driver figured out using the telnet method used in the Elk driver.

There are a couple of interesting things for this driver:

  1. The device does not send unsolicited updates over the serial port. This means that if someone changes a light via a keypad, the HE won't know unless I poll for it. If I blast the polling message for all 48 loads, the results come back out of order. So, in the LUA code, I implemented a circular queue that polls one device after another every 2 seconds. And if an update happens from the HA system, it inserts the poll for that one device at the top of the queue as a priority poll to ensure that it updated on the lighting controller. I still need to do this in the groovy code. It's not ideal, but it works.
  2. One thing I did not implement was a queue for sending commands to the unit. Right now, the vera will send all the commands quickly for a scene, and the controller doesn't pick them all up. Sometimes I need to run the scene multiple times to get all the lighting loads to update. I'll need to implement a command queue that has a delay between each command. Planning on 500ms to see if that works, and I'll raise it if needed.
  3. Dimmer levels on the controller are 0-255. In order to make this compatible with percentages, I do some math in LUA to make it work. I need to do the same thing here. Also, my LUA code does not support ramp rates, however, the controller does. So I want to implement this as well.

@cobra, I didn't see a link to the code you posted above. Do you have a link to it?

Also, any tips anyone can give me would be greatly appreciated. I've never done anything w/ groovy before.

The top line written in blue is a link

Ah sorry, it seems it was a couple links deep. Thank you!