Need the process to implement two buttons to send commands through tcp

I am trying to implement volume up/down buttons and gauge. I explored tcp command and found that it is only sensor and it is increasing volume continuously. Glad I figured out and removed without damaging receiver. It is mistake of my understanding on sensor and that tpc provides.

It seems options are to use shell command or command line. Let me know what would be better. I have two receivers of same type and it would help better develop kind of parameters for each ip. Otherwise, it is fine to specify 4 commands. These are high level steps that I assume

  1. Modify configuration.yaml to have shell_command or command_line for 4 commands to send up/volume for two IP addresses(receivers)
  2. Write script that invokes above
  3. put button on dashboard and invoke those scripts
    Let me know if I am on right path. Also, these commands return response containing current volume. How do I set for the gauge.
    Appreciate to validate and for the direction.

I see command_line integration supports switch, but it is required ‘command_on’, and ‘command_off’. Since I need just one action on button press, not sure if I can use this or not.

I guess I need to send this command
echo -n ‘Z1VUP;’ | nc 192.168.4.5 14499

Appreciate input.

1 Like

Thanks. I will define 4 shell commands and create 4 scripts to call from 4 buttons. it seems it gets response also and can be parsed to display in gauge.

May be there is better way to not to create so many scripts, but I can try with it.

I tried this command and nothing happening.

shell_command:
mrx_volume_up: “echo -n ‘Z1VUP;’ | nc 192.168.4.5 14999”

I tried even this from terminal of HA and it does nothing and no error
echo -n ‘Z1VUP;’ | nc 192.168.4.5 14999

Is there way to debug? From putty I can connect to it through telnet and send ‘Z1VUP’ and it responds.

I tried this, but there is no telnet
echo -n ‘Z1VUP;’ | telnet 192.168.4.5 14999

I find that nc command is working in interactive mode. But when I pipe from echo is not working. Any alternative? Thanks.

I tried enough these commands without luck. I want to explore anything else. Does mqtt allows to send tcp commands to receiver? Is it good idea to setup and learn and try mqtt. Appreciate it.

Home Assistant integrates with tens of thousands of devices and can use more than 2500 different integrations… It might help others to help you if you follow the Question Guidelines so that we have all pertinent information.

  • What is the actual goal?
  • What are the brand and model of the device?
  • Provide a link to relevant documentation
  • Is there an integration for the device?
  • Describe your HA installation type and any pertinent network details

Thanks for the reply. I bought Green few weeks back. My goal is to send command to Anthem receiver upon clicking on volume up/down button. There is Anthem integration but underlying media entity sends in percentage. This entity increases volume by 1 to 3 db instead of .5db increments depending on volume levels.

Using nc command always works sending command properly in inteactive mode.

homeassistant:~/myscripts# nc 192.168.4.5 14999
Z1POW1;
Z1POW1;Z1INP3;Z1ALM6;Z1VOL-34.5;

Also sending this command from TCP command works. But I need ondemand to send tcp command and not sensor.

I tried all these and they do nothing. It never works when I pipe echo to nc command.

homeassistant:/config# bash -c ‘echo “Z1POW1;” |nc 192.168.4.5 14999’
homeassistant:/config# bash -c ‘echo “Z1POW1;\n” |nc 192.168.4.5 14999’
homeassistant:/config# bash -c ‘echo “Z1POW1;\r\n” |nc 192.168.4.5 14999’

I spent enough time on these commands and wondering any alternative integrations and not sure mqtt helps. I know C, java and did even use python and if the direction is given I can write python code as well. Appreciate it.