Have you seen our amidiauto
utility? It automatically makes the virtual MIDI connections whenever hardware changes are detected as well as on system startup. See my post here for an example config for an idea what it can do: Midi connection manager - #7 by Giedrius
Only caveat is at the moment it works only with devices’ or softwares’ first pair of in out ports. We’ll have to upgrade the utility, so it works well with the rest of Midihub’s ports.