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

Some sources no longer work with Home Assistant #135

Open
kbrown01 opened this issue Dec 9, 2022 · 21 comments
Open

Some sources no longer work with Home Assistant #135

kbrown01 opened this issue Dec 9, 2022 · 21 comments

Comments

@kbrown01
Copy link

kbrown01 commented Dec 9, 2022

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

@kbrown01
Copy link
Author

kbrown01 commented Dec 13, 2022

More info is posted here: home-assistant/core#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.

@kbrown01
Copy link
Author

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.

@kbrown01
Copy link
Author

I have successfully found the issue, I will leave it to someone to fix. See exiva/Vizio_SmartCast_API#36

Inputs like HDMI-1, HDMI-2, ... CAST are now hdmi1, hdmi2, ... cast.

@r14n
Copy link

r14n commented Dec 28, 2022

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

@kbrown01
Copy link
Author

As my example shows. You are using hdmi2 and not HDMI-2 and in newer TVs the second one no longer works

@kbrown01
Copy link
Author

kbrown01 commented Dec 29, 2022

@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

@r14n
Copy link

r14n commented Dec 29, 2022

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'

@kbrown01
Copy link
Author

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

@kbrown01
Copy link
Author

kbrown01 commented Jan 1, 2023

@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

@r14n
Copy link

r14n commented Jan 1, 2023

No backticks in my command, can you paste what you are using and I'll check on it?

@kbrown01
Copy link
Author

kbrown01 commented Jan 1, 2023

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'

@r14n
Copy link

r14n commented Jan 1, 2023 via email

@kbrown01
Copy link
Author

kbrown01 commented Jan 1, 2023

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):`

@kbrown01
Copy link
Author

kbrown01 commented Jan 1, 2023

service: shell_command.vizio_source_select
data:
  auth: XXXXXXXXXX
  ip: 192.168.2.20
  port: 7345
  source: cast

`

@kbrown01
Copy link
Author

kbrown01 commented Jan 1, 2023

FYI, I tried it without the variables with fixed values and I get the same error

@r14n
Copy link

r14n commented Jan 2, 2023 via email

@r14n
Copy link

r14n commented Jan 2, 2023

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: .......

@kbrown01
Copy link
Author

kbrown01 commented Jan 2, 2023

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.

@kbrown01
Copy link
Author

kbrown01 commented Jan 2, 2023

And OS is Linux with Home Assistant Core installed. Updated to the latest:

Home Assistant 2022.12.8
Frontend 20221213.1 - latest

@kbrown01
Copy link
Author

kbrown01 commented Jan 2, 2023

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.

@r14n
Copy link

r14n commented Jan 2, 2023

That does sound like it could be the issue, maybe try putting it directly in configuration.yaml?

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

No branches or pull requests

2 participants