Get full device ID rather than just the last digit

Using just the last digit can cause problems, as per issue #22.