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

2020 Vizio TVs Return URI Not Found on version check #114

Closed
yurdle opened this issue Nov 12, 2020 · 23 comments · Fixed by #116
Closed

2020 Vizio TVs Return URI Not Found on version check #114

yurdle opened this issue Nov 12, 2020 · 23 comments · Fixed by #116

Comments

@yurdle
Copy link

yurdle commented Nov 12, 2020

The version endpoint on 2020 Vizio TVs appears to have moved to /menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information/version, while older devices remain at /menu_native/dynamic/tv_settings/system/system_information/tv_information/version as pyvizio is currently written to use.

I had enough know-how to find the issue, but not enough to know how to fix it.
Likely needing a condition, or something like try one, if fail, try the other?

I've only had the ability to test this against a V405-H9M myself and found it while trying to pair it with Home Assistant, but also saw this reported by other Home Assistant users: https://community.home-assistant.io/t/vizio-smartcast-tv-cannot-connect/240378/2

Log snippet from Home Assistant below:

2020-11-11 22:28:58 DEBUG (MainThread) [pyvizio.api._protocol] Using Command: GetVersionCommand({'_url': '/menu_native/dynamic/tv_settings/system/system_information/tv_information/version', 'item_name': 'VERSION', 'default_return': None})
2020-11-11 22:28:58 DEBUG (MainThread) [pyvizio.api._protocol] Using Request: {'method': 'get', 'url': 'https://192.168.1.102:7345/menu_native/dynamic/tv_settings/system/system_information/tv_information/version', 'headers': {}}
2020-11-11 22:28:58 DEBUG (MainThread) [pyvizio.api._protocol] Response: {'STATUS': {'RESULT': 'URI_NOT_FOUND', 'DETAIL': 'URI not found'}, 'URI': '/menu_native/dynamic/tv_settings/system/system_information/tv_information/version'}
2020-11-11 22:28:58 ERROR (MainThread) [pyvizio] Failed to execute command: unexpected status URI_NOT_FOUND: URI not found

And curl results against each endpoint:

$ curl -k https://192.168.1.102:7345/menu_native/dynamic/tv_settings/system/system_information/tv_information/version
{"STATUS": {"RESULT": "URI_NOT_FOUND", "DETAIL": "URI not found"}, "URI": "/menu_native/dynamic/tv_settings/system/system_information/tv_information/version"}
$ curl -k https://192.168.1.102:7345/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information/version
{"STATUS": {"RESULT": "SUCCESS", "DETAIL": "Success"}, "ITEMS": [{"HASHVAL": 341066122, "NAME": "Version:", "VALUE": "1.10.15.1-2", "READONLY": "TRUE", "CNAME": "version", "TYPE": "T_STRING_V1"}], "HASHLIST": [731341160, 2266556823, 1317704272, 116765155], "URI": "/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information/version", "PARAMETERS": {"FLAT": "TRUE", "HELPTEXT": "FALSE", "HASHONLY": "FALSE"}}
@raman325
Copy link
Owner

thanks! I am curious if other data points have also moved to this new endpoint. Can you run curl on /menu_native/dynamic/tv_settings/system/system_information/tv_information and paste the output here?

@yurdle
Copy link
Author

yurdle commented Nov 13, 2020

Here is the results of the endpoint you requested:
$ curl -k https://192.168.1.102:7345/menu_native/dynamic/tv_settings/system/menu_native/dynamic/tv_settings/system/system_information/tv_information {"STATUS": {"RESULT": "URI_NOT_FOUND", "DETAIL": "URI not found"}, "URI": "/menu_native/dynamic/tv_settings/system/menu_native/dynamic/tv_settings/system/system_information/tv_information"}

