Is it possible to make a sensor react to a TCP/IP ASCII string?

I have a software that can send a ASCII string like “alarm1” when something happens in that system, it will send it to a specific IP address via TCP/IP. I downloaded a tool and tested to see that the software sends the ASCII string and that happens:) I just now need to figure out how I can make a sensor that listening to “alarm1” and then change sensor status to alarm state.

Is this possible? I have had a look at https://www.home-assistant.io/integrations/modbus/ and https://www.home-assistant.io/integrations/tcp but I don´t have a “request/reply mechanism” so I don´t get this to work.

I use:
Hassio 0.102.2

I currently have applications that transmit their data via TCP and UDP. However, I am not receiving this data directly via Home Assistant. The solution I use leverages additional infrastructure (that I already have) so, if you don’t want to install more software, this may not be the road you want to follow.

The TCP and UDP packets are received by Node-Red which processes the data and then publishes the payload to an MQTT topic. In Home Assistant, I have MQTT Sensors that are subscribed to the topic and receive the payload.

Simplest example is how my phone reports its battery status to Home Assistant.

  • MacroDroid runs on my phone and reports the battery status via a UDP packet.
  • Node-Red receives the UDP packet on port 5010, reformats the payload then publishes it to an MQTT topic named phone/battery.
  • An MQTT Sensor is defined in Home Assistant and it is subscribed to phone/battery.

There are, of course, other ways to achieve the same result.

Cool, I have node-red running so this should be a solution that could work. Could you please share your node-red config?

It’s all described, in great detail, in this post:

Thanks for you help! I managed to get it working fine:)

1 Like