devId = None
devices = device_repository.get_all_devices("CODESYS Control Win V3")
for device in devices:
devId = device.device_id
proj = projects.primary
# delete existing testdev device
existing = proj.find('testdev')
if len(existing) > 0:
existing[0].remove()
# add device
proj.add('testdev', devId)
apps = proj.find('Application', True)
if len(apps) > 0:
app = apps[0]
tc = app.create_task_configuration()