Integrating audio matrix with TCP commands

IT WORKED! It made an entity and I’m able to toggle it in “Call Service”
Thank you!

Not to take advantage of your help, but can you help me make a slider? for the volume? The commands start at

<12VO01\r

and end at

<12V038\r

This was the last hurdle I need to complete my smart home. Amazing! thank you

Take a look at this thread: Automation , send variable from slider in a shell curl command
You’ll need to add an input_number in helpers.

Basically the example from Shell Command - Home Assistant (home-assistant.io)

The '%03d' % notation is to output leading zeroes on 3 postions.

# Apply value of a GUI slider to the shell_command
automation:
  - alias: "run_set_vol"
    trigger:
      platform: state
      entity_id: input_number.av_vol
    action:
      service: shell_command.set_vol_to_slider

input_number:
  av_vol:
    name: AV Volume
    initial: 24
    min: 1
    max: 38
    step: 1

shell_command:
  set_vol_to_slider: >-
    printf "<12V{{ '%03d' % states('input_number.av_vol')|int }}\r\n" | nc ip_address port
2 Likes

I’m having a hard time implimenting this. I dont know if its coding, or a location issue. I had to make some adjustments to Koying’s code. (Thank you BTW) Its only 2 decimals, the command is 12VO (not a zero)

I have this into my automation yaml.

- id: Vol3
  alias: "run_set_vol"
  trigger:
    platform: state
    entity_id: input_number.av_vol
  action:
    service: shell_command.set_vol_to_slider

And this in the bottom of my configuration.yaml


# Apply value of a GUI slider to the shell_command
input_number:
  av_vol:
    name: Vol3
    initial: 24
    min: 1
    max: 38
    step: 1

shell_command:
  set_vol_to_slider: >-
    printf "<12VO{{'%02d'% states("input_number.av_vol")|int }}\r\n" | nc 192.168.2.156 8080

This volume slider appears as an entity, with the correct range, but does not work.

Can I put any of this code directly into a button?
Thank you

There is something fishy with the pipe when the shell command is called directly from HA.

Try

shell_command:
  set_vol_to_slider: >-
     bash -c 'echo -ne "<12VO{{'%02d'% states('input_number.av_vol')|int }}\r\n" | nc 192.168.2.156 8080'

I tested it end-2-end and seems to work.

1 Like

It works! There’s no way I would have figured out this on my own. No idea what “bash -c echo” means.
I’m going to try and make volume sliders in the mini media card… I may return to this thread if I get stuck since its so shell_command specific. Hopefully you’ll be able to help again if I do.
Thank you!

There are other threads with similar issues, where the resolution went through creating a shell script on the machine.
There appear to be some bug when the pipe character is used directly in a shell_command, at least when templates are used (which is 99% the case, really).

bash is the command line interpreter. What is done here is creating a “child” interpreter, passing it the command to execute via “-c”.

I can stack sliders using the custom slider card, but its shorter than the others? Is that because we’re using values 1-38?
Is there a way to scale this to 0 - 100% and have matching slider lengths?

Hello,

I’m trying to send tcp commands to a remote matrix but doesn’t works.

I have tested my connection with the matrix and i can send commands from a windows tool as a tcp client. All commands as this #|M001|F001|SV01|40|U|\r\n and as hex from windows client works, from HA nothing happens and nothing to check at logs…
From HA i have tried all possible combinations with no success.
The values at ASCII for this example is the #|M001|F001|SV01|0-100|U|\r\n
My configuration.yaml has the below switch for testing only.

switch:
  - platform: command_line
    switches:
       audac:
        command_on: 'echo -ne "#|M001|F001|SV01|60|U|\r\n" | nc 192.168.168.202 5001'
        command_off: 'echo -ne "#|M001|F001|SV01|30|U|\r\n" | nc 192.168.168.202 5001' 

I have created the below post at community but we can understand why i cant send the commands.
I have use from here the bash -c option but nothing happens again. Any ideas?

Below my post to see more details about the problems and the checks which we have done with no progress.

https://community.home-assistant.io/t/tcp-commands-from-ha-to-audio-matrix

Can anyone help me with my problem?

Pls stop repeating the same question every day… As told before , you need to command to work first… First step is to get it to work in an ssh terminal session, if that works, then create the command switch…

Try “printf” as suggested in this topic, instead of NC

Hello,
I have try the printf plenty of times from the beginning of my testing without any result.
Can you write me a command with printf with my ASCII value from ssh to see if i’m doing something wrong ?

I can’t write and test, I don’t have the device…
Plenty of examples in this thead, try those

I have try those examples. That why i said you if i have make mistakes at the syntax to saw me the right way.

try in ssh terminal

printf "#|M001|F001|SV01|60|U|\r\n" | nc 192.168.168.202 5001

This is exactly the command which i have tested.
I think that it’s impossible to find a solution to my problem.
But i will not stop until I will find the solution.
Thank you for your support!

1 Like

@nkaratzis Hi, It looks like your trying to integrate the Audac M2/ R2, i’m also planning on doing this, did you manage to make it work?

1 Like

Hello @muhammad ,

I could’t find a solution to this. If you manage to do this, please share here the way.
Thank you!

Yes definitely

Hello @muhammad,

Any news ?