Integrating audio matrix with TCP commands

I have an 6x6 audio amplifier and switch from No Hassle AV. The only GUI is through an Android App, and there is no IR or RF remote.

The No Hassle support team told me I can integrate the their device into HA using TCP commands, but I have zero idea how to do that, even after some research.
They sent a document with commands. I’m hoping someone will read this and it will make sense.

`

TCP
Ascii
IP Port: 8080

Output 1

Input 1 <11CH01\r
Input 2 <11CH02\r
Input 3 <11CH03\r
Input 4 <11CH04\r
Input 5 <11CH05\r
Input 6 <11CH06\r

Off <11PR00\r
On <11PR01\r

Volume Slider Starting at <11VO01\r and ending at <11VO38\r. So there are 38 separate commands

`

It continues like that for all other Outputs and Inputs.

I would love to just turn the speaker ON and OFF and volume in home assistant. button or automation.
I do not know any programing or NodeRed, and am learning the Yaml codes slowly.
Many thanks.
Matt

They didn’t give you any examples?
I can’t make out from this what to do.
I would assume it’s POST or GET command to the IP and port but. An example would be nice.

Thanks for the quick reply. The only thing they sent me were those commands in an XLS document. Nothing more… in fact, they even said:

“unfortunately we cannot offer education on how to implement them. TCP is it very extensive topic and differs depend on which platform you use. Below are the commands”

I can access the device through an IP address. I can access Audio Device through an IP Address. which has various connection details that look like router settings. Nothing that indicates the status of settings or volume.

Reading windows 7 - How to send data to tcp server from command prompt - Super User

It seems you can use command prompt in windows to test if it works.

telnet IP port [enter]

[Code] [enter]

If I understand it correctly

I connected, but 2 things:

  • I can not turn local echo off once connected
  • Every command attempt = Command Error.

I got a little help just now from No Hassle. all it said was : “Our customers use Packet Sender”
Getting help from these guys is like pulling teeth.

I’ll give that a test.

And yet they call themselves “no hassle”

1 Like

What exactly did you type at the telnet prompt? Are you aware that you should not send literal \r? It is an escape sequence for carriage return (CR) – enter.
Are you getting that command error as a response from the server through the TCP connection?
If you have a Linux environment available for testing, I would much rather use the netcat (aka nc) utility.

The telnet prompt only replies:

#[pound sign]

Command Error

Everything I type is doubled (local echo I believe, which I can’t turn off)
Oh I’m not aware of anything code rules. The last time I took a programing class was 1993. We did lots of HTML back then. I grew up on DOS prompt, so I’ve got that going for me, I can figure it out once I learn the rules.
Im running HA on a virtual linux box from my 2nd PC, and I have a Raspberry Pi 4 that I’m testing Lovelace on a touchscreen 4K Monitor. So far, I’m making great process. This is TCP is a hangup because its not part of HACS or the new UI.

Ok, this is how I would test this with netcat in GNU/Linux: printf "command\r" | nc ip port. printf will expand the \r escape sequence – you can see this if you pipe it’s output to xxd or hexdump:

$ printf "test\r\ntest" | xxd
00000000: 7465 7374 0d0a 7465 7374                 test..test

Since this approach does not involve any interactive entry of data, it should be much easier to debug than telnet.

Thanks Ondras, I typed that into the terminal and nothing returns. The test command returns the response you posted.
Can we skip right to a suggesting how to test it in home assistant as a service? or button?

I was able to use the commands with a simple TCP packet sending app on my Android. So it works.

Did the command exit immediately, or did you have to terminate it with ctrl+c? Maybe you should try printf "command\r\n" | nc ip port.

What exactly did you send?

Take a look at the TCP integration. It should be pretty similar to how the netcat command we are testing works, that’s why I wanted to try that first. The string in double quotes after printf should be your payload.

The TCP integration only provide sensors, not any service to do an action on the device.

Right. The payload is very simple, and it does work with a TCP app. I dont know how to write the payload send command through HA. I don’t care if I get feedback from the device.

The command I’m testing is <12PR00\r That will turn off Channel 2s speaker.

Can someone suggest how to write that in YAML? Or as a call Service?

I guess we will need to use command line switches then. Better get that netcat working…

1 Like

I dont know know what netcat is :frowning:

Here’s the command I sent on the app that works. The connection tab has IP and PORT

Netcat is nc, a command line utility for working with TCP (and UDP) connections.
Try this: printf "<12PR00\r\n" | nc ip_address port

Yes! I thought so too. Can you suggest the code for that and where to place it? The structure of YAML I am still learning.

If you already have switch: in your configuration.yaml, just append the lines that follow it in this example. Otherwise place the whole thing at the end of your configuration.yaml.

switch:
  - platform: command_line
    switches:
      speaker:
        command_off: >-
          printf "<12PR00\r\n" | nc ip_address port
        command_on: >-
          printf "<12PR01\r\n" | nc ip_address port

But before trying to integrate it with Home Assistant, you should make sure the commands work as expected.