exiva / Vizio_SmartCast_API

API documentation for Vizio SmartCast TV's
175 stars 33 forks source link

Figuring out control syntax to open specific app (Netflix, Hulu, etc.) #21

Closed brubaked closed 4 years ago

brubaked commented 4 years ago

I recently noticed that the Vizio smartphone app (android) added support to open all the smart apps from within the app. I poked around the decompiled app and found the following endpoints in Vizio/vue/devicecontrol/api/enums/VZRestEndpoint.java:

APP(null, "app"), APP_CURRENT(APP, "current"), APP_LAUNCH(APP, "launch"), APP_CONFIG(APP, "config"), APP_CONFIG_GET(APP_CONFIG, "get_property"), APP_STORE(APP, "store"), APP_STORE_GET(APP_STORE, "get"), APP_STORE_SET(APP_STORE, "set"),

I can get the current app with the following curl command: curl -k -H "Content-Type: application/json" -H "AUTH: XXXXXXXX" -X GET https://XXX.XXX.XX.XXX:7345/app/current

Here is the output:

{"STATUS": {"RESULT": "SUCCESS", "DETAIL": "Success"}, "ITEM": {"TYPE": "T_APP_V1", "VALUE": {"MESSAGE": "https://www.youtube.com/tv", "NAME_SPACE": 5, "APP_ID": "1"}}, "URI": "/app/current"}

I'm not sure what the syntax to launch an app is though. Any help is appreciated.

brubaked commented 4 years ago

Alright, made some more progress.

The following opens youtube.

curl -k -H "Content-Type: application/json" -H "AUTH: XXXXXXXXXX" -X PUT -d '{"VALUE": {"MESSAGE": "https://www.youtube.com/tv", "NAME_SPACE": 5, "APP_ID": "1"}}' https://XXX.XXX.XX.XXX:7345/app/launch

Running the following while another app is on screen

curl -k -H "Content-Type: application/json" -H "AUTH: XXXXXXXX" -X GET https://XXX.XXX.XX.XXX:7345/app/current

Gives the MESSAGE, NAME_SPACE, and APP_ID necessary to launch any other app directly.

Actually, it looks like you can open apps while leaving the "message" field set to null.

curl -k -H "Content-Type: application/json" -H "AUTH: XXXXXXXXXX" -X PUT -d '{"VALUE": {"MESSAGE": null, "NAME_SPACE": 5, "APP_ID": "1"}}' https://XXX.XXX.XX.XXX:7345/app/launch

for example works.

raman325 commented 4 years ago

I was able to get a list of app APP_ID, NAME_SPACE, and MESSAGE parameters from the apk source: https://github.com/vkorn/pyvizio/issues/22#issuecomment-583148703

exiva commented 4 years ago

@brubaked @raman325 Great find! I'll start updating the doc with the table of apps and command to launch.

exiva commented 4 years ago

Can you verify the docs are correct now? in commit 6a27e7b

Also if someone can give the response from a successful /app/launch??

brubaked commented 4 years ago

Running curl -k -H "Content-Type: application/json" -H "AUTH: XXXXXXXXXX" -X PUT -d '{"VALUE": {"MESSAGE": "https://www.youtube.com/tv", "NAME_SPACE": 5, "APP_ID": "1"}}' https://XXX.XXX.XX.XXX:7345/app/launch

results in {"STATUS": {"RESULT": "SUCCESS", "DETAIL": "Success"}}

exiva commented 4 years ago

thanks 👍

exiva commented 4 years ago

Docs added, thanks again for the information!

brubaked commented 4 years ago

Sorry I just noticed that you have "name_space" and "app_id" as integer here:

`{
    "VALUE": {
        "MESSAGE": String,
        "NAME_SPACE": Integer,
        "APP_ID": Integer
    }
}`

I believe it should be

`{
    "VALUE": {
        "MESSAGE": String,
        "NAME_SPACE": Integer,
        "APP_ID": String
    }
}`

Running curl -k -H "Content-Type: application/json" -H "AUTH: XXXXXXXXXX" -X PUT -d '{"VALUE": {"MESSAGE": "https://www.youtube.com/tv", "NAME_SPACE": 5, "APP_ID": "1"}}' https://XXX.XXX.XX.XXX:7345/app/launch is successful (note "APP_ID": "1"), while running

curl -k -H "Content-Type: application/json" -H "AUTH: XXXXXXXXXX" -X PUT -d '{"VALUE": {"MESSAGE": "https://www.youtube.com/tv", "NAME_SPACE": 5, "APP_ID": 1}}' https://XXX.XXX.XX.XXX:7345/app/launch

(note "APP_ID": 1) results in

{"STATUS": {"RESULT": "INVALID_PARAMETER", "DETAIL": "Invalid parameter"}, "URI": "/app/launch"}

exiva commented 4 years ago

Fixed 73ca1cb