The $DeviceName$ variable does not work as intended. It actually evaluates as $DeviceName (without the trailing $). This means that $DeviceNameOrAlias$ does not work as well since it will evaluate the $DeviceName portion and not the full expression.