QuantumEntangledAndy / neolink

An RTSP bridge to Reolink IP cameras
GNU Affero General Public License v3.0
354 stars 49 forks source link

MQTT "motion" always returns "off" #129

Closed tr1plus closed 1 year ago

tr1plus commented 1 year ago

Describe the bug When using neolink in MQTT mode, the "motion" topic neolink/<cam>/status/motion always returns "off", even when the official client shows motion

To Reproduce Steps to reproduce the behavior. Example:

  1. Create this configuration file:
bind = "0.0.0.0"

[[cameras]]
name = "tuin"
username = "admin"
password = "123456"
address = "192.168.1.79"
uid = "xxx"
discover = "local"
mqtt.broker_addr = "192.168.1.25"
mqtt.port = 1883
mqtt.credentials = ["xxx", "xxx"]
mqtt.discovery.topic = "homeassistant"
mqtt.discovery.features = ["ir", "motion", "battery"]
  1. Launch Neolink
  2. Ensure reolink camera sees motion
  3. Check MQTT topic and observe new messages are coming in with payload "off"

image

I have a lot of "off" payload, no "on" payload image

I have done a capture while generating motion in front of my camera. I tried checking if I could find anything in the packets, but I'm not even sure how to start decoding these packages + my knowledge of the RUST language is non-existant. mqtt-motion.zip

Expected behavior When motion is occuring I expect the payload to be "on", when motion stops it should return to "off".

Versions NVR software: N/A Neolink software: the new firmware branch with login issue resolution Reolink camera model and firmware: argus eco; Camera reports firmware version v3.0.0.1981_23040606

QuantumEntangledAndy commented 1 year ago

Is this a PIR camera? Or one that actually works out difference in camera frames

QuantumEntangledAndy commented 1 year ago

Motion detection works by reading the alarm event list and firing a MotionStart event if alarm_event.status == "MD" or MotionStop if alarm_event.status == "none" from your issue report it seems that we are getting the "none" event but NOT the "MD" event. Which might mean that it is something else like "PIR" for example.

Could you attach a packet dump, so I could check

tr1plus commented 1 year ago

It's a PIR camera I believe (has the big black sphere below the lens on the front). https://reolink.com/product/argus-eco/ (but I have the black version)

I did attach a packet capture already in the first post :) mqtt-motion.zip

tr1plus commented 1 year ago

Also: I had shared this image in the other issue, but forgot to add it here: image

tr1plus commented 1 year ago

