exiva / Vizio_SmartCast_API

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

Change Input not working #4

Closed heathbar closed 7 years ago

heathbar commented 7 years ago

I am unable to change the input on my device.

I AM ABLE to retrieve the list of inputs with this command:

curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxxxx" -X GET https://10.1.1.57:9000/menu_native/dynamic/tv_settings/devices/name_input

{ "STATUS": { "RESULT": "SUCCESS", "DETAIL": "Success" }, "HASHLIST": [ 2711206618, 857646160, 328267420 ], "GROUP": "G_DEVICES", "NAME": "Name Input", "PARAMETERS": { "FLAT": "TRUE", "HELPTEXT": "FALSE", "HASHONLY": "FALSE" }, "ITEMS": [ { "HASHVAL": 4223247769, "CNAME": "cast", "NAME": "CAST", "TYPE": "T_DEVICE_V1", "READONLY": "TRUE", "VALUE": { "NAME": "CAST", "METADATA": "" } }, { "HASHVAL": 2142775487, "CNAME": "hdmi1", "TYPE": "T_DEVICE_V1", "NAME": "HDMI-1", "VALUE": { "NAME": "HDMI-1", "METADATA": "" } }, { "HASHVAL": 3180621345, "CNAME": "hdmi2", "TYPE": "T_DEVICE_V1", "NAME": "HDMI-2", "VALUE": { "NAME": "HDMI-2", "METADATA": "" } }, { "HASHVAL": 1062560941, "CNAME": "hdmi3", "TYPE": "T_DEVICE_V1", "NAME": "HDMI-3", "VALUE": { "NAME": "HDMI-3", "METADATA": "" } }, { "HASHVAL": 2833012137, "CNAME": "hdmi4", "TYPE": "T_DEVICE_V1", "NAME": "HDMI-4", "VALUE": { "NAME": "", "METADATA": "" } }, { "HASHVAL": 3604572706, "CNAME": "hdmi5", "TYPE": "T_DEVICE_V1", "NAME": "HDMI-5", "VALUE": { "NAME": "", "METADATA": "" } }, { "HASHVAL": 3821290730, "CNAME": "comp", "TYPE": "T_DEVICE_V1", "NAME": "COMP", "VALUE": { "NAME": "", "METADATA": "" } } ], "URI": "/menu_native/dynamic/tv_settings/devices/name_input", "CNAME": "name_input", "TYPE": "T_MENU_V1" }

However, when I try to change to a specific input, I get HASHVAL_ERROR. For example:

curl -k -H "Content-Type: application/json" -H "AUTH: xxxxxxxxxx" -X PUT -d '{"REQUEST": "MODIFY","VALUE": "HDMI-4","HASHVAL": 2833012137}' https://10.1.1.57:9000/menu_native/dynamic/tv_settings/devices/current_input

{ "STATUS": { "RESULT": "HASHVAL_ERROR", "DETAIL": "Hashval error" }, "URI": "/menu_native/dynamic/tv_settings/devices/current_input", "PARAMETERS": { "HASHVAL": 2833012137, "REQUEST": "MODIFY", "VALUE": "HDMI-4" } }

storagedaemon commented 7 years ago

I've been meaning to post basically this, except that I found that the HASHVAL that current_input expects isn't the HASHVAL from the name_input call, but instead you get it from a quick call to current_input itself.

current_input { "STATUS": { "RESULT": "SUCCESS", "DETAIL": "Success" }, "ITEMS": [ { "HASHVAL": 3057664350, "NAME": "Current Input", "ENABLED": "FALSE", "VALUE": "CAST", "CNAME": "current_input", "TYPE": "T_STRING_V1" } ], "HASHLIST": [ 4268724861, 1359452003 ], "URI": "/menu_native/dynamic/tv_settings/devices/current_input", "PARAMETERS": { "FLAT": "TRUE", "HELPTEXT": "FALSE", "HASHONLY": "FALSE" } }

So 3057664350 in this case.

anthonylavado commented 7 years ago

I can also confirm the above solution from @iodine53 in the case of my P65-C1.

I had spoken about it with @exiva, but never got around to it.

See thread here: https://www.twitter.com/anthonylavado/status/835982701052243975

heathbar commented 7 years ago

Confirmed: solution from @iodine53 works for me too.

exiva commented 7 years ago

It looks like you use the last hashval you got in the next call always, correct? I wonder why the e43-d2 doesn't enforce the hashval field.

anthonylavado commented 7 years ago

@exiva At least in my case, I call GET_CURRENT_INPUT in order to get a hashval that will allow me to change to the next input.

exiva commented 7 years ago

Out of curiosity, and because my set accepts whatever you throw at it, try calling devices/name_input and using one of the values you get in HASHLIST to change input with devices/current_input

storagedaemon commented 7 years ago

I tried that and no luck on my M50-D1 - only the HASHVAL from current_input seems to work to change the value of current_input.

exiva commented 7 years ago

Thank you everyone for the input & feedback, I'll update the docs tonight accordingly. šŸ‘

skavan commented 6 years ago

p.s. I think the docs are still wrong.. It's not from name_input, but rather current_input

PUTĀ current_input FromĀ name_input
VALUE ITEMS[x].NAME
HASHVAL ITEMS[x].HASHVAL
WalkerSensabaugh commented 5 years ago

Can confirm, this is still incorrect in the docs. This thread helped a bunch!

r14n commented 1 year ago

Some bash code to change inputs if you have to use the current input hashval in the change call.

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