Yes, you are able to do this, however you have some problems with your code, you need to read the method signatures more closely to see what has changed when you are programming in our system. Also, the namespace of most of our drivers is hubitat. So for you example addChildDevice method, it should be coded like this:
addChildDevice("hubitat", "Virtual Contact Sensor", "${device.deviceNetworkId}-ep${i}", [name: "${device.displayName} (Contact${i})", isComponent: false])