exiva / Vizio_SmartCast_API

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

Changing input to a source no longer functions #36

Open kbrown01 opened 1 year ago

kbrown01 commented 1 year ago

Very detailed information also posted here:

https://github.com/home-assistant/core/issues/83689

IN general, changing input to a physical input (HDMI-1 ... HDMI-#, COMP, TV or CAST) no longer works after a Vizio update to later model TVs. Changing input to "apps" like Netflix, HBOMax, etc. still functions.

Test to show this:

curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxxx" -X GET https://192.168.2.20:7345/menu_native/dynamic/tv_settings/devices/current_input

{"STATUS":{"RESULT":"SUCCESS","DETAIL":"Success"},"URI":"/menu_native/dynamic/tv_settings/devices/current_input","PARAMETERS":{"HASHONLY":"FALSE","FLAT":"TRUE","HELPTEXT":"FALSE"},"ITEMS":[{"CNAME":"current_input","TYPE":"T_STRING_V1","NAME":"Current Input","VALUE":"HDMI-1","ENABLED":"FALSE","HIDDEN":"TRUE","HASHVAL":2129379411}],"HASHLIST":[4012391352,3366813733]}

curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxx" -X PUT -d "{\"REQUEST\": \"MODIFY\",\"VALUE\": \"CAST\",\"HASHVAL\": 2129379411}" https://192.168.2.20:7345/menu_native/dynamic/tv_settings/devices/current_input

{"STATUS":{"RESULT":"FAILURE","DETAIL":"Failure"},"URI":"/menu_native/dynamic/tv_settings/devices/current_input","PARAMETERS":{"REQUEST":"MODIFY","VALUE":"CAST","HASHVAL":2129379411}}

They all result in a nothing message that is just "Failure" with no information. As you can see, I called this to switch the input to CAST from the current input Hashval 2129379411 (HDMI-1). This applies to switching anything that is a physical input or CAST, not to "apps" which seems to function normally.

I will note that this worked in the past up until my Vizio's all got an update. I do have one older model TV that was not updated and it works on this TV. The whole GUI is different in the later models so I am unsure what information to provide, but here are some details:

Not working: Model V505-J09 Firmware 1.520.24.2-2 Updated December 14,2022

Working: Model M65-D0 Version 11.0.120.1-1 Cast Version 1.50.243780 Don't know where last update is, but checking updates says the TV is up to date.

kbrown01 commented 1 year ago

One additional note, this still works should you wish to pop open the list of inputs and cycle through them:

curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxxx" -X PUT -d "{\"KEYLIST\": [{\"CODESET\": 7,\"CODE\": 1,\"ACTION\":\"KEYPRESS\"}]}" https://192.168.2.20:7345/key_command/

But that is not really pleasing, one should be able to set the input directly.

kbrown01 commented 1 year ago

I think I know the issue. First I got the devices information:

curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxxx" -X GET https://192.168.2.20:7345/menu_native/dynamic/tv_settings/devices

This yields the following:

{ "STATUS": { "RESULT": "SUCCESS", "DETAIL": "Success" }, "URI": "/menu_native/dynamic/tv_settings/devices", "PARAMETERS": { "HASHONLY": "FALSE", "FLAT": "TRUE", "HELPTEXT": "FALSE" }, "ITEMS": [ { "CNAME": "name_input", "TYPE": "T_MENU_V1", "NAME": "Name Input", "HIDDEN": "TRUE", "HASHVAL": 2290841388 }, { "CNAME": "hdmi1", "TYPE": "T_MENU_V1", "NAME": "HDMI-1", "HASHVAL": 2280660428 }, { "CNAME": "hdmi2", "TYPE": "T_MENU_V1", "NAME": "HDMI-2", "HASHVAL": 4288216768 }, { "CNAME": "hdmi3", "TYPE": "T_MENU_V1", "NAME": "HDMI-3", "HASHVAL": 555909760 }, { "CNAME": "comp", "TYPE": "T_MENU_V1", "NAME": "COMP", "HASHVAL": 484700649 }, { "CNAME": "tuner", "TYPE": "T_MENU_V1", "NAME": "TV", "HASHVAL": 542431704 }, { "CNAME": "current_input", "TYPE": "T_STRING_V1", "NAME": "Current Input", "VALUE": "SMARTCAST", "ENABLED": "FALSE", "HIDDEN": "TRUE", "HASHVAL": 2023834057 }, { "CNAME": "current_inputs", "TYPE": "T_LIST_CURRENT_INPUTS_V1", "NAME": "Current Inputs", "VALUE": [ { "CNAME": "tuner", "CUSTOM_NAME": "TV", "ENABLED": true, "HIDEABLE": true, "INPUT_TYPE": 0, "NAME": "Coax", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "comp", "CUSTOM_NAME": "COMP", "ENABLED": true, "HIDEABLE": true, "INPUT_TYPE": 0, "NAME": "Comp", "READONLY": false, "SELECTED": false, "VISIBLE": false }, { "CEC_OBJECT": { "AMP_CONNECTED": false, "DEVICE_TYPE": "Tuner", "DEV_NAME": "Tuner 1", "HDMI_PORT": "HDMI-1", "LOGICAL_ADDRESS": "0x3", "OSD_NAME": "Tuner 1", "PHYSICAL_ADDRESS": "0x1000", "VENDOR_ID": "0x000" }, "CNAME": "hdmi1", "CUSTOM_NAME": "DirecTV", "ENABLED": true, "HIDEABLE": true, "INPUT_TYPE": 0, "NAME": "HDMI-1", "READONLY": false, "SELECTED": false, "VISIBLE": true }, { "CNAME": "hdmi2", "CUSTOM_NAME": "HDMI-2", "ENABLED": true, "HIDEABLE": true, "INPUT_TYPE": 0, "NAME": "HDMI-2", "READONLY": false, "SELECTED": false, "VISIBLE": false }, { "CNAME": "hdmi3", "CUSTOM_NAME": "HDMI-3", "ENABLED": true, "HIDEABLE": true, "INPUT_TYPE": 0, "NAME": "HDMI-3", "READONLY": false, "SELECTED": false, "VISIBLE": false }, { "CNAME": "usb", "CUSTOM_NAME": "USB", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 0, "NAME": "USB", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "cast", "CUSTOM_NAME": "SMARTCAST", "ENABLED": true, "HIDEABLE": false, "INPUT_TYPE": 0, "NAME": "SmartCast", "READONLY": true, "SELECTED": true, "VISIBLE": true }, { "CNAME": "watchfree", "CUSTOM_NAME": "WatchFree+", "ENABLED": true, "HIDEABLE": false, "INPUT_TYPE": 1, "NAME": "WatchFree+", "READONLY": true, "SELECTED": false, "VISIBLE": true }, { "CNAME": "TV", "CUSTOM_NAME": "TV", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "TV", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Recorder 1", "CUSTOM_NAME": "Recorder 1", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Recorder 1", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Recorder 2", "CUSTOM_NAME": "Recorder 2", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Recorder 2", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Tuner 1", "CUSTOM_NAME": "Tuner 1", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Tuner 1", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Player 1", "CUSTOM_NAME": "Player 1", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Player 1", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Audio System", "CUSTOM_NAME": "Audio System", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Audio System", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Tuner 2", "CUSTOM_NAME": "Tuner 2", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Tuner 2", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Tuner 3", "CUSTOM_NAME": "Tuner 3", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Tuner 3", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Player 2", "CUSTOM_NAME": "Player 2", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Player 2", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Recorder 3", "CUSTOM_NAME": "Recorder 3", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Recorder 3", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Tuner 4", "CUSTOM_NAME": "Tuner 4", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Tuner 4", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Player 3", "CUSTOM_NAME": "Player 3", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Player 3", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Device 1", "CUSTOM_NAME": "Device 1", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Device 1", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Device 2", "CUSTOM_NAME": "Device 2", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Device 2", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "Device 3", "CUSTOM_NAME": "Device 3", "ENABLED": false, "HIDEABLE": false, "INPUT_TYPE": 2, "NAME": "Device 3", "READONLY": true, "SELECTED": false, "VISIBLE": false }, { "CNAME": "airplay", "CUSTOM_NAME": "AirPlay", "ENABLED": true, "HIDEABLE": false, "INPUT_TYPE": 1, "NAME": "AirPlay", "READONLY": true, "SELECTED": false, "VISIBLE": true } ], "ENABLED": "FALSE", "HIDDEN": "TRUE", "HASHVAL": 3514900185 } ], "NAME": "Input Settings", "TYPE": "T_MENU_V1", "CNAME": "devices", "GROUP": "G_DEVICES", "HASHLIST": [ 4178950623, 1190847418 ] }

From that, I instead of sending "HDMI-1", I changed to "hdmi1":

curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxxx" -X PUT -d "{\"REQUEST\": \"MODIFY\",\"VALUE\": \"hdmi1\",\"HASHVAL\": 2023834057}" https://192.168.2.20:7345/menu_native/dynamic/tv_settings/devices/current_input

And now:

{"STATUS":{"RESULT":"SUCCESS","DETAIL":"Success"},"URI":"/menu_native/dynamic/tv_settings/devices/current_input","PARAMETERS":{"REQUEST":"MODIFY","VALUE":"hdmi1","HASHVAL":2023834057},"ITEMS":[{"NAME":"Current Input","HASHVAL":3820226472}],"HASHLIST":[1829525585,851380311]}

This would imply that you need to pass in the CNAME of the input now and not Items[x].Name.

HDMI-1 = hdmi1 HDMI-2 = hdmi2 .... CAST = cast

exiva commented 1 year ago

On both sets, can you verify the CNAME works? On my E43D2 with the old smartcast, CNAME does nothing. So I think there'd have to be an option added in APIs and apps to maintain support for all models, not exactly elegant. 😬

kbrown01 commented 1 year ago

Yes you are exactly correct. As stated I have one older TV that still accepts "HDMI-1" however three other TVs with updated firmware no longer work and only accepts "hdmi1". Not sure what to do here, but I would assume possibly a firmware update could break the older TV although it has not happened yet.

kbrown01 commented 1 year ago

I can check "hdmi1" on the older set if that helps via curl, I will post results in a bit

kbrown01 commented 1 year ago

Checked and yes! "hdmi1" works on my older TV.

curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxxxx" -X PUT -d "{\"REQUEST\": \"MODIFY\",\"VALUE\": \"hdmi1\",\"HASHVAL\": 2023834057}" https://192.168.2.5:7345/menu_native/dynamic/tv_settings/devices/current_input

Results:

{"STATUS": {"RESULT": "SUCCESS", "DETAIL": "Success"}, "ITEMS": [{"HASHVAL": 3820226472, "NAME": "Current Input"}], "HASHLIST": [641952183, 682050470], "URI": "/menu_native/dynamic/tv_settings/devices/current_input", "PARAMETERS": {"HASHVAL": 2023834057, "REQUEST": "MODIFY", "VALUE": "hdmi1"}}

exiva commented 1 year ago

Okay, so probably on all the ones with the smartcast UI You'd want to use CNAME. Hm. I'll do some more testing with my old chomecast version set, see if I can make it work by cname. That would be a lot more elegant than having to differentiate between versions.

r14n commented 1 year ago

For me, I have to get the hashval of the current input, and pass that to the command to change it, or else I get a hashval error. So I have to make two API calls like so, but at least I can switch inputs now.

hashval=$( curl -s -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxx" -X GET https://192.168.100.20:7345/menu_native/dynamic/tv_settings/devices/current_input | jq --raw-output '.ITEMS[0].HASHVAL' ); curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxx" -X PUT -d "{\"REQUEST\": \"MODIFY\",\"VALUE\": \"hdmi2\",\"HASHVAL\": $hashval}" https://192.168.100.20:7345/menu_native/dynamic/tv_settings/devices/current_input

DanMabee commented 1 year ago

can confirm switching to cname works. i went through this a few weeks ago on a vizio m50q7-j01 after a firmware update broke my old scripts and made the same discovery.

exiva commented 1 year ago

Since the official app barely works anymore on my older set I'm guessing there's no backwards compatible route other than having to add a switch to the libraries and implementations for when using a older set. Thats unfortunate. Guess the docs will need updated.