Then I and others have told you or tried to tell you. If you cannot make it work as a command at the shell level, your issue has 100% absolutely nothing to do with Hone Assistant.
Make it work without anything in Home Assistant and the come back here for help on making it into a switch. Constantly asking things here that you cannot execute from the command line is worthless effort to us and others.
1 last try, you showed us an screenshot from a windows client where you were sending the ASCII, the line below was the hex format, why not try with hex format, like I do with my NC commands?
I can’t understand why doesn’t work.
All are correct.
I have at the add also with $1 variables at nc.sh with values and guess what!! Doesn’t work.
The values which i add at the below template i have tested first at the other software and works fine!
Well IMHO if you ran this command if you ssh into HASS:
nc -z 192.168.168.202 5001
And got nothing back, I would assume that means that port 5001 is closed or not available or you cannot get to it from where you ran the command. That is my whole point really.
You could change that to something like:
nc -z 192.168.168.202 80-6000
Which would scan every port from 80 to 6000. To see if there are any listening ports.
If the ports are blocked, maybe this helps:
Windows client is running from a different machine or virtual environment and is not HASS in ??? (not clear what you have, a Linux container or?). These are two completely different environments that could firewall off communications outbound in different ways, can they not? It is obvious that the matrix unit is not blocking anything from speaking to it, the question is can you send out requests to it.
I run 2 installations with HA.
The first is at raspberry PI 4 with Hassos and the second is from windows PC with VMware and have download the os for windows for VMware.
Maybe a shorter port range? Not clear but right from nc manpages:
Port Scanning
It can be useful to know which ports are open and running services on a target machine. The –z flag can be used to tell nc to report open ports, rather than to initiate a connection.
Every nmap give me other result.
I run nmap plenty of times and now also vmware finds the tcp ports without to change nothing. Noted that windows firewall is disabled.See the time difference which commands executed.