Seems like no one knows. Just in case someone will face this issue and find this question, I could not find anything better than shorten the workaround to
port = evaluate("${device}0_port")
This replace device
with the actual device name when it is parsed by groovy interpreter and then at runtime it evaluates the actual variable name.