The methods Module::onAdd and Module ::onSave are only called on loading/saving a patch, but not on loading/saving a preset.
If I want to save e.g. a wave file within a preset, I could call Module::onSave from Module::dataToJson. But then every time the autosave thread runs, the wave file will also be saved.
Has anyone found a way to distinguish between Module::dataToJson called from saving a preset manually and called from the autosave thread?
No, but you can put a text widget on the display that presents a name. This could be set in a menu, or even editable in-place. This text would of course be an entry in the json for the module, hence part of any preset that gets saved/loaded.