There. Is no scan interval on a command line, you need to send an on or off command, see below… If you want to fire just a one time command, use a script instead…
Well great news! I got it to work. I will share the code tomorrow but it is simple command line commands. This is promising and proof of concept for anyone struggling to control a Sharp Aquos TV through IP via Homeassistant.
I made a card and it’s a command line switch card. I’m not happy yet with the design but I will clean that up. On the card are 4 switches total for: HDMI 1, HDMI 2, HDMI 3 & HDMI 4. Each of those switches has an on and an off. Both on and off perform the same function of sending the command to switch to that input. I did consider having 1 switch control two different HDMI inputs one with on and another with off. Went with one switch equals one input for both on and off. I mainly wanted to get it functional. I will research other methods of creating a card with just a simple icon or button press to executed the command line.
Sharp uses an 8 character command structure followed by pressing enter. This is sufficient when you are typing into a terminal and pressing enter. However with my command line we are echoing what we want sent to the Sharp TV IP address. When echoing we need to echo the carriage return. For hex the manual kept referencing 0DH. This is referencing hex carriage return which is written as x0D. This needs to be the 9th character we are echoing for it to work. The echo command works directly through an SSH terminal as well as via the command line. It didn’t help I was using the wrong characters initially. I was attempting to use IVAD instead of IAVD.
A sample command for HDMI 1:
echo -e “\x49\x41\x56\x44\x31\x20\x20\x20\x0D” | nc !secret aquostv_IP 1002
I will mention I did this with a tv setup with no username or password. I’m sure you could make it work with a user name and password. You would just need to send a command to provide both in two separate commands likely. It worked using secrets file to store IP as well.
Sharp makes available a plethora of IP commands for this would work for nearly 100% of functionality. 2 of my Sharp TVs won’t allow me to power it on using this method. Another I have will allow me to power it on.
I will follow up with maybe learning a cleaner way of doing this with python. I’m not a coder so I have limited experience. But I am quite familiar with some languages which help me such as my in depth experience with VBA.
At a minimum I believe I will tabulate all of the commands Sharp is capable of. I’m sure there may be a better place to place those for others to learn or use for development. I will test them as well to ensure each code works as expected.
I’m just not sure I have the experience to slap an add on together worthy of sharing. At least I have proof of concept for the codes and method for it to work. Now to cleaning it up!
Tomorrow I will post the snippet for the completed card I created for others to see in case it’s found useful. I’m on my cell and about to crash. Can’t copy and paste from my file at moment.
Do you also capture the state? Or just on and off ?
This doesn’t capture the state in my particular instance. However the protocol Sharp provides it does send back a response. By default when It receives a valid command a response of ok is received. If an invalid command is received it responds with err. You can send a command to get it to respond with what input is active. I’ll have to double check what it is. I believe it is IAVD???; the present setting value responds which would be 1-5. So if there is a method for listening for the response this state could be recorded.
I believe there is a way for the commands be sent to listen for a response. Obviously when I’m using my terminal I can view the response. This is more advanced than what I will need. I’m happy to automate and set the state I want by powering on via my Apple TV and then set the input I want via a command line command. I will play with it and experiment.
the -q should capture the state, but if you are running hassos, like in my case, i dont have an -Q , i have another netcat version i am afraid
command_state: echo -n 00 | nc -q 1 <ip_addr> <port>
I’m trying to create some switches for my HDMI matrix. Anyone see what I’m doing wrong?
Here are the IP commands - http://nohassleav.com/8x8_hdmi_hdr/after_dec_15th/New_simplified_RS232_IP_commands.txt
switch: - platform: command_line switches: hdmi_matrix: command_on: echo -e “@T 04 00 !” | nc 192.168.0.210 5000 friendly_name: HDMI Matrix
whats your issue? do you have a config error? or ?
is your net command working if you do i from a terminal?
I looked at the data in the link. Is that just text characters? It doesn’t appear to be specific ASCII codes to corresponding characters. I use this as a handy chart: http://www.asciitable.com
Is it possible you need to convert those characters to hex? In your link it also mentions: "epending on the control system that you’re using, you might need a carriage return at the end of each of these commands. Check with your control system manufacturer to see what symbol you should use for a carriage return. It could be any of these symbols:
\r, /r, <CR>, \0XD" The last one mentioned
" \OXD" appears to be hex which would be entered as
I converted your string into hex below:
@T 0F 01 ! Without a carriage return: echo - e "\x40\x54\x20\x30\x46\x20\x30\x31\x20\x21"
When I pasted into my terminal and pressed enter it shows it echoes:
@T 0F 01 ! which is what your device is expecting to execute the power on command. However according to your documentation which you linked to your device may need a carriage return added. If so try the below option. You likely won’t know if that is needed when testing it from the actual terminal interface directly. This may need to be tested directly within your
@T 0F 01 ! With a carriage return: echo - e "\x40\x54\x20\x30\x46\x20\x30\x31\x20\x21\x0D"
Doing the above steps is what my device required. Yours may behave similarly. Give it a try to see if that makes a difference.
Yours may look like this: command_on: echo -e "\x40\x54\x20\x30\x46\x20\x30\x31\x20\x21"| nc 192.168.0.210 5000 or this: command_on: echo -e "\x40\x54\x20\x30\x46\x20\x30\x31\x20\x21\x0D "| nc 192.168.0.210 5000
I will give it a try to test with capturing the state. I would need to figure out how that would be stored on my card or if it needs anything else in addition to the -q . I fear it wouldn’t matter as just like you, I am operating on HassOS as well. It is likely I am in the same boat as yourself.
yes, then indeed its not working
i am going to step away from hassos in the future, then i try it again
I wanted to follow up with anyone who was following this and for future reference what I used to get hassOS working to send IP commands to a Sharp Aquos Android TV. Specifically to these two models: LC-80LE844U and LC-Ux30US where x would be the size of your TV. Mine is a LC-U7030US however I think that is unimportant.
switch: platform: command_line switches: hdmi_input1: command_on: echo -e "\x49\x41\x56\x44\x31\x20\x20\x20\x0D" | nc !secret aquostv_ip 10002 command_off: echo -e "\x49\x41\x56\x44\x31\x20\x20\x20\x0D" | nc !secret aquostv_ip 10002 friendly_name: HDMI 1 hdmi_input2: command_on: echo -e "\x49\x41\x56\x44\x32\x20\x20\x20\x0D" | nc !secret aquostv_ip 10002 command_off: echo -e "\x49\x41\x56\x44\x32\x20\x20\x20\x0D" | nc !secret aquostv_ip 10002 friendly_name: HDMI 2 hdmi_input3: command_on: echo -e "\x49\x41\x56\x44\x33\x20\x20\x20\x0D" | nc !secret aquostv_ip 10002 command_off: echo -e "\x49\x41\x56\x44\x34\x20\x20\x20\x0D" | nc !secret aquostv_ip 10002 friendly_name: HDMI 3 hdmi_input4: command_on: echo -e "\x49\x41\x56\x44\x34\x20\x20\x20\x0D" | nc !secret aquostv_ip 10002 command_off: echo -e "\x49\x41\x56\x44\x34\x20\x20\x20\x0D" | nc !secret aquostv_ip 10002 friendly_name: HDMI 4 Replace !secret aquostv_ip with your own IP address for your aquos TV if you aren't using the secrets file.
The TV must already be powered on for this to work properly on many TV’s. Some sharp Aquos support being powered on via IP while others do not.
This works and is pretty plain at the moment. It simply gives a simple switch. I have customized it using Groups to name the card. In my used version my friendly names were: Apple TV and Tivo to name the specific devices connected. This doesn’t capture states it is just a one way command to set the desired state I want.
your on and off command look the same? why are you not using command line scripts? then you just exequte it
They are the exact same. I am still learning how to do this. As soon as I figure out a cleaner way that accomplishes the same I will be switching to that. In the command line hassio instructions it simply had this functionality within a switch. I was going to remove
command_off but it is required of the switch. I am still learning the front end and card creation/modification.
My first goal was to ensure the command worked when I pressed them and it achieved the desired result from the TV. It has. Now onto learning more about designing the front end and putting this in a better package without an on and off switch.
I envision a simple Card with my HDMI inputs labeled as Tivo and Apple TV using the same icons. And I press either of them and it execute the
command_line command I choose.
These are baby steps for me. I have only begun playing with HomeAssistant 2 weeks now. I have installed and reinstalled about 4 times. I have screwed it up a few times. But I am learning as I go. I have also learned to save snapshots for easy recovery now in case of a flub up. I am slowly adding rooms and devices I wish to automate. I have about 30 dimmers/outlets/fan speed controllers I still need to install in my home and add to all of this.
I was focusing on learning the ins and outs of the front end, its operation and the design. I wanted to get it as smooth as possible before handing it off to the misses and these little things are helping me get there albeit slowly.
Ah ok, deep in script, basically the same as you do, but then without an off so your switch icon, just has one button
@Alex_Yeoman it says in the page you pointed to something you appear to have ignored:
Depending on the control system that you’re using, you might need a carriage return at the end of each of these commands. Check with your control system manufacturer to see what symbol you should use for a carriage return. It could be any of these symbols: \r, /r, <CR>, \0XD
Well special caracters, its works now, i was using telnet switch, later i change to command_line sw with netcat and send the hex bytesequence
Thanks for this. I actually can’t even send commands to the HDMI matrix via packet sender…it won’t connect. I’ll fix this first then try your suggestions. Thanks again!
Does anybody see what I’m doing wrong? I get the following error sending commands to my HDMI matrix.
2019-02-23 14:02:51 INFO (SyncWorker_13) [homeassistant.components.switch.command_line] Running command: echo -e “\x40\x54\x20\x30\x30\x20\x30\x30\x20\x21” | nc 192.168.0.210 5000
2019-02-23 14:02:51 ERROR (SyncWorker_13) [homeassistant.components.switch.command_line] Command failed: echo -e “\x40\x54\x20\x30\x30\x20\x30\x30\x20\x21” | nc 192.168.0.210 5000
This is my config code…
switch: - platform: command_line switches: hdmi_matrix: command_on: echo -e “\x40\x54\x20\x30\x30\x20\x30\x30\x20\x21” | nc 192.168.0.210 5000 command_off: echo -e “\x40\x54\x20\x30\x30\x20\x30\x30\x20\x21” | nc 192.168.0.210 5000 friendly_name: HDMI Matrix
(I’ve also treid with \x0D on the end of the command)
The code works when I send via packet sender
For a start the command_off does not have a port (5000 in the command_on.
nice catch…but it didn’t help.