Need help pairing Vizio TVs

Hey folks. I need help from people who are smarter than me. We got two new Vizio TVs for Christmas and I need help getting the auth token to pair them with Home Assistant.

Here are my constraints: I’m running hassio, so I don’t have easy access to a command line. And my only other computer at the moment is a Windows laptop for work that I can’t install anything on.

I know that hassio has the pyvizio component built in, so my solution so far has been to create two command line sensors – one to initiate pairing and one to submit the pairing request with the PIN and pairing token. As convoluted of a solution as it is, it mostly works. I can get a pin to display on the TV and I can also submit a command with hard-coded pin and token (which, obviously, gets denied). When I template the command to pull in a PIN and token from other sensors (that I manually set), it just times out.

Here’s the hard-coded request I’m sending:
command: "/usr/bin/curl -k -H \"Content-Type: application/json\" -X PUT -d '{\"DEVICE_ID\": \"pyvizio\",\"CHALLENGE_TYPE\": 1,\"RESPONSE_VALUE\": \"'\"4444\"'\",\"PAIRING_REQ_TOKEN\": '\"666666\"'}' https://192.168.0.40:7345/pairing/pair"

And here’s the templated command:
command: "/usr/bin/curl -k -H \"Content-Type: application/json\" -X PUT -d '{\"DEVICE_ID\": \"pyvizio\",\"CHALLENGE_TYPE\": 1,\"RESPONSE_VALUE\": \"'\"{{ states('sensor.pin') }}\"'\",\"PAIRING_REQ_TOKEN\": '\"{{ states('sensor.pair_token') }}\"'}' https://192.168.0.40:7345/pairing/pair"

As you can see, I’ve escaped all the double-quotes in both commands. It seems, however, that these are getting stripped out when it’s sent by Home assistant. Here is what I see in the logs:

Timeout for command: /usr/bin/curl -k -H Content-Type: application/json -X PUT -d {"DEVICE_ID": "pyvizio","CHALLENGE_TYPE": 1,"RESPONSE_VALUE": "9129","PAIRING_REQ_TOKEN": 805943} https://192.168.0.40:7345/pairing/pair

So, I need someone who can help me properly format my command, so that it will be accepted. Or suggest an alternative approach, keeping in mind my constraints above. Any help is appreciated.

I’m not sure if there’s another solution but what would work is running Hassio on Linux (assuming you’re using a pi, Raspbian Lite). You still get the add-ons and snapshot feature, but you have control over the host OS and can install other tools like pyvizio to run the commands. That’s what my setup is.

Obviously it’s a nuclear option but if no one else has an idea that’s probably your best bet. Just take a snapshot and copy it to external media so you can copy it over and restore it on the new install.

Appreciate the input. If that’s the only solution, I’ll likely just wait until I have my home PC back up and running and use that.

It’s frustrating being this close… I’m still hoping someone can just help me correct my command so I can clear this last hurdle.

Any other suggestions from anyone else?

@BigBlackBear this PR adds the ability to pair the device through HA natively, so if you are willing to wait a release or two, your current solution will no longer be necessary: https://github.com/home-assistant/home-assistant/pull/31520

I happened to pair my vizio last night using pyvizio and besides needing to update my python to 3.7 it was pretty simple. Following the steps on the github.

That’s great news!

On my end, I borrowed a friend’s laptop and managed to pair my TVs pretty easily. That being said, this change makes this integration much more approachable for everyone else.