For another option, the strategy I took was that I created global scripts to create the data points (MQTT/Modbus, virtual, meta) for my devices.
The scripts I have are:
dataPointJsonTempates
--> This script contains the minimal set of values I need to set for each type of data point.
createDataPointFunction
--> This script contains the list of points I need for each of the devices. It loops through each list of points and calls the appropriate function below.
createDeviceFunctions
--> This script creates each of the appropriate data point, event detector, and event handlers.
The intention was to detect the error generated when an unknown MQTT topic is subscribed to and create the required data points from the device id in the topic. I haven't gotten that working yet but it is a lower priority item at the moment.
For now, I have a scripting data source to call the function:
createDevice('PCU_110006');
I have created multiple 'createDataPointFunctions' scripts for the different devices I need. The same pattern is applied.
Ian