Not sure if this is related - figuring out how "pausing" is supposed to work (I found this which I based my research on: https://github.com/thirtythreeforty/neolink/pull/210). Happy to open another issue if this is completely different motion related code.

I've added the following to my camera config.

When I had on_client = true it did indeed pause when I wasn't using vlc to watch the rtsp stream

  [cameras.pause]
  on_motion = true # Should pause when no motion
  #on_client = true # Should pause when no rtsp client
  on_client = false
  mode = "none"
  timeout = 2.0 # How long to wait after motion stops before pausing

however, the camera never seems to pause with only on_motion = true.

I have a feeling that the PIR sensor "motion" and the software person/vehicle detection motion are different. I think I only get the "running man image" in the official client when the software motion is triggered.

image

I had tested this by setting up the audio alarm/siren. As far as I can tell, the alarm was going off because there was PIR motion, but the "running man" image didn't show up when the siren was going off, making me assume the camera has 2 types of motion detection.

However, the camera never pauses, doesn't matter if PIR or software had detected motion.

QuantumEntangledAndy commented 1 year ago

Unfortunately your wireshark dump is missing the login packets. If they aren't included then I cannot decode the AES (also need to know the password but I assume that it is 123456 like the other dump)

tr1plus commented 1 year ago

sorry! wanted to keep the trace short, didn't know how it worked.

Attached 2 captures including their logins

password indeed still 123456

Let me know if these are of help motion_test.zip

QuantumEntangledAndy commented 1 year ago

Oh the siren. I've been meaning to see if I can trigger that manually. Maybe I'll have a look, just don't want to disturb my family too much with the siren.

I'll look at the packets when I can. The AES pass phrase is made up of your login password and some random characters exchanged during the initial login messages so that's why I need the login packets.

QuantumEntangledAndy commented 1 year ago

So these are the relevant messages

start

<?xml version="1.0" encoding="UTF-8" ?>
    <body>
    <AlarmEventList version="1.1">
    <AlarmEvent version="1.1">
    <channelId>0</channelId>
    <status>none</status>
    <AItype>people</AItype>
    <recording>0</recording>
    <timeStamp>0</timeStamp>
    </AlarmEvent>
    </AlarmEventList>
    </body>

stop

<?xml version="1.0" encoding="UTF-8" ?>
    <body>
    <AlarmEventList version="1.1">
    <AlarmEvent version="1.1">
    <channelId>0</channelId>
    <status>none</status>
    <AItype>none</AItype>
    <recording>0</recording>
    <timeStamp>0</timeStamp>
    </AlarmEvent>
    </AlarmEventList>
    </body>

Seems that this is more to do with ai then with motion detection

QuantumEntangledAndy commented 1 year ago

I could group them all together and register motion as whenever both status and AIType are not none.

But maybe something where the actual type of AI dection could be reported would also be useful

QuantumEntangledAndy commented 1 year ago

This is being addressed in #131

First test build is here

tr1plus commented 1 year ago

is this motion logic also being used for the stream pause or not? As I have a feeling the motion pause is not working either.

I will test the MQTT things first. Does the PIR status also gets passed? or is your build now only looking at the "AItype"?

Oh the siren. I've been meaning to see if I can trigger that manually. Maybe I'll have a look, just don't want to disturb my family too much with the siren.

Tell me about it 🥲

tr1plus commented 1 year ago

I got an MQTT message with motion "on" - however I think it's only for the AI motion, the PIR doesn't trigger the message as far as I can tell.

QuantumEntangledAndy commented 1 year ago

No PIR is seperate. Theres another HA element for it

QuantumEntangledAndy commented 1 year ago

At least I think there was meant to be but I might not have done it right, since it seems to be missing from the docs... Hmmm

QuantumEntangledAndy commented 1 year ago

If I recall correctly PIR dosen't have an off state, it just fires a separate ON section event (it's a limitation of PIR). That's why there is no running man. I would have to add some sort of timeout for it I think

tr1plus commented 1 year ago

Well in that case I believe aimotion is working in mqtt.

I don't see any mqtt stuff for the PIR.

tr1plus commented 1 year ago

