Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pairing #13

Merged
merged 6 commits into from
Feb 5, 2017
Merged

Add support for pairing #13

merged 6 commits into from
Feb 5, 2017

Conversation

postlund
Copy link
Owner

@postlund postlund commented Feb 4, 2017

Should work by using atvremote:

atvremote pair

And then add the remote on the Apple TV. Default pin is 1234 (which
must be correctly entered) and name is "pyatv remote". These settings
can be changed with parameters to atvremote. Currently a pairing
timer is set to 60 seconds, so the process must be finished within
that time.

NOTE: Before merging this, some work must be done with tearing down the webserver and zeroconf after the paring period is done. It currently leaks.

@postlund postlund mentioned this pull request Feb 4, 2017
@coveralls
Copy link

coveralls commented Feb 4, 2017

Coverage Status

Coverage increased (+0.4%) to 94.549% when pulling a0ad21d on pairing_process into 0c4d1c1 on master.

@coveralls
Copy link

coveralls commented Feb 4, 2017

Coverage Status

Coverage increased (+0.4%) to 94.528% when pulling e471961 on pairing_process into 0c4d1c1 on master.

@coveralls
Copy link

coveralls commented Feb 4, 2017

Coverage Status

Coverage increased (+0.4%) to 94.539% when pulling bad51c3 on pairing_process into 0c4d1c1 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.539% when pulling 6d10302 on pairing_process into 0c4d1c1 on master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.539% when pulling 6d10302 on pairing_process into 0c4d1c1 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.539% when pulling 6d10302 on pairing_process into 0c4d1c1 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.539% when pulling 6d10302 on pairing_process into 0c4d1c1 on master.

@coveralls
Copy link

coveralls commented Feb 4, 2017

Coverage Status

Coverage increased (+0.4%) to 94.539% when pulling 8df567a on pairing_process into 0c4d1c1 on master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.539% when pulling 8df567a on pairing_process into 0c4d1c1 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.539% when pulling 8df567a on pairing_process into 0c4d1c1 on master.

@robbiet480
Copy link
Contributor

I paired it but when using the login ID a 503 was thrown.

@postlund
Copy link
Owner Author

postlund commented Feb 4, 2017

What does the URLs look like?

@robbiet480
Copy link
Contributor

(pyatv) HomeAssistant/pyatv [ atvremote --address 192.168.1.214 --login_id 0000000000000001 --debug commands                                                                    pairing_process * ] 2:19 PM
DEBUG: GET URL: http://192.168.1.214:3689/login?hsgid=0000000000000001&hasFP=1
DEBUG: Data[3]: b'313033'
WARNING: Unknown data: b'103'
DEBUG: get_data: 103: None [_unknown, unknown tag]

DEBUG: GET URL: http://192.168.1.214:3689/login?hsgid=0000000000000001&hasFP=1
DEBUG: Data[3]: b'313033'
WARNING: Unknown data: b'103'
DEBUG: get_data: 103: None [_unknown, unknown tag]

Traceback (most recent call last):
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/__main__.py", line 245, in _run_application
    asyncio.wait_for((yield from cli_handler(loop)), timeout=15)
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/__main__.py", line 96, in cli_handler
    return (yield from _handle_command(args, loop))
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/__main__.py", line 173, in _handle_command
    playing_resp = yield from atv.metadata.playing()
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/internal/apple_tv.py", line 225, in playing
    playstatus = yield from self.apple_tv.playstatus()
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/daap.py", line 126, in get
    yield from self._assure_logged_in()
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/daap.py", line 177, in _assure_logged_in
    yield from self.login()
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/daap.py", line 115, in login
    resp = yield from self._do(self.session.get_data, url)
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/daap.py", line 152, in _do
    action, url, False, is_login=is_login, is_daap=is_daap))
  File "/Users/robbiet480/Repos/HomeAssistant/pyatv/pyatv/daap.py", line 155, in _do
    'failed to login: ' + str(status))
pyatv.exceptions.AuthenticationError: failed to login: 503

>>> An error occurred, full stack trace above

@postlund
Copy link
Owner Author

postlund commented Feb 4, 2017

Try adding 0x in front of the login id. I should make that more clear.

@robbiet480
Copy link
Contributor

All good now. I figured that you were adding the 0x in the code so I hadn't added it myself.

@postlund
Copy link
Owner Author

postlund commented Feb 4, 2017

Good 👍 For some reason I decided not to do that. I use a regex to decide if the identifier is a HSGID or pairing-guid, which requires 0x. Then I just pass the id along. Guess it was simple that way.

@coveralls
Copy link

coveralls commented Feb 5, 2017

Coverage Status

Coverage increased (+0.8%) to 94.928% when pulling 879c81a on pairing_process into 0c4d1c1 on master.

Should work by using atvremote:

    atvremote pair

And then add the remote on the Apple TV. Default pin is 1234 (which
must be correctly entered) and name is "pyatv remote". These settings
can be changed with parameters to atvremote. Currently a pairing
timer is set to 60 seconds, so the process must be finished within
that time.
By doing this and using a handler, it is much easier to test and the
application is also responsible of aborting stopping the pairing
process. Later, maybe a callback based API can be added so the user
can be notified when pairing is done.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.766% when pulling 85dbb71 on pairing_process into 03bcf90 on master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.766% when pulling 85dbb71 on pairing_process into 03bcf90 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.766% when pulling 85dbb71 on pairing_process into 03bcf90 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 94.766% when pulling 85dbb71 on pairing_process into 03bcf90 on master.

@postlund postlund merged commit 91f7fe0 into master Feb 5, 2017
@postlund postlund deleted the pairing_process branch February 5, 2017 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants