Android real device and android emulator

I have some problem to run my tests. I have some test case that I need to run it on android emulator but if the real device will be connected this test case will be run on the real device but in desired capabilities I set emulator. How I can cancel default device in appium?

d_c = {
‘platformName’: ‘Android’,
‘deviceName’: ‘emulator-5554’,
# ‘unicodeKeyboard’: True,
# ‘resetKeyboard’: True,
‘automationName’: ‘uiautomator2’,
‘noReset’: True,
‘newCommandTimeout’: 480,
device = webdriver.Remote(‘’, desired_capabilities=d_c)

set the deviceName to ‘null’ to use the first available device (either real or emulator)

I saw in this discussion my problem:

but it’s not work for me.

Thank you for your answer.
The problem is that I set in deviceName emulator, why the appium run my test on a real device instead of the emulator?
The real device is connected and USB debugging is working but why when I set in deviceName the emulator the appium is run my test on the real device?
I meat I want to use with device that I set in deviceName not something default.

because devices are distinguished by their UIDs, not by names. See