But also grabbed the below, in case it's more what you were looking for:
$ curl -k https://192.168.1.102:7345/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information {"STATUS": {"RESULT": "SUCCESS", "DETAIL": "Success"}, "HASHLIST": [2911612711, 943609066, 2233333702, 3936475927], "GROUP": "G_TV_INFORMATION", "NAME": "TV Information", "PARAMETERS": {"FLAT": "TRUE", "HELPTEXT": "FALSE", "HASHONLY": "FALSE"}, "ITEMS": [{"HASHVAL": 902048810, "NAME": "Cast Name:", "VALUE": "*** Room TV", "READONLY": "TRUE", "CNAME": "cast_name", "TYPE": "T_STRING_V1"}, {"HASHVAL": 734634561, "NAME": "Serial Number:", "VALUE": "21LINIZALW*****", "READONLY": "TRUE", "CNAME": "serial_number", "TYPE": "T_STRING_V1"}, {"HASHVAL": 2192867982, "NAME": "Model Name:", "VALUE": "V405-H9", "READONLY": "TRUE", "CNAME": "model_name", "TYPE": "T_STRING_V1"}, {"HASHVAL": 341066122, "NAME": "Version:", "VALUE": "1.10.15.1-2", "READONLY": "TRUE", "CNAME": "version", "TYPE": "T_STRING_V1"}, {"HASHVAL": 1645851238, "NAME": "Cast Version:", "VALUE": "1.40.169511", "READONLY": "TRUE", "CNAME": "cast_version", "TYPE": "T_STRING_V1"}, {"HASHVAL": 3508409467, "NAME": "Chromium Version", "VALUE": "MTKC-4.2.427.1", "READONLY": "TRUE", "CNAME": "chromium_version", "TYPE": "T_STRING_V1"}, {"HASHVAL": 763127665, "NAME": "SCPL Version:", "VALUE": "1.0.13_1.0.13.29_2031_0008", "READONLY": "TRUE", "CNAME": "scpl_version", "TYPE": "T_STRING_V1"}, {"HASHVAL": 1942851150, "NAME": "AirPlay Version:", "VALUE": "25.06", "READONLY": "TRUE", "CNAME": "airplay_version", "TYPE": "T_STRING_V1"}, {"STATUS": {"RESULT": "PROXY_ERROR", "DETAIL": "Proxy error"}, "READONLY": "TRUE", "CNAME": "google_home_version", "TYPE": "T_STRING_V1", "NAME": "Google Home Version"}, {"HASHVAL": 1850115353, "NAME": "Amazon Version", "VALUE": "1.3.2-hotfix-gc-config\r\n", "READONLY": "TRUE", "CNAME": "amazon_version", "TYPE": "T_STRING_V1"}, {"HASHVAL": 2263534310, "NAME": "Source Type:", "VALUE": "SMARTCAST", "READONLY": "TRUE", "CNAME": "source_type", "TYPE": "T_STRING_V1"}, {"HASHVAL": 2867215621, "NAME": "Resolution:", "VALUE": "720p", "READONLY": "TRUE", "CNAME": "resolution", "TYPE": "T_STRING_V1"}, {"HASHVAL": 2062668895, "NAME": "Vertical Frequency:", "VALUE": 0, "READONLY": "TRUE", "CNAME": "vertical_frequency", "TYPE": "T_VALUE_V1"}, {"HASHVAL": 2286905819, "NAME": "VRR", "VALUE": "NO", "READONLY": "TRUE", "CNAME": "vrr", "TYPE": "T_STRING_V1"}, {"HASHVAL": 2552409782, "NAME": "Source Audio", "VALUE": "STEREO", "READONLY": "TRUE", "CNAME": "source_audio", "TYPE": "T_STRING_V1"}, {"HASHVAL": 2296608886, "NAME": "Audio Type Out", "VALUE": " ", "READONLY": "TRUE", "CNAME": "audio_type_out", "TYPE": "T_STRING_V1"}, {"HASHVAL": 2172934655, "NAME": "HDR", "VALUE": "NO", "READONLY": "TRUE", "CNAME": "hdr", "TYPE": "T_STRING_V1"}, {"HASHVAL": 403726857, "NAME": "Netflix ESN", "VALUE": "VIZSCMG3060000000******", "READONLY": "TRUE", "CNAME": "netflix_esn_native", "TYPE": "T_STRING_V1"}, {"HASHVAL": 3398976475, "NAME": "Country", "VALUE": "USA", "READONLY": "TRUE", "CNAME": "country", "TYPE": "T_STRING_V1"}], "URI": "/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information", "CNAME": "tv_information", "TYPE": "T_MENU_V1"}

Let me know if you need anything else, happy to grab it.

@raman325
Copy link
Owner

Thank you, the second was indeed what I was looking for!

@raman325
Copy link
Owner

