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:
--> This script contains the minimal set of values I need to set for each type of data point.
--> 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.
--> 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:
I have created multiple 'createDataPointFunctions' scripts for the different devices I need. The same pattern is applied.