Telnet switch not working, tried alternative methods no luck either


I have a crestron HDMI matrix I have been using with hassio that I have wire sharked, and figured out how to control over telnet. Previously I ran my installation on an ubuntu machine via docker, and the only way I was able to get telnet to work was to ssh outside of hassio back to the box, and execute a shell script there.

Currently I have moved my installation over to a PI, set up the built in telnet switch, but as before, nothing happens. No log, switch doesn’t do anything, nada. I went to the hassio shell, and netcat does not work either as it is listening on

  - platform: telnet
        command_on: "sleep 1; SETAVROUTE 4; sleep 1"
        command_off: "sleep 1; SETAVROUTE 4; sleep 1"
        timeout: 2

I did have success trying curl telnet://, and got the greeting message from my matrix, but was not able to access the console or send a command. Even with the command below with necessary sleeps, it never seems to get the ack back.

("sleep 1; SETAVROUTE 4; sleep 1") | curl --raw --connect-timeout 3 telnet://

I get the greeting, but nothing else.

Finally I implemented the python script integration, wrote a script using pexpect, but I see it still does not let you use the import command despite others saying pexpect is pre-installed, so that is useless to me too.

import pexpect
import sys

child = pexpect.spawn('/usr/bin/telnet')
child.sendline('SETAVROUTE 4')

What am I doing wrong here? Telnet switch seems the easiest, but with no logger info, I can’t get anywhere.

What are those sleep 1;? Is that what your telnet server expects?

No, I originally put the sleep in my bash script to allow the console enough time to flush the welcome message, otherwise I would step on it and get a bad input command. WIthout the sleeps makes no difference. I enabled the logger

  default: info
    homeassistant.components.telnet.switch: debug

But still I get absolutely nothing in the log.

If it’s an interactive prompt (like you’d get with SSH but here over telnet) that you get on your device, I doubt that the telnet switch is suitable for your use case.

Also maybe you can inspire yourself from this other thread, it seems to fit your use case: Question about new Telnet Switch

I just took a look at the source code and your right, it just processes a single command line argument and spits it out to the socket.

I have written lots of python bash and shell, the issue is hassio doesn’t expose any dependencies. I can’t use pexpect or expect since it is included even with the python_script, and telnet is not either. I have tried testing directly at the console as wel…

Maybe that is the way to go then since imports are disabled in the core python_script integration: