Open kbrown01 opened 1 year ago
More info is posted here: https://github.com/home-assistant/core/issues/83689
I would assume that pyvzio would have a similar issue if it is calling the REST interface. Specifically:
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}}
There are no other details, just that it fails.
One additional note/workaround ... you can implement a button to call the key command:
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/
This will pop open the list of inputs and calling again (and again ...) before it auto selects will cycle through the inputs. This is the old way I did this but that seems so kludgy.
I have successfully found the issue, I will leave it to someone to fix. See https://github.com/exiva/Vizio_SmartCast_API/issues/36
Inputs like HDMI-1, HDMI-2, ... CAST are now hdmi1, hdmi2, ... cast.
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
As my example shows. You are using hdmi2 and not HDMI-2 and in newer TVs the second one no longer works
@r14n ... are you using Home Assistant? If so, can you show me the YAML code you used for that singular command in something like a shell_command entity. I cannot get it to work exactly and only have been successful in running pieces (store the current HASHVAL as the state of an entity, then use it). I have been trying something like this:
vizio_source_select: > hashval = $( curl -s -k -H "Content-Type: application/json" -H "AUTH: {{auth}}" -X GET https://{{ip}}:{{port}}/menu_native/dynamic/tv_settings/devices/current_input | jq --raw-output ".ITEMS[0].HASHVAL") && curl -k -H "Content-Type: application/json" -H "AUTH: {{auth}}" -X PUT -d '{"REQUEST": "MODIFY","VALUE": "{{source}}","HASHVAL": $hashval}' https://{{ip}}:{{port}}/menu_native/dynamic/tv_settings/devices/current_input
Here's what I have in configuration.yaml:
shell_command:
tv_input_hdmi2: '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'
All in the escaping ! i will try that one tomorrow. I add {{ip}}, {{port}}. {{auth}}, {{input}} to make it a little more generic so I can call the shell_command and pass in those values
@r14n, that shell_command does not work for me. what are the ticks directions? All I get is an error that "hashval$(" file does not exist. I think there are some back ticks I am missing there
No backticks in my command, can you paste what you are using and I'll check on it?
vizio_source_select: 'hashval=$( curl -s -k -H "Content-Type: application/json" -H "AUTH: {{auth}}" -X GET https://{{ip}}:{{port}}/menu_native/dynamic/tv_settings/devices/current_input | jq --raw-output ".ITEMS[0].HASHVAL" ); curl -k -H "Content-Type: application/json" -H "AUTH: {{auth}}" -X PUT -d "{\"REQUEST\": \"MODIFY\",\"VALUE\": \"{{source}}\",\"HASHVAL\": $hashval}" https://{{ip}}:{{port}}/menu_native/dynamic/tv_settings/devices/current_input'
I'm thinking it looks ok, where are you calling it from and how are the variables {{auth}} {{ip}} etc being passed in?
On Sun, Jan 1, 2023 at 6:05 PM kbrown01 @.***> wrote:
vizio_source_select: 'hashval=$( curl -s -k -H "Content-Type: application/json" -H "AUTH: {{auth}}" -X GET https://{{ip}}:{{port}}/menu_native/dynamic/tv_settings/devices/current_input | jq --raw-output ".ITEMS[0].HASHVAL" ); curl -k -H "Content-Type: application/json" -H "AUTH: {{auth}}" -X PUT -d "{\"REQUEST\": \"MODIFY\",\"VALUE\": \"{{source}}\",\"HASHVAL\": $hashval}" https:// {{ip}}:{{port}}/menu_native/dynamic/tv_settings/devices/current_input'
— Reply to this email directly, view it on GitHub https://github.com/vkorn/pyvizio/issues/135#issuecomment-1368561313, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDZDFQHJF5MU466N6VVCBTWQIEVLANCNFSM6AAAAAASZXLEZQ . You are receiving this because you were mentioned.Message ID: @.***>
and ...
`Logger: homeassistant.helpers.script.websocket_api_script Source: components/shell_command/init.py:81 First occurred: 11:39:41 AM (1 occurrences) Last logged: 11:39:41 AM
websocket_api script: Error executing script. Unexpected error for call_service at pos 1: [Errno 2] No such file or directory: 'hashval=$(' Traceback (most recent call last):`
service: shell_command.vizio_source_select
data:
auth: XXXXXXXXXX
ip: 192.168.2.20
port: 7345
source: cast
`
FYI, I tried it without the variables with fixed values and I get the same error
What operating system are you using? Is the shell bash?
On Sun, Jan 1, 2023 at 6:35 PM kbrown01 @.***> wrote:
FYI, I tried it without the variables and I get the same error
— Reply to this email directly, view it on GitHub https://github.com/vkorn/pyvizio/issues/135#issuecomment-1368566514, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDZDFWUGZX3PVQL3MTMBSLWQIIFBANCNFSM6AAAAAASZXLEZQ . You are receiving this because you were mentioned.Message ID: @.***>
Just to make sure, in your configuration.yaml, you have shell_command with the vizio_source_select nested below right?
shell_command: vizio_source_select: .......
I use an !include so in configuration.yaml
:
shell_command: !include shell_commands.yaml
And the shell_commands.yaml
has many other entries in it. Like this one (my old one) right above which does work:
vizio_directv: >
curl -k -H "Content-Type: application/json" -H "AUTH: {{auth}}" -X PUT -d '{"REQUEST": "MODIFY","VALUE": "hdmi1","HASHVAL": 2023834057}' https://{{ip}}:{{port}}/menu_native/dynamic/tv_settings/devices/current_input
`
I was only trying to make things a little more generic. HASHVAL 2023834057 is "cast" which in 90% of the cases where I have a TV that I want to move to "hdmi1" BUT not always (like going from "hdmi2" to "hdmi1" on some rare occasions. I also need to have the ip, port, auth codes passed in because I have 6 total TVs (Deck, Patio, Master, Kitchen, Living, Guest) and it would be so dumb to create a sensor of current HASHVAL for each. Love your approach, just cannot seem to get it to work in my HA install. I use "jq" a lot for other things so I know that isn't the issue and in fact carving off just the "hashval" part and executing only the curl piped to "jq" also works to get the HASHVAL.
One thing that strikes me as odd but maybe it is some simple hash is the hashcode seems to be always the same ... meaning no date or particular TV info or anything is in it ... simply the name of the current input. I get the same code like 2023834057 for current input as "cast" for every TV. Since I use a JSON file to manage all my TVs (inputs, DirecTV codes, favorites in DirecTV, etc. I could just add the HASHVAL to it and look it up in the JSON. I find your solution more elegant though.
And OS is Linux with Home Assistant Core installed. Updated to the latest:
Home Assistant 2022.12.8 Frontend 20221213.1 - latest
Maybe this in the documentation is the issue?
https://www.home-assistant.io/integrations/shell_command/
"The commands can be dynamic, using templates to insert values for arguments. When using templates, shell_command runs in a more secure environment which doesn’t allow any shell helpers like automatically expanding the home dir ~ or using pipe symbols to run multiple commands."
My example is using templates.
That does sound like it could be the issue, maybe try putting it directly in configuration.yaml?
Note: I am not sure this is the right place, perhaps not. Not sure whether this is generic select source issue or an issue with pyvizio.
Some sources (specifically HDMI-1,2,3,4) as well as CAST no longer work with media_player.select_source
service: media_player.select_source
data:
source: HDMI-1
target:
entity_id: media_player.office_vizio
Worked up until the last Vizio update on newer TVs. It is like select source works to select an app, but can't be used to change input.
Note that I have two V505-J09 which worked until Vizio update got installed. I have another Vizio (older) which had no update and it works perfectly. I can set source to HDMI-1, CAST, Netflix, etc and it will switch between those. After the update for the other TVs, yu can no longer use Home Assistant to switch between these sources.
In a quick test I can confirm that using select_source does not select any "inputs" now. From the HA state:
source_list: HDMI-1 HDMI-2 HDMI-3 COMP TV
All these no longer work, all other "apps" do. This also applies to CAST, you cannot get back to it after switching to something like Netflix. The code I use is all posted here which I cannot use anymore for these TVs:
https://github.com/kbrown01/Vizio_DirecTV