Copy deviceIndex into the device_index property

Prior to this patch the device_index of an attachment was always shown
as zero.

Addresses issue #1631