TCP Binary sensor

I need help setting up a TCP Binary sensor so that HomeAssisstant knows if my camera is on or off.
I thought i could use the status of the camera rtsp server over tcp.
Using wireshark and playing the stream with vlc I can see :

  1. first a SYN being sent to the camera on its port 8554 TCP 66 61924 → 8554 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1

  1. Then if the rtsp server is ON a SYN, ACK message back to the player TCP 66 8554 → 49961 [SYN, ACK] Seq=0 Ack=1 Win=14600 Len=0 MSS=1460 SACK_PERM=1 WS=16

  1. If the rtsp is OFF I get instead a RST, ACK TCP 60 8554 → 64584 [RST, ACK] Seq=1 Ack=1 Win=0 Len=0

I’m quite new to this but I’m guessing that’s normal behaviour so I tried to set up the TCP Binary sensor like this hoping to get a different value depending on the rtsp server status :

  - platform: tcp
    port: 8554
    payload: "PAYLOAD"
    value_on: Seq=1, Ack=1

It doesn’t work though as it always stays off and I get those errors :

2019-06-22 16:35:17 WARNING (MainThread) [homeassistant.helpers.entity] Update of binary_sensor.tcp_sensor is taking over 10 seconds
2019-06-22 16:35:17 WARNING (SyncWorker_8) [homeassistant.components.tcp.sensor] Timeout (10 second(s)) waiting for a response after sending 'PAYLOAD' to on port 8554.

Any idea on how to configure this properly?

I should mention that the rtsp server is password protected and i play the stream on vlc using rtsp://user:[email protected]:8554/unicast and I dont know if i need to include any kind of authentication to the tcp sensor config…

I can’t answer the question you asked but have you tried using a ping sensor. I use it to see if several of my network devices are online.

Thank you, i tried but unfortunately it doesn’t work because the device is always online… I tried adding the port but the sensor shows it’s connected all the time. Might try command line sensor