Consider changing the delivery service to not use the deveui as the Ubidots label.
This causes a problem when creating new logical devices and mapping them to existing TTN phyiscal devices because even though a new logical device is created within IoTa, when the data is sent to Ubidots using the deveui as the device label Ubidots will find and use the existing device (from the previously mapped device).
Make the change here
The Ubifunction mentioned in the comment has been disabled so is not a problem.
The TTN special case can be removed so the else clause handles TTN devices.