Following the changes mentioned by adding
return $response.value[0].azureADDeviceId
and then amending the adding device block with https://graph.microsoft.com/v1.0/devices(deviceId='$DeviceID')
made it instantly work! Thanks a lot, I was missing one piece of logic, you made my day :)