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

No Soundbar Pairing #4

Closed
arthurlt opened this issue Feb 11, 2018 · 16 comments
Closed

No Soundbar Pairing #4

arthurlt opened this issue Feb 11, 2018 · 16 comments

Comments

@arthurlt
Copy link

I successfully paired my Vizio TV, but can't seem to get my SmartCast Sound Bar 3821-D6. It has no display and no way to get a PIN.

pi@HomeControl:~ $ pyvizio --ip 192.168.86.205 pair
INFO:pyvizio.cli:Initiating pairing process, please check your TV for pin upon success
/home/pi/.local/lib/python3.5/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
INFO:pyvizio.cli:Challenge type: 6
INFO:pyvizio.cli:Challenge token: 908397
pi@HomeControl:~ $ pyvizio --ip 192.168.86.205 pair_finish --ch_type=6 --token=908397
Usage: pyvizio pair_finish [OPTIONS]

Error: Missing option "--pin".
pi@HomeControl:~ $ 
@ds8k
Copy link

ds8k commented Feb 11, 2018

The soundbar starts playing a sound so it's definitely in pairing mode and expecting a response. I've managed to get PAIRING_DENIED by assuming the pin is default 0s:

$ pyvizio --ip=192.168.86.51 pair_finish --ch_type=6 --token=908397 --pin=0000
INFO:pyvizio.cli:Finishing pairing
INFO:urllib3.connectionpool:Starting new HTTPS connection (1): 192.168.86.51
/usr/lib/python3/dist-packages/urllib3/connectionpool.py:732: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html (This warning will only appear once by default.)
  InsecureRequestWarning)
ERROR:pyvizio.vizio:Failed to execute command: Unexpected response PAIRING_DENIED: Pairing request denied

But it's inconsistent. Most of the time I get CHALLENGE_INCORRECT

@exiva
Copy link

exiva commented Mar 30, 2018

How does pairing work in the official app with a soundbar? Someone asked about soundbar pairing on the api docs and never responded.

@arthurlt
Copy link
Author

It plays a sound and then you press the volume up button on the sound bar to confirm.

@ds8k
Copy link

ds8k commented Mar 30, 2018

@arthurlt This is incorrect. Pushing volume up increases the volume of the pairing noise the soundbar starts to make. You need a pin to finish pairing using pyvizio.

@arthurlt
Copy link
Author

@ds8k @exiva asked how the official app worked.

@ds8k
Copy link

ds8k commented Mar 30, 2018

@arthurlt oh wow, my bad! Sorry about that

@anaisbetts
Copy link
Contributor

I managed to figure this out from another post on GitHub, use the pin 0000 and make sure to pass --ch_type 6 to pair finish

@ds8k
Copy link

ds8k commented Apr 18, 2018

@paulcbetts What model soundbar are you using? I tried using zeroes as the pin previously and had no luck.

INFO:pyvizio.cli:Challenge type: 6
INFO:pyvizio.cli:Challenge token: 779416

pyvizio --ip=192.168.86.51 pair_finish --ch_type=6 --token=779416 --pin=0000
INFO:pyvizio.cli:Finishing pairing
INFO:urllib3.connectionpool:Starting new HTTPS connection (1): 192.168.86.51
ERROR:pyvizio.vizio:Failed to execute command: Unexpected response CHALLENGE_INCORRECT: Challenge incorrect

EDIT: Ignore that! Turns out you need to push the volume up button on the soundbar once after it starts beeping. Then you can run pair_finish

@vkorn
Copy link
Collaborator

vkorn commented Apr 28, 2018

I don't have soundbar unfortunately, so can't test myself.
If anyone can confirm that @paulcbetts solution works, I'll add it to the doc.

@ds8k
Copy link

ds8k commented Apr 29, 2018

@vkorn Can confirm. Begin the pairing process like normal, tap the physical Volume Up button on the soundbar, then use 0000 as the pin

@jeradM
Copy link

jeradM commented Apr 29, 2018

I can confirm that this method works for my soundbar as well. However, at least for the model soundbar that I have, an auth token is not required to control any function of the speaker. All of the functionality I need (power, volume/mute, source selection) works without supplying an auth token.

In addition, most of the TV API endpoints and remote codes don't work for the SmartCast speakers. I created a separate library for them so I could integrate my soundbar into Home Assistant. This is still somewhat of a work in progress and I haven't quite figured out how direct volume selection works (partially works, but only accepts values up to 10), but most of the functionality is there and the hass component is working.

@anaisbetts
Copy link
Contributor

anaisbetts commented Apr 30, 2018

@jeradM Maybe once you get this working we can just get this merged into pyvizio as a related API? Then move up the stack and fix up the Home Assistant integration to expose a separate component that uses the new pyvizio API. I'm also in this for the Home Assistant Integration (and specifically, the volume setting)

@Breakerz
Copy link

I got success to obtain my access token using : https://github.com/exiva/Vizio_SmartCast_API
I got Vizio Sound Bar 5.1 model SB3651-E6 (from Costco)
I had to use the port 9000 to query the api.
After i had to use pyvizio with --ip=192.1.1.222:9000 to set the port
The pyvizio package work partially, I think the URI is different for this model... I can power on/off, increase/decrease/mute the volume... no success with the input commands. Also the Home Assistant component dont load. Will continue to test.

@raman325
Copy link
Owner

raman325 commented Mar 13, 2019

I built this: https://github.com/raman325/pyviziosoundbar

It's essentially a fork of pyvizio with auth removed and the key mappings updated. I made some small tweaks that didn't affect functionality as I was trying to reverse engineer the code.

If we wanted to merge these changes into pyvizio as @paulcbetts suggested, here's how I was thinking it could be done:

  • add a 'device type' parameter to CLI and all methods in pyvizio.py which defaults to tv (options are soundbar or tv)
  • in cli.py we can just add an optional parameter to the base CLI command for device type and pass it to the base methods)
  • for the _invoke_api_auth method, use invoke_api_auth if tv, _invoke_api if soundbar, and raise an exception if device_type is invalid
  • for key mappings, create a new KeyCodes class in protocol.py which is specifically for soundbars, and then reference the appropriate class where necessary. the key mappings ive found to work are a subset of the existing keys, but if someone figures out the key mappings to skip to next or previous, which I haven't been able to find, it would be trivial to add them in

For the vizio component in HA, we could do the same thing triggered by a new optional config parameter for device type. There may be some other changes there (I can't figure out how to skip forward or back so those commands would not be supported until someone finds the right keys, and in testing, the volume options go from 0-31 instead of 0-100 so may have to adjust the volume command).

Thoughts? The alternative is to figure it out based on the model (mine is SmartCast Sound Bar 4031-D5) but I would need help verifying that "Sound Bar" is included in the model for all of their sound bars.

@vkorn would like to hear your thoughts since you manage the package and would need to approve a PR with these changes. I'd be happy to do the work since I have most of the sound bar specific work done and have an idea in my head of what changes I'd need to make to build what I proposed

@raman325
Copy link
Owner

Decided to give it a shot and submitted this draft PR: #18

Let me know if you have any feedback

@raman325
Copy link
Owner

PR was approved so this shouldn't be an issue anymore if you specify the right device type. See the updated docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants