async def pair_with_device(loop):
    """Make it possible to pair with device."""
    my_zeroconf = Zeroconf()
    details = conf.AppleTV('127.0.0.1', 'Apple TV')
    details.add_service(conf.DmapService('login_id'))
    atv = pyatv.connect_to_apple_tv(details, loop)

    atv.pairing.pin(PIN_CODE)
    await atv.pairing.start(zeroconf=my_zeroconf, name=REMOTE_NAME)
    print('You can now pair with pyatv')

    # Wait for a minute to allow pairing
    await asyncio.sleep(60, loop=loop)

    await atv.pairing.stop()

    # Give some feedback about the process
    if atv.pairing.has_paired:
        print('Paired with device!')
        print('Credentials:', atv.pairing.credentials)
    else:
        print('Did not pair with device!')

    my_zeroconf.close()
async def pair_with_device ( loop ) : my_zeroconf = Zeroconf ( ) details = conf . AppleTV ( '127.0.0.1' , 'Apple TV' ) details . add_service ( conf . DmapService ( 'login_id' ) ) atv = pyatv . connect_to_apple_tv ( details , loop ) atv . pairing . pin ( PIN_CODE ) await atv . pairing . start ( zeroconf = my_zeroconf , name = REMOTE_NAME ) print ( 'You can now pair with pyatv' ) await asyncio . sleep ( 60 , loop = loop ) await atv . pairing . stop ( ) if atv . pairing . has_paired : print ( 'Paired with device!' ) print ( 'Credentials:' , atv . pairing . credentials ) else : print ( 'Did not pair with device!' ) my_zeroconf . close ( )
Make it possible to pair with device.