Can you try pulling down the latest from master here: https://github.com/raman325/pyvizio and checking those commands? The commands would be pyvizio --ip 192.168.1.102 --auth <TOKEN> get-esn|get-version|get-serial-number. The changes I have made are a bit of a hack to try one then the other endpoint but hopefully it at least unblocks this issue and I can fix some of the Home Assistant issues

@yurdle
Copy link
Author

yurdle commented Nov 13, 2020

I think I did it right. I did a git clone https://github.com/raman325/pyvizio.
Validated I had the right code by checking for the changes in _protocol.py.
Ran python3 setup.py install
Install completed with Finished processing dependencies for pyvizio==0.1.57

Ran pyvizio --ip 192.168.1.102 --auth <TOKEN> get-esn|get-version|get-serial-number with my actual token and ran each command separately.
Returned:
ERROR:pyvizio.cli:Couldn't get esn
ERROR:pyvizio.cli:Couldn't get version
ERROR:pyvizio.cli:Couldn't get serial number

I ran the same commands against my 2018 TV and they were successful in returning results on this same build.

@raman325
Copy link
Owner

raman325 commented Nov 17, 2020

Yes that's right because I bumped the version. It might be easier to run pip install -I path/to/repo.

Can you try the latest? I don't see how it would resolve the issue, but it's worth trying. Did you also happen to look at the additional endpoints I listed in _protocol.py and verify that they are what you expect? If not, do you mind checking?

I don't see what could be wrong aside from possibly the changes I just made

@yurdle
Copy link
Author

yurdle commented Nov 17, 2020

Ah okay. I uninstalled, re-pulled the repo, and installed as suggested. Still seeing same issues.

The new alt endpoints all look correct. To be sure, I copy/paste them and tested a curl against each. Version and serial returned success and ESN returned "requires pairing, since I didn't include any auth headers.

I'm not sure I follow how the conditioning works in pyvizio/__init__.py, thought I'm still very much a python novice.
Wouldn't this always return the result of GetSerialNumberCommand, even if it's a error?

        item = await self.__invoke_api(
            GetSerialNumberCommand(self.device_type),
            log_api_exception=log_api_exception,
        ) or await self.__invoke_api(
            GetAltSerialNumberCommand(self.device_type),
            log_api_exception=log_api_exception,
        )

@raman325
Copy link
Owner

__invoke_api should return None if the endpoint is not found, so or basically says run the second command if the first one doesn't work.

With that said, the latest changed this logic to be more explicit about calling the first and then calling the second.

I will spend some more time looking at this later.

@raman325
Copy link
Owner

just to confirm @yurdle when you looked at the latest code, do you still see the or logic?

@yurdle
Copy link
Author

yurdle commented Nov 17, 2020

I don't when I check now. But I also see the last commit was 14 hours ago, so I must have been looking at an older commit when I was poking around and trying to understood earlier.
My testing this morning was definitely using the latest, validated the or logic is not present there as well.

@raman325
Copy link
Owner

Sorry to keep bugging you about this but can you pull the latest again and try again? I wish I had a device that had this behavior so that I could test locally 😞

@yurdle
Copy link
Author

yurdle commented Nov 18, 2020

No apologies needed. Happy to test as much as is necessary. Trying to reply as quickly as I notice a reply too.
Just pulled and re-installed, still no luck.

@raman325
Copy link
Owner

Much appreciated. I just pushed a new version with a new set of CLI commands (get-alt-serial-number/esn/version) that ONLY calls the alternate URLS (the admin_and_privacy ones). Can you try those and see if you get anything back? If you don't, it means there's an issue with the logic to parse the response from those endpoints

@yurdle
Copy link
Author

yurdle commented Nov 18, 2020

Here's each of the commands and responses.

$ pyvizio --ip 192.168.1.102 --auth <Token> get-alt-version
ERROR:pyvizio.cli:Couldn't get version
$ pyvizio --ip 192.168.1.102 --auth <Token> get-alt-esn
ERROR:pyvizio.cli:Couldn't get ESN
$ pyvizio --ip 192.168.1.102 --auth <Token> get-alt-serial-number
ERROR:pyvizio.cli:Couldn't get serial number

Need me to provide the exact http responses? Perhaps they differ as well?

@raman325
Copy link
Owner

Yes, that would be great.

