Implement serial commands to control an audio matrix!

Hi

I try to control a Zektor audio matrix that can be controlled by telnet into it and sending some text commands. I’m trying to implement that into HA but killing my head on proper way to do it after having read lot of threads here and documentations too :frowning:
Any idea how to implement that in most efficient way ?

here is what I have done so far but I don’t succeed to get it to work and be free of syntax error :frowning:

shell_command:
  zektor_commutation: 'bash /config/commut.sh {{states{"input_number.Zektor_input"},states{"input_numben.Zektor_output"}}}''
  zektor_volume: 'bash /config/volume.sh {{Zektor_output},{Zektor_volume}}''

input_number:
  Zektor_input: 
    name: Zektor Input
    initial: 0
    min: 0
    max: 180
    step: 1
  Zektor_output: 
    name: Zektor Output
    initial: 0
    min: 0
    max: 180
    step: 1
  Zektor_volume: 
    name: Zektor Volume
    initial: 0
    min: 0
    max: 50
    step: 1

and content of the two bash scripts:
commut.sh

 #!/bin/sh
echo "^SZ @$1, $2$" | nc -w 2 172.16.2.11 50005

and volume.sh:

 #!/bin/sh
echo "^VPZ @$1, $2$" | nc -w 2 172.16.2.11 50005

Thanks for your suggestions, ideas

Vincèn

Well input_numben is spelled wrong. You may need to make sure these are integers by using | int. States should be in () and not curly braces. You should check logs and test in dev tools to get what you need.

Thanks for the indication regarding the spelling. How can I debug that in dev tools ? as it implies variables so not sure how you can debug that properly :frowning:
For logs unhappy they can’t help me as I’m struggling already to get code properly written so can’t reload system till I have some good codes and so get logs :frowning:

Well, the template editor is your friend to debug with. You could have started like this:

Just to see if you get any output. You don’t, because there are errors.
Now slight changes, and picking sensors I do have, I get this:

So far so good. Now maybe you don’t want the trailing 0s, who knows?
You could test this:

Now, to be sure you get what you want (because adding the characters will make the output into a string), you could add the command line like this and test to see what you would be sending:

The key is to use developer tools first to work through your templates to get what you want and then use them. You have every tool you need, you just need to learn to use them.

1 Like

Thanks a lot @kbrown01 for the explanations and I got it now :wink: Will for sure use it in future to debug all my automations, scripts and other stuffs in HA :wink:
So now all my syntax is fine, just have to find out why the bash script itself is not running properly ! It’s very strange as I run that same command line (just replacing variable by a real value) on my linux laptop and it commands well the device but when I run it from command line on Hassio it does absolutely nothing, no error shows up (neither in logs neither on command line) and device is not changing state :frowning: Will have a look at documentation to find out if there is a real way to debug that part to find out issue…
I added also in my HA config file these to get more details to debug the shell_command part but unhappy it logs absolutely nothing :frowning:

logger:
  default: debug
  logs:
    homeassistant.components.shell_command: debug

Possibly it is permission and user issue.