I have a feeling this also partially fixed the stream pause issue. I get a lot of [2023-08-08T11:20:32Z INFO neolink::rtsp] tuin: Motion Resume in the logs now when running as RTSP (which I didn't get before)

I however have a feeling it never gets paused I believe... (or nothing is showing up in the logs)

Is it possible the whole motion-related things are using the same messages/code logic, and something is "wrong" there where i never stops the PIR (so never pauses)?

QuantumEntangledAndy commented 1 year ago

Its the same code, but I'm no sure what issue (if any) you are describing.

Also I've remembered some of the things that stopped me adding PIR proper into HA. For PIR since its just an ON switch, theres not a good entity to show it. What we could do would be a sort of event that mqtt and ha could fire.

Also how does the offical client show that PIR is happening? I only remember the running man which is motion and AI

tr1plus commented 1 year ago

For PIR:

For what I think the issue is (I know it's not MQTT anymore, I would say MQTT is working for the AI and I can create a new issue of needed):

in "RTSP" mode I believe neolink never "pauses". It does print a message that it is resuming on motion, but it never pauses and I can always stay connected via RTSP.

in case of on_client=true --> Working scenario, but I want to pause on motion

in case of on_motion=true --> Not working scenario

tr1plus commented 1 year ago

P.S. according to the reolink site the PIR should show up in the mobile app to activate/deactivate https://support.reolink.com/hc/en-us/articles/360004379493-Turn-on-off-the-PIR-sensor/

However I don't think it's actually showing an indicator whether it's seeing something or not.

image

This is the explanation of reolink, so it would be good if this motion can also be used?

tr1plus commented 1 year ago

Had it run for some time now in RTSP with the pause on motion. It seems to have crashed after some time(I never generated any motion in this case. Was testing for it to start pausing):

Maybe it tried to pause, but it all went wrong after that:

[2023-08-09T08:21:52Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T08:50:29Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T08:21:45Z INFO  neolink] Neolink eefe3dfa71c494dad762907d7874a25fbdc73865 release
[2023-08-09T08:21:45Z INFO  neolink::rtsp] Starting RTSP Server at 0.0.0.0:8554
[2023-08-09T08:21:45Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T08:21:45Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T08:21:45Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T08:21:46Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 10:21:53.0 -01:00:00
[2023-08-09T08:21:47Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T08:21:47Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T08:21:52Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T08:50:29Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T08:50:29Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-09T08:50:29Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T08:50:29Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T08:50:31Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T08:50:33Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 10:50:40.0 -01:00:00
[2023-08-09T08:50:33Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T08:50:33Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T08:50:33Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T09:20:47Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T09:20:47Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-09T09:20:47Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T09:20:47Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T09:20:49Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T09:20:51Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 11:20:59.0 -01:00:00
[2023-08-09T09:20:51Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T09:20:51Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T09:20:51Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T09:51:05Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T09:51:05Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-09T09:51:05Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T09:51:05Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T09:51:07Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T09:51:08Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 11:51:16.0 -01:00:00
[2023-08-09T09:51:09Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T09:51:09Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T09:51:09Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T10:21:23Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T10:21:23Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-09T10:21:23Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T10:21:23Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T10:21:24Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T10:21:26Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 12:21:35.0 -01:00:00
[2023-08-09T10:21:27Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T10:21:27Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T10:21:27Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T10:51:41Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T10:51:41Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-09T10:51:41Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T10:51:41Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T10:51:42Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T10:51:44Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 12:51:52.0 -01:00:00
[2023-08-09T10:51:45Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T10:51:45Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T10:51:45Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T11:21:58Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T11:21:58Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-09T11:21:58Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T11:21:58Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T11:22:00Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T11:22:02Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 13:22:10.0 -01:00:00
[2023-08-09T11:22:02Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T11:22:02Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T11:22:02Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T11:52:16Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T11:52:16Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-09T11:52:16Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T11:52:16Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T11:52:18Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T11:52:20Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 13:52:28.0 -01:00:00
[2023-08-09T11:52:21Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T11:52:21Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T11:52:21Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T12:22:34Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-09T12:22:34Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-09T12:22:34Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-09T12:22:34Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-09T12:22:36Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:53453
[2023-08-09T12:22:38Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-09 14:22:46.0 -01:00:00
[2023-08-09T12:22:39Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-09T12:22:39Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-09T12:22:39Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-09T12:39:03Z WARN  neolink::rtsp::gst::factory] Media send thead failed... restarting. Cause: Could not push buffer to appsrc
tr1plus commented 1 year ago

FYI - I was able to mostly achieve what I wanted doing the following:

This allows me to use the built in motion trigger and use shinobi to only connect to neolink when needed. This hopefully has minimal batttery impact (in realms of whats possible)

next few days I'll be testing this solution with a solar panel outside :)

P.S. - still interested in getting pause in neolink to work, might also try to deepdive a bit in the code, maybe I find a way to implement an SMTP pause feature. But I have no coding experience in rust :)

QuantumEntangledAndy commented 1 year ago

P.S. according to the reolink site the PIR should show up in the mobile app to activate/deactivate https://support.reolink.com/hc/en-us/articles/360004379493-Turn-on-off-the-PIR-sensor/

However I don't think it's actually showing an indicator whether it's seeing something or not. image This is the explanation of reolink, so it would be good if this motion can also be used?

I've use this while testing the Push Notification and it only send on start not stop. PIR is only an event, the sensor detects change in heat and reports that. There's no native concept of start and stop, you have to add that at the application level.

Reolink seems to use it as a sort of low impact (battery wise) sensor that starts up other things like sirens and higher level motion like AI.

QuantumEntangledAndy commented 1 year ago

For SMTP motion we discussed this in other threads and it was decided that this might cause too much issue having to setup a smtp server and get all the ports forwarded and its a lot of work for the user. Instead we are trying to listen to the push notifications see #85

QuantumEntangledAndy commented 1 year ago

In terms of motion pause, I wanted to ask if it works after the first motion detection event. When you first connect the camera, the camera dosent' report its current motion status. It only reports changes in so if it starts in a motion state then it can cause issues until that motion stops.

QuantumEntangledAndy commented 1 year ago

Timed out waiting for new Media Frame is a known issue and totally unrelated to this. It seems sometimes the camera stops sending us media frames. I keep looking into it but there seems to be lots of possible reasons such as the camera dropping us because of connection issues

I made some recent changes to help address this by ensuring neolink pushes the acknowledgment frames faster and more reliably but it its not in master yet

tr1plus commented 1 year ago

In terms of motion pause, I wanted to ask if it works after the first motion detection event. When you first connect the camera, the camera dosent' report its current motion status. It only reports changes in so if it starts in a motion state then it can cause issues until that motion stops.

I believe it never works. As you saw in some console captures, it keeps printing "resume on motion" but never pauses. I can test again in a few days. Currently a bit busy.

tr1plus commented 1 year ago

Timed out waiting for new Media Frame is a known issue and totally unrelated to this. It seems sometimes the camera stops sending us media frames. I keep looking into it but there seems to be lots of possible reasons such as the camera dropping us because of connection issues

I made some recent changes to help address this by ensuring neolink pushes the acknowledgment frames faster and more reliably but it its not in master yet

This indeed also happens when rtsp client is used. Meaning that when an rtsp client connects it sometimes takes 20 or 30 seconds ro get an image (as it needs to re login ect)

Still I'm happy with the solution I put in place. Having everything centralized in neolink would be better, so I'm happy to keep testing certain setups!

tr1plus commented 1 year ago

For SMTP motion we discussed this in other threads and it was decided that this might cause too much issue having to setup a smtp server and get all the ports forwarded and its a lot of work for the user. Instead we are trying to listen to the push notifications see #85

Would there be a big difference between the setup for push and the setup for smtp? People using neolink are usually at least a bit tech-savy. No?

Still, push notifications would also be great I'd they work. Conceptually it's the same thing

QuantumEntangledAndy commented 1 year ago

Push notifications is conceptually much simplier as it requires zero setup from the end user.

QuantumEntangledAndy commented 1 year ago

If you have the time could you use this build with debug = true inside the [[cameras]] config. It will print out the raw xml messages we get from the camera. I want to look to see if there's anything odd about the Alarm Events you have.

QuantumEntangledAndy commented 1 year ago

From what I can test with my camera there is NO PIR event being sent. At least not over the AlarmEventList (which is used for motion and AI). This suggests that it is not the PIR that is messing up the pause on motion.

QuantumEntangledAndy commented 1 year ago

When you get the chance can you test motion pause on this one. I don't have AI or anything but MD on my camera so for me neolink seems to work alright

tr1plus commented 1 year ago

When you get the chance can you test motion pause on this one. I don't have AI or anything but MD on my camera so for me neolink seems to work alright

This is the output I get with this config

  [cameras.pause]
  on_motion = true # Should pause when no motion
  #on_client = true # Should pause when no rtsp client
  #on_client = false
  mode = "none"
  timeout = 2.0 # How long to wait after motion stops before pausing

Between minute 15 & minutes 25 I briefly walked away to make sure no motion was being triggered. So it recognizes the "resume", but never "pauses". When it pauses it seems to crash (but I'm not sure this pause is related as ih happens 22min later only)

23 minutes after the last message below, the stream is still working via VLC (so no pause I assume)

[2023-08-16T08:13:37Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-16 10:13:44.0 -01:00:00
[2023-08-16T08:13:37Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-16T08:13:37Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-16T08:13:37Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Sub Stream (Fluent)
[2023-08-16T08:13:43Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-16T08:15:11Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:12Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:13Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:14Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:15Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:16Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:17Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:18Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:19Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:20Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:21Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:22Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:23Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:24Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:25Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:26Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:27Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:28Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:29Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:37Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:38Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:39Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:40Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:41Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:42Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:44Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:45Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:46Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:15:47Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:17:01Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:00Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:01Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:02Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:03Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:04Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:05Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:06Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:07Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:11Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:11Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:12Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:13Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:14Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:15Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:16Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:18Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:25:18Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T08:43:51Z INFO  neolink::rtsp] tuin: Join Pause
[2023-08-16T08:43:51Z WARN  neolink::rtsp] tuin: Retryable error: Timed out waiting for new Media Frame

    Caused by:
        deadline has elapsed
[2023-08-16T08:43:51Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-16T08:43:51Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
[2023-08-16T08:43:53Z INFO  neolink_core::bc_protocol] tuin: Local discovery success xxx at 192.168.1.79:34186
[2023-08-16T08:43:55Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-16 10:44:02.0 -01:00:00
[2023-08-16T08:43:55Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-16T08:43:55Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-16T08:43:55Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Sub Stream (Fluent)
[2023-08-16T08:43:55Z INFO  neolink::rtsp] tuin: Buffers prepared
tr1plus commented 1 year ago

P.S. - this is same output as when using the debug true

[[cameras]]
debug = true
name = "tuin"
username = "admin"

Nothing extra seems to be printed to the docker output.

QuantumEntangledAndy commented 1 year ago

Docker might not be printing stdout then just stderr

QuantumEntangledAndy commented 1 year ago

From a conversation in another thread I might have gotten the true/false the wrong way around. Can you try debug = false

QuantumEntangledAndy commented 1 year ago

I think I have it fixed could you check out this build when possible

tr1plus commented 1 year ago

Will do some more testing later today/tomorrow, but I at least have it pause. Will need to check if it "starts" again on motion ect. Keep you posted!

thanks again for the work on this :)

[2023-08-16T13:59:23Z INFO  neolink::rtsp::states::loggedin] tuin: Camera time is already set: 2023-08-16 15:59:31.0 -01:00:00
[2023-08-16T13:59:23Z INFO  neolink::rtsp::states::loggedin] tuin: Camera reports firmware version v3.0.0.1981_23040606
[2023-08-16T13:59:23Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-16T13:59:23Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Sub Stream (Fluent)
[2023-08-16T13:59:29Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-16T13:59:31Z INFO  neolink::rtsp] tuin: Motion Pause
tr1plus commented 1 year ago

seems to be mostly working. I do get a "dropped connection" sometimes. I assume this is just a camera thing and neolink can't handle this specifically?

[2023-08-16T18:17:42Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-16T18:17:42Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Sub Stream (Fluent)
[2023-08-16T18:20:09Z INFO  neolink::rtsp] tuin: Motion Pause
[2023-08-16T18:20:54Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T18:20:54Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-16T18:20:54Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Sub Stream (Fluent)
[2023-08-16T18:21:38Z INFO  neolink::rtsp] tuin: Motion Pause
[2023-08-16T18:22:21Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T18:22:21Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Main Stream (Clear)
[2023-08-16T18:22:21Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Sub Stream (Fluent)
[2023-08-16T18:23:38Z INFO  neolink::rtsp] tuin: Motion Pause
[2023-08-16T18:43:46Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-16T18:43:46Z WARN  neolink::rtsp] tuin: Retryable error: tuin: Error updating pause state

    Caused by:
        0: Error while processing motion messages
        1: IO Error: Custom { kind: Other, error: DroppedConnection }
        2: Dropped connection
[2023-08-16T18:43:46Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-16T18:43:46Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
QuantumEntangledAndy commented 1 year ago

I'm currently looking into what might be causing it. The camera seems to drop us if there is even 500ms of interruption in the acknowledgment packets.

tr1plus commented 1 year ago

It seems to happen about Every 30minutes. My camera died over night (seems.it even died in only 5h or so) because of this (it recorded 30 seconds during Every motion change, so also when it re-connected because the image changes).

QuantumEntangledAndy commented 1 year ago

That's one of the reasons why it's hard to pin down. I think I can optimise the acknowledgment part of the code more and more but testing it waiting half hour to check if it actually improves anything is a slow progress.

tr1plus commented 1 year ago

I can imagine. If I can do anything to help, let me know :)

P.S. - do we close this issue since the original 2 issues (MQTT motion + motion pause) are solved? Is there any other issue open to track the above?

QuantumEntangledAndy commented 1 year ago

Yeah I think so there are enough open issues for the connection losses :(

QuantumEntangledAndy commented 1 year ago

If your still avaliable for testing could you check out this build it has lot of improvements to the ACK packet delivery and redoes the channel logic to help keep things running. Seems to work for me but more cameras to test on would be good

tr1plus commented 1 year ago

seems to be same issue - assuming you indeed pushed to docker image "latest".

I'll keep it running a bit longer

happy to keep trying :)

[2023-08-19T19:02:28Z INFO  neolink::rtsp::states::streaming] tuin: Starting video stream Sub Stream (Fluent)
[2023-08-19T19:02:33Z INFO  neolink::rtsp] tuin: Buffers prepared
[2023-08-19T19:03:04Z INFO  neolink::rtsp] tuin: Motion Pause
[2023-08-19T19:32:30Z INFO  neolink::rtsp] tuin: Motion Resume
[2023-08-19T19:32:30Z WARN  neolink::rtsp] tuin: Retryable error: tuin: Error updating pause state

    Caused by:
        0: Error while processing motion messages
        1: IO Error: Custom { kind: Other, error: DroppedConnection }
        2: Dropped connection
[2023-08-19T19:32:30Z INFO  neolink_core::bc_protocol] tuin: Trying TCP discovery
[2023-08-19T19:32:30Z INFO  neolink_core::bc_protocol] tuin: Trying local discovery
tr1plus commented 1 year ago

yup - happend again 30 min later

QuantumEntangledAndy commented 1 year ago

I'm not expecting perfect never fails but does it improve anything? Does it happen less often?