@yurdle
Copy link
Author

yurdle commented Nov 18, 2020

Is this what you need?

$ curl -k -H "Content-Type: application/json" -H "AUTH: TOKEN" -X GET https://192.168.1.102:7345/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/uli_information/esn
{"STATUS": {"RESULT": "SUCCESS", "DETAIL": "Success"}, "ITEMS": [{"HASHVAL": 1909715021, "NAME": "ESN", "VALUE": "LINIZALW2112343", "READONLY": "TRUE", "CNAME": "esn", "TYPE": "T_STRING_V1"}], "HASHLIST": [4288381043, 1549970040, 1489396298, 904742941], "URI": "/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/uli_information/esn", "PARAMETERS": {"FLAT": "TRUE", "HELPTEXT": "FALSE", "HASHONLY": "FALSE"}}

$ curl -k -H "Content-Type: application/json" -H "AUTH: TOKEN" -X GET https://192.168.1.102:7345/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information/version
{"STATUS": {"RESULT": "SUCCESS", "DETAIL": "Success"}, "ITEMS": [{"HASHVAL": 341066122, "NAME": "Version:", "VALUE": "1.10.15.1-2", "READONLY": "TRUE", "CNAME": "version", "TYPE": "T_STRING_V1"}], "HASHLIST": [2911612711, 1549970040, 1489396298, 904742941], "URI": "/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information/version", "PARAMETERS": {"FLAT": "TRUE", "HELPTEXT": "FALSE", "HASHONLY": "FALSE"}}

$ curl -k -H "Content-Type: application/json" -H "AUTH: TOKEN" -X GET https://192.168.1.102:7345/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information/serial_number
{"STATUS": {"RESULT": "SUCCESS", "DETAIL": "Success"}, "ITEMS": [{"HASHVAL": 734634561, "NAME": "Serial Number:", "VALUE": "21LINIZALW01234", "READONLY": "TRUE", "CNAME": "serial_number", "TYPE": "T_STRING_V1"}], "HASHLIST": [2911612711, 1549970040, 1489396298, 904742941], "URI": "/menu_native/dynamic/tv_settings/admin_and_privacy/system_information/tv_information/serial_number", "PARAMETERS": {"FLAT": "TRUE", "HELPTEXT": "FALSE", "HASHONLY": "FALSE"}}

@raman325
Copy link
Owner

this is perfect! at first glance I don't see why the code wouldn't work but I will review anyway

@raman325
Copy link
Owner

OK @yurdle I think I figured out why it wasn't working. Both the get-esn|serial-number|version and get-alt-esn|serial-number|version commands should be working now, let me know if that's not the case (you will once again have to pull down the latest and install it)

@yurdle
Copy link
Author

yurdle commented Nov 18, 2020

Success! With all 6 commands!
Tried looking at the changes you made to see if I could understand, but I'm not really following what was changed looking at the diff.

@raman325
Copy link
Owner

The command classes were subclasses of this one: https://github.com/raman325/pyvizio/blob/master/pyvizio/api/item.py#L106-L138

This treats the name of the key in the dictionary of endpoints as the item name to look for. With these alternate versions of the API endpoints, I created new keys that don't match the name of the item. I created a new subclass that fixes it: https://github.com/raman325/pyvizio/blob/master/pyvizio/api/item.py#L189-L202

I don't love the way the code is structured but this has been mostly adapted from the original code so I haven't bothered changing it. At some point I was hoping to do a refactor to make things simpler to understand so others can contribute but at this point I am not sure if the extra effort is justified.

In either case, thank you for your help in troubleshooting this, I will get this pushed out soon and submit a version bump to HA

@raman325
Copy link
Owner

Can you check the latest one more time? I reverted some of the test changes I made and re-simplified the logic, just want to make sure I didn't break anything before I push it

@raman325
Copy link
Owner

I removed get-alt-* as part of this so we just need to test get-esn|version|serial-number

@raman325 raman325 linked a pull request Nov 18, 2020 that will close this issue
@yurdle
Copy link
Author

yurdle commented Nov 19, 2020

Just pulled and re-tested, still working correctly with the original commands.
Glad I could help, thank you for your help as well. Look forward to seeing this fixed in HA.

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

Successfully merging a pull request may close this issue.

2 participants