Having said all that, which took all day as I was doing other things and writing the code. So...
Attached is my version of using templates for collections. It is inspired (I think that's the best word) by your code.
Things it does:
- Configuration:
- Add the collection template field.
- For both the collections column and template, add a checkbox to enable/disable. For the columns, it will default to enabled to match the current behaviour.
- The two fields are independent and either or both can be used.
- If the checkboxes are checked and the fields are empty, nothing will be done with it.

- The driver has changes for the above options and a couple of other small changes.
- The "get_collections" method is where action is.
- The collections template format is added as a parameter.
- Instead of just passing in the serial number, I am passing in a dictionary of what I think could be useful. What is being passed in is:
- serial_number
- firmware_version - a tuple like (4,32,19501)
- display_firmware_version - will look like "4.32.19501"
- dbversion
I considered adding the device name, but, that is already available with "connected_device_name('main')".
- I have stripped out a lot of stuff that wasn't being used. I did not understand what was happening here when I took over the driver maintenance, I hated the code and have not revisited it.
I have done some testing, but nowhere near enough. It seems to work with the different combinations of the options. And the collection template I have been using is:
Code:
program:
globals(serial_number='N7828A0018128');
collections = '';
if serial_number == 'N7828A0018128' then
collections = connected_device_name('main')
fi;
if (connected_device_uuid("main") == '30c617bc-d1e4-4cc0-bc69-ef7ca6ab88c9') then
collections = list_union(collections, 'connected_device_uuid', ',')
fi;
return collections
I'm not completely sure if the configuration is right. I am looking for the method that will be easy to explain. I think this is it, but, I know that no matter what I do, sooner or later, I'll be writing a post thinking, "How do I explain it simpler than that?" If someone has a better idea, I'm open to it. Though I might ask you to write the help