Check for device_id being set before using