Hello,
I need help to send TCP message from HA to other PC on a specfic port
for example:
message: “my message”
Destanation IP: 192.168.1.1
Destanation Port: 55025
Thank You
Hello,
I need help to send TCP message from HA to other PC on a specfic port
for example:
message: “my message”
Destanation IP: 192.168.1.1
Destanation Port: 55025
Thank You
I need to send the message via automation I don’t think it’s possible to do that with sensor or binary sensor that I can create using the TCP integration.
It is not clear how your end point receives the message. Here’s something you could try:
Create a rest command
rest_command:
send_message:
url: http://192.168.1.1:55025?message='my message'
Use it in an automation
action:
- service: rest_command.send_message
Otherwise you will have to use a shell command and figure out how to post your message with curl.
Just to be clear, are you asking how to set up a port listener on HA in the same way that you would on a Firewall that forwards all messages received on a certain port to a TCP service on HA?
No they are asking how to send from HA to a PC.
Sorry, translation mistake.
What is the listening service on the PC?
It may be possible to send out a simple asci string to the right port.
This is just a guess- remember I’ve never used TCP in Home Assistant, but if you provide a name, you should be able to see the entity name in settings > entities. You can then use this entity name in your script or automation.
I have no way to test TCP, but I just tried it. This is what I put into my sensors.yaml:
#---------- Example TCP entry ----------#
- platform: tcp
name: my_tcp_test
host: 192.168.1.57
port: 55025
payload: "This is my payload"
And in settings → entities, I find this:
sensor.my_tcp_test
I have a PC with TCP Listener, I can send ASCII message from other devices and I want to send TCP messages from HA to this PC, It’s a simple message that I need to send via automations for example if window sensor is open then send TCP Message “Window_Open”
I’m not sure how can use it… It’s a sensor how can i use it in action?
Looks good idea but I need to Check if I can send an HTTP messages instead TCP.
Out of my league. Maybe if you make it a switch template?
Not Working with Rest_Command
Solution:
command_line:
- switch:
name: my_switch
command_on: 'echo "message_on" | nc 10.10.10.1 55025'
command_off: 'echo "message_off" | nc 10.10.10.1 55025'
I’d definitely be interested in trying something similar now that I know that it’s possible. Have you found any documentation or online tutorials that explain this?
The command_line stuff is HA. That which actually does the work is the bash shell commands. Lots and lots of bash stuff out there, but here’s one. Echo is just a native bash command. Finally, nc is the netcat command.
The trouble is knowing what to look for. I know pretty much nothing about Bash so I don’t even know where to start looking, or what it would be called.
I remember there being an echo command in one of the old DOS based systems though that used to be used to add on screen text to batch file executions.