fwestenberg / reolink_dev

Home Assistant Reolink addon
MIT License
549 stars 102 forks source link

Motion Detection not working other entities work #200

Open quadrupole1988 opened 3 years ago

quadrupole1988 commented 3 years ago

Describe the bug Motion detection on RLC-820A and E1Zoom always stays either clear or unavailable. Other entities (ie. IR Lights, sound PTZ) works great.

To Reproduce Install reolink intergration into Home Assistant 6.2 VM on Unraid server. Accessed through OpenVPN/DuckDNS when outside.

Expected behavior Motion detection to trigger detected motion in HA

Screenshots 1

HTTP used internally

2 The motion sensor is always clear or unavailable. It's usually clear, but I was trying everything under the sun to get this working. The only detected motion was testing from Dev Tools to set state.

3 Logs show no errors and successful subscriptions to both cameras.

4 Attributes are all present

5 Both cameras are reporting motion properly when detected

Environment: Please provide useful information about your environment, like:

Great work by the way. I'm just a noob at all this and this must've taken a lot of time to code. Thanks for the help.

Logs:

2021-06-07 12:34:05 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration reolink_dev which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-06-07 12:34:05 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration localtuya which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-06-07 12:34:05 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-06-07 12:34:05 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration smartir which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-06-07 12:34:05 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration smartthinq_sensors which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-06-07 12:34:05 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration picotts_remote which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-06-07 12:34:05 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration google_home which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2021-06-07 12:34:08 DEBUG (MainThread) [custom_components.reolink_dev.base] Registering webhook for event ID reolink_dev-event-ec71dbeeefac 2021-06-07 12:34:08 INFO (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.140 subscribed successfully to webhook http://homeassistant.local:8123/api/webhook/5f90f5647f9532ec18b8dc1eadb83c9e5ffc2dbe16aa2eb8eb611182dd2ed83b 2021-06-07 12:34:08 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.118 seconds 2021-06-07 12:34:09 DEBUG (MainThread) [custom_components.reolink_dev.base] Registering webhook for event ID reolink_dev-event-683943bda57d 2021-06-07 12:34:09 INFO (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.21 subscribed successfully to webhook http://homeassistant.local:8123/api/webhook/ec85af654cc11bc169a2cb298736ce590d6d8df8bb62486ce046e287c8ec6539 2021-06-07 12:34:10 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.921 seconds 2021-06-07 12:34:10 DEBUG (MainThread) [custom_components.reolink_dev.media_source] Creating REOLink Media Source 2021-06-07 12:35:10 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.113 seconds 2021-06-07 12:35:11 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 1.689 seconds 2021-06-07 12:36:10 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.114 seconds 2021-06-07 12:36:12 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 1.345 seconds 2021-06-07 12:37:10 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.143 seconds 2021-06-07 12:37:12 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.909 seconds 2021-06-07 12:38:10 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.121 seconds 2021-06-07 12:38:12 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.910 seconds 2021-06-07 12:39:10 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.121 seconds

yxd2000 commented 3 years ago

I share the same issue. After update HA to 6.3, the motion detection stops working.

image

Updates:

The motion sensor is working again with the latest Reolink_Dev patch. It took around 1 ~ 2 hour to take effect.

quadrupole1988 commented 3 years ago

I'm already on 0.17. isn't that the latest? Still not working for me.

sahni2021 commented 3 years ago

This describes exactly the experience I am having with the RLC-510AW camera using the reolink_dev integration inside HA.

sahni2021 commented 3 years ago

I'm already on 0.17. isn't that the latest? Still not working for me.

I'm running the same version (0.17) which I re-installed today. Also upgraded my RLC-510WA to the latest firmware. Unfortunately still the same problem: binary motion sensor available but not working i.e. not detecting any motion. All other properties (IR lights, Email, FTP) are working and I am able to switch them on/off in HA. Attributes (People, Face etc.) also available. reo1

snozzley commented 3 years ago

I'm also struggling with the same issue, so adding some details for more information:

Just connected through the NVR, (nothing direct to the cameras), motion sensors not working for any of them.

MarkGodwin commented 3 years ago

The NVR isn't listening on 'http://:8000/onvif/event_service' which is what the motion detection events rely on, so this isn't going to work. The PC app gets all of its data from port 9000, and is able to detect motion events. Someone did a pile of work exploring the protocol here [https://www.thirtythreeforty.net/posts/2020/05/hacking-reolink-cameras-for-fun-and-profit/]. It may be possible to get the motion events from the stream without subscribing to a video feed, but I think there's a lot of work to be done to achieve that, and any undocumented protocol is subject to change, so it's probably not worth the effort.

It looks like the best option currently is polling the web service for motion events with GetMdState.

snozzley commented 3 years ago

thanks, that's a really interesting read, and something I'll give a crack at using.

MarkGodwin commented 3 years ago

Reolink may have improved their protocol already, as there was a security advisory about the P2P protocol sharing usernames and passwords across the internet. At least I hope they have. But I'm definitely going to disable P2P and block the NVR from the internet now.

snozzley commented 3 years ago

Ah just realised that the above hacks (whilst super interesting) won't work with the reolink NVR in the picture, and I'd need direct access to the cameras, (and separate poe switch etc). So that's parked for now, shame that reolink make this so hard for us on the software side.. as the cameras themselves seem decent. Should really just run my own NVR, but wanted to save on cost/power usage, etc

quadrupole1988 commented 3 years ago

I ended up at first using polling GetMdState but found that although it works well, I miss the having the smarter AI feature of my 810a.

I'm now using Frigate NVR and it works really well on even on a 6600K with HA as a VM with no GPU acceleration. Motion detection is so much better than the native "dumb" motion detection on the E1Zoom. It was also super quick and easy to set-up. Just sharing this for others who are stuck in the same spot.

snozzley commented 3 years ago

Did you get polling for GetMdState working over the NVR? It seems to return 0 always, and seems to just ignore whatever channel I pass in.

quadrupole1988 commented 3 years ago

@snozzley

Sorry, I don't know. I don't use the reolink NVR. I record directly through FTP to my unraid server.

MarkGodwin commented 3 years ago

GetMdState seems to work for me with the latest NVR firmware. I tried with an earlier version, but that returned errors from the request. I think there may also be a GetAiState, but I don't have any cameras with AI Detection to test that. My plan was to use GetMdState to trigger some local person detection. I'm giving up with it, though. Following @quadrupole1988's recommendation I've now bought a coral.ai USB dev kit for use with Frigate NVR, and I'm hoping that will be a better and much easier solution. I'll still use the Reolink NVR for recording and powering the cameras, but use Frigate NVR for detection and HA integration. I have a pretty weedy i3 NUC powering my HA server, so I hope it has enough grunt to do the stream decoding.

quadrupole1988 commented 3 years ago

@MarkGodwin

Where did you manage to snag a coral.ai usb accelerator?

You shouldn't have any problems decoding the stream. I feed frigate the substream for both my e1 zoom and 820a and it seems to work great. The 820a substream has a lower resolution than the e1 (640x360 vs 640x480), but the ai detection is still fantastic. The documentation says that frigate was trained on 300x300 pixel images and resizes inputs to 300x300 anyways so I doubt your i3 will have problems handling that.

I'm gonna use my spare 1070 to accelerate things until I can get my hands on a coral AI as well.

MarkGodwin commented 3 years ago

I ordered it from mouser electronics, who had hundreds in stock. It was around $50 US + tax & shipping, which was much better than the crazy ebay prices. I nearly bought the m2 card, which is much cheaper, but I couldn't figure out which one (if any) would fit in the NUC.

kdeyko commented 3 years ago

Same issue here. I'm happy to provide any logs/screenshots and other debugging info if needed.

SpanishHearts commented 3 years ago

E1 Zoom here, Motion detection doesn't work.

lightheaded commented 2 years ago

I'm also seeing this on my setup without an NVR. It kind of works, but instead of reporting motion, it becomes unavailable.

Screenshot_20211030-140942_Home Assistant