Command line “echo”

I have created a switch in my command_line.yaml as:

- switch:
    name: "Lindy HDMI Matrix"
    unique_id: lindyhdmimatrix
    command_on: echo -e "\A5\5B\08\0C\0F\00\00\00\00\00\00\00\DE" | nc 192.168.2.50:8000
    command_off: echo -e "\A5\5B\08\0C\F0\00\00\00\00\00\00\00\FD" | nc 192.168.2.50:8000

It’s not working :frowning:

I’m working on a PC. Can anybody help on have I got the correct format and how to test/debug this on a PC?

You have to tell us what the error messages in the log say…

Is that supposed to be hex values? And I think you probably don’t want the newline (\n) that echo will add either.

echo -en "\xA5\x5B...

Check:

man echo

Thanks.
I can’t see anything in any logs. Which log should I see this in when I click the switch?

Thank you.
Yes they are hex codes so I’ve added the \x and also echo -en.
I’m not sure what you meant by “Check man echo”. Can you tell me?

On a Linux terminal, you can type man echo to read the manual page for the echo command if you wanted to know more about these specific options (arguments) or others.

I’ve picked this up again and I’m still struggling.
Here is what I can see in Wireshark:


And here is my command line switch:

- switch:
    name: "Lindy HDMI Matrix"
    unique_id: lindyhdmimatrix
#on switch output A to input 2
    command_on: echo -e  "\xa5 \x5b \x02 \x03 \x02 \x00 \x01 \x00 \x00 \x00 \x00 \x00 \xf8" | nc 192.168.2.50 8000
#off switch output A to input 1
    command_off: echo -en "\xa5 \x5b \x02 \x03 \x01 \x00 \x01 \x00 \x00 \x00 \x00 \x00 \xf9" | nc 192.168.2.50 8000

but I’m not seeing any activity on wireshark when I operate the switch.
Which suggests that my connection outward from HA isn’t working. Nothing showing in any logs.

I am guessing you are trying to control the HDMI switch sending some hex commands to it. Are you doing so via an IR port? (I found a device on amazon with the same name that has an IR port, and nothing else that would take commands). If so, there are a number of cheap IR blasters that are compatible with Tasmota or ESPHome (my preferred choice as not MQTT needed). Some others need to be converted with a hardware mod which is the road I took. Anyhow, once you have ESPHome (I can only speak to this option) installed on one with basic YAML I can share, you point the remote to it and it will print out the commands it receives. All you do then, is copy those commands into your ESPHome YAML and you have IR control of your HDMI switch. I did exactly that with a 4 port HDMI switch I use in my office. It works 100% reliably and was super easy and cheap to do.

1 Like

Why do you have spaces between the hex values?

That is a good offer. I have a stack of tasmota and mqtt running, so I may follow up your kind offer,if I cannot make this thing work.

Thank you Pieter. I changed it to:

- switch:
    name: "Lindy HDMI Matrix"
    unique_id: lindyhdmimatrix
#on swith output A to input 2
    command_on: echo -e  "\xa5\x5b\x02\x03\x02\x00\x01\x00\x00\x00\x00\x00\xf8" | nc 192.168.2.50 8000
#off switch output A to input 1
    command_off: echo -e "\xa5\x5b\x02\x03\x01\x00\x01\x00\x00\x00\x00\x00\xf9" | nc 192.168.2.50 8000

and it works

1 Like