[SOLVED] Switch using Telnet Commands to 8x8 ATEN HDMI Matrix

I seen in some previous posts that the switch command can be used to send Telnet commands. I have tested my HDMI matrix using Telnet and I can control it as expected, however my issue is that I cant send the commands from Hass.IO as the telnet session requires a username and password.

Is there a way to do this ?

anyone know how to pass credentials in telnet session ?

Does this help? https://serverfault.com/questions/92736/send-login-credentials-and-commands-using-shell-script-via-telnet

Did a bit of digging an found some sort of advice, though at this moment it doesn’t seem to be working. It must be stated that when I run the commands below in Putty it works as expected.

In my configuration.yaml I have the following;

switch:
  - platform: command_line
    switches:
      xboxone_2_homeoffice:
       command_on: /config/hdmimatrix/xboxone2office.sh
       friendly_name: "Xbox One to Office TV"

This switch then calls a script file which has the following in it;

{ sleep 1; echo -e “username”; echo -e “password”; echo -e “ss 03,06”; echo -e “exit”; } | telnet 192.168.1.10

I have also run from the SSH on the HASS.IO the following command

chmod 755 /config/hdmimatrix/xboxone2office.sh

Now as expected the swich now appears in the states but when run it doesn’t make the changes expected, in fact it doesn’t appear to do anything at all.

Im probably missing something but I have been looking at it that long now my head hurts lol

Your script doesn’t look like the one I pointed to on serverfault. For a start you surround your echo commands with curly brackets { }, whereas the example uses plain brackets ( ).

Morning @nickrout, further searching in the community took me to the following topic, this is where the deviation in syntax came from

Still doesn’t work though so will try it with normal brackets and see.

you can check this topic here

@elRadix you any idea how I could install Expect on Hass.IO ?

if you can logon in ssh in hassio (using the ssh addon I guess) you could try these commands…

apk update
apk add busybox-extras
apk add expect

ps. I’m not an hassio user

Thanks @elRadix seems to look positive … just need to find where it was installed now

try

which telnet
which expect

I guess you’ll have to re-execute these command when there is a new HA update…or create a script to run at hass start with an automation ie. shell_command

I’ve recently purchased one of the same HDMI switches and hooked it up to my Hassio server via usb-to-rs323 cable. however im unable to get the hang of how to control it via command/ssh. Would you be kind enough to shed some light on it for me please and explain how you have controlled it to change hdmi ports.

If you telnet onto the device the switching command is fairly simple

ss 0x,0x

So if you wanted to send source 3 to output 6 the command would be

ss 03,06

1 Like

Opened this topic some time ago, but only recently got it working.

So just to close off this thread thought i would summarise what has been done to resolve my problem.

  1. Installed PyScript … this was done via HACS

    HACS - Pyscript Install

  2. This created a pyscript folder in the root of my /config

  3. create a script file in the pyscript folder for each of the options, If you use all 8 inputs and all 8 outputs that will be 64 scripts in total … example of one below;

@service
def ftv_charlottes_bedroom_set():
    import telnetlib
    import time
    HOST = "192.168.1.10"
    telnet = telnetlib.Telnet(HOST)
    telnet.write(b'admin\r\n')
    task.sleep(1)
    telnet.write(b'admin\r\n')
    task.sleep(1)
    telnet.write(b'ss 07,03\r\n')
    task.sleep(3)
    tn_read = telnet.read_until('Enter Password:'.encode('ascii'), timeout)
  1. Once you have created all these you can go to Services select pyscript.<> to run it.

I have built on this by building dummy switches to set the status etc but above is the basics to get your Aten HDMI matrix switching inputs and outputs from HA

1 Like