Device IDs are not considered persistent. This is true across Mac OS versions, and especially true for external drives.
For example, in the current OS version, disk0 is the internal physical drive but it holds a container ('virtual drive') that is your (possibly-encrypted, possibly RAIDed) OS volume that is mounted as disk1. Older OS versions would have just mounted disk0, so your boot drive could be disk0 or disk1 depending on the OS version.
More importantly, with external drives, they are labelled in the order they are mounted. Since you explicitly indicated this is an external drive, it could be disk2 today (the first externally-attached drive), or it could be disk3 or disk4 if other drives have been attached. The likelihood of this depends entirely on your environment - if you never attach/detach other drives, USB keys, network mounts, etc. then your device IDs are likely to be more consistent. However, since it's not guaranteed, I'd recommend going with the above approach that dynamically identifies the device ID.