Display state of TCP switch

I’ve made switches for my amplifier matrix that controls multiple speaker sets. 2 shown below.
What I didn’t know was possible is now reality with help from this forum (thank you!)

switch.yaml

- platform: command_line
  switches:
    speaker_livingroom:
      command_off: >-
        printf "<11PR00\r\n" | nc 192.168.2.156 8080
      command_on: >-
        printf "<11PR01\r\n" | nc 192.168.2.156 8080
    speaker_diningroom:
      command_off: >-
        printf "<12PR00\r\n" | nc 192.168.2.156 8080
      command_on: >-
        printf "<12PR01\r\n" | nc 192.168.2.156 8080

How can I create a call command to show the current state of each switch? The only way currently is to turn it off and on, and engage it with home assistant.

Turning this into a toggle switch would be nice too!
Thank you.

Is there a command that returns the status from the device?

If so, you can use “command_state” or “value_template”.
If not, not clear what you have in mind to find out the actual status…

I’ve emailed the device manufacturer to see what they say about query commands.

I was hoping there was a clever way to check a state without changing it. Which now sounds more quantum physics than home assistant.

Or magic (but quantum physics IS magic, isn’t it) :joy:

Since we’re here, and you helped me create those volume sliders, can you tell me how to turn them into typical volume sliders? Right now they’re truncated. Here’s my attempts

I’m not a GUI guy :wink:
What is “typical” for you?

All the media sliders can be more custom, the YAML ones we created are always tiny. “Kitchen” in this example.

Dear Matt, I have an artsound receiver art54 with 4 zones and I’m also looking a long time to integrate this in home assistant as you did.
I have also a protocol for this receiver. i can send the PDF if you want.

Serial settings:
Art5.4 Main CPU Software Revision: 1.05
Use COM2 on Art5.4
Settings for serial port on control unit:
38400 baud, 8 databits, 1 stopbit, no par.
TCPIP Socket communication
ART 5.4 Main CPU version 1.06 or higher
IP (standard): 192.168.123.80 (may be modified)
Socket: 5017

When you want I can send htis PDF. In this protocol I read for ON or OFF in a zone :

Syntax:
*PWR,,RD;
Equivalent commands:
*ON,;
*OFF,;
Parameters
Zone | MAIN |
Example:
Client to server: *PWR, 1, ON; turns zone 1 on
Client to server: *PWR, 1, RD; reads power status
Server to client: *PWR, 1, ON; Zone 1 is on.

So When I change in your conf yaml <11PR00\r\n to *PWR, 1 ON; it can work you think?

  • platform: command_line
    switches:
    speaker_livingroom:
    command_off: >-
    printf *PWR, 1, OFF; | nc 192.168.1.23 88
    command_on: >-
    printf *PWR, 1, ON; | nc 192.168.1.23 88

But first I want to test command *PWR, 1, ON; with an app as you did. With app have you used?
Wich port do I have to use? I have on IP 192.168.1.23 three open ports :

  • 23 telnet
  • 80 http
  • 8888 sun-answerbook

I hope you can help me a little bit.

Best regards,

Tom

Thanks Tom,
I have no idea how to reply, I didn’t understand this a year ago, and now I forget most of what code I did learn.