Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not receiving events from NVR5xxx-I #168

Open
mooton85 opened this issue Feb 23, 2022 · 17 comments
Open

Not receiving events from NVR5xxx-I #168

mooton85 opened this issue Feb 23, 2022 · 17 comments

Comments

@mooton85
Copy link

Version

Latest

Describe the bug

When using the NVR5-I series, no events are received by the event handler. I have tested three models of NVR two of which are "-I" series and one which isn't. The one that isn't and is just a standard "4KS2" model works fine, I can receive all events from the unit.

Units Tested:

NVR5216-8P-I System Version V4.002.0000000.0, Build Date: 27-07-2021 No Events Received
NVR5216-16P-I System Version V4.002.0000000.0, Build Date: 27-07-2021 No Events Received
NVR5416-16P-4KS2 System Version V4.001.0000007.1, Build Date: 27-08-2021 Event Received Ok

Adding either of the two NVR5-I units listed above seems to work in every other aspect as I can view the streams, trigger switches (such as IR on/off for example) and also enable/disable disarming. It just seems to be the events that do not come through.

As a test I added both the NVR5-4KS2 and the NVR5-I to HA and then enabled event listening within developer tools, which resulted in the below capture for the NVR5-4KS2 when triggering alarm input 1.

Event 42 fired 15:47:
{
"event_type": "dahua_event_received",
"data": {
"name": "NVR5_4KS2",
"Code": "AlarmLocal",
"action": "Start",
"index": "0",
"DeviceName": "NVR5_4KS2"
},
"origin": "LOCAL",
"time_fired": "2022-02-23T15:47:49.245925+00:00",
"context": {
"id": "8e9a1ccb243e5756f95a4ab731b52172",
"parent_id": null,
"user_id": null
}
}

If I perform this same test on the NVR5-I units I get nothing received at all and I have also tried multiple event types.

To check whether the API was working correctly on the 5-I units I ran this script (I slightly modified the url to include "All" events/codes) from Ubuntu which gave me the following output when trigger local alarm input 1......

NVR5-4KS2
Code=AlarmLocal;action=Start;index=0
Code=AlarmLocal;action=Stop;index=0

NVR5-I
Code=AlarmLocal;action=Start;index=0
Code=AlarmLocal;action=Stop;index=0

So it looks like the NVR5-I units are working just the same as the NVR5-4KS2 as far as the API goes, just not in HA for some reason.

Not sure where to go from here but hoping you can provide some pointers on anything to check or any additional info I can provide?

I've enabled the debug log but nothing has appeared with regards to this from what I can see.

@jjscarafia
Copy link

I'm having the same issue.
I've only get some smart motion detecions randomply but could not replicate it again.
I'm using DH-XVR5108HS-I3

Other things that happens on my setup is that:

  1. let say I add channel 0 (camara 1) and channel 1 (Camara 2)
  2. I disable smart motion detection for channel 1 (Camara 2) on HA
  3. Checking on the NVR, the disabled camara is "Camara 1"

No matter for wich camara I disable / enable smart motion detecion, the one that is disabled is channel 0 (Camara 1)

I don't have experience to attache more info, but please let me know if I can give more details.

Any help appretiated, thanks.

@jjscarafia
Copy link

This is the log while I'm having smart motion events but seems not to be on ha

2022-03-01 22:09:34 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 1: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '3', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:34 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 0: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '3', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:42 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 0: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '2', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:42 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 1: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '2', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:44 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 0: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '3', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:44 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 1: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '3', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:51 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 1: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '1', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:51 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 0: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '1', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:53 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 0: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '2', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:53 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 1: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '2', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:09:54 DEBUG (MainThread) [custom_components.dahua] ClientError fetching information from https://192.168.0.167:443/cgi-bin/configManager.cgi?action=getConfig&name=Lighting[0][0]
2022-03-01 22:09:54 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 1.595 seconds (success: True)
2022-03-01 22:10:02 DEBUG (MainThread) [custom_components.dahua] ClientError fetching information from https://192.168.0.167:443/cgi-bin/configManager.cgi?action=getConfig&name=Lighting[1][0]
2022-03-01 22:10:03 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 1: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '2', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:10:03 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 0: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '2', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:10:03 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 1.572 seconds (success: True)2022-03-01 22:10:04 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 0: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '3', 'data': {'SmartMotionEnable': True}}]
2022-03-01 22:10:04 DEBUG (MainThread) [custom_components.dahua] Events received from 192.168.0.167 on channel 1: [{'Code': 'VideoMotion', 'action': 'Stop', 'index': '3', 'data': {'SmartMotionEnable': True}}]

@jjscarafia
Copy link

Hi @mooton85
For me it start to work if when linking each channel of the XVR I choose less options (for eg. just "smart motion detecion")
What is not working yet is the avilability to enable / disable smart motion detcion (always channel 0 is updated)

@mooton85
Copy link
Author

mooton85 commented Mar 8, 2022

Sounds like a different issue to mine to be honest, I get nothing at all.

I have noticed something in the log which I missed initially as I do have a doorbell/VTO attached and thought this was a false error as it works fine.....

2022-03-08 23:00:18 ERROR (Thread-10) [custom_components.dahua] Connection to VTO failed will try to connect in 30 seconds, error: [Errno 111] Connect call failed ('192.168.1.97', 5000), Line: 121
2022-03-08 23:00:20 DEBUG (MainThread) [custom_components.dahua] Finished fetching dahua data in 0.582 seconds (success: True)

However, the IP address listed is the NVR5-I not the doorbell, so it maybe this is related to the problem, if the integration is detecting the NVR5-I as a VTO/Doorbell and failing to subscribe to push (other functions work fine). When I add the NVR5-4KS2 this error is not present.

@dracon80
Copy link

I think you might be onto something with the doorbell.
I have the following in my logs constantly
Connection to VTO failed will try to connect in 30 seconds, error: [Errno 111] Connect call failed ('192.168.1.20', 5000), Line: 121

This is the IP address of my NVR, not the doorbell. The doorbell works fine and I receive events from it without issue directly (192.168.1.21). However I receive NO events at all from the NVR for any of the events that happen.

My NVR is a DHI-NVR5208-8P-4KS2E model.

@dracon80
Copy link

@rroller is there any logging or access I can give you to help troubleshoot this problem. More then happy to work with you to figure out what is going on.

@rroller
Copy link
Owner

rroller commented Mar 16, 2022

Sorry just haven't had any free time to dig in. Hopefully soon

@dracon80
Copy link

Not a problem. Let me know if I can provide anything to help out.

@dracon80
Copy link

dracon80 commented Apr 4, 2022

@rroller I found a line of code that is causing the issue for me at least. My NVR is a DHI-NVR5208-8P-4KS2E and this was causing it to be detected as a doorbell. Not sure what other systems start with DHI, but for me at least I was able to get it working by simply removing the DHI check as per the blow sample. This is from line 504 in init.py

def is_doorbell(self) -> bool:
        """ Returns true if this is a doorbell (VTO) """
        m = self.model.upper()
        """return m.startswith("VTO") or m.startswith("DHI") or self.is_amcrest_doorbell()"""
        return m.startswith("VTO") or self.is_amcrest_doorbell()

@HugasRadvilenas
Copy link

@rroller I found a line of code that is causing the issue for me at least. My NVR is a DHI-NVR5208-8P-4KS2E and this was causing it to be detected as a doorbell. Not sure what other systems start with DHI, but for me at least I was able to get it working by simply removing the DHI check as per the blow sample. This is from line 504 in init.py

def is_doorbell(self) -> bool:
        """ Returns true if this is a doorbell (VTO) """
        m = self.model.upper()
        """return m.startswith("VTO") or m.startswith("DHI") or self.is_amcrest_doorbell()"""
        return m.startswith("VTO") or self.is_amcrest_doorbell()

same problem here with dhi-nvr2108hs-i. removing dhi detection solved the problem for me too .

@mooton85
Copy link
Author

mooton85 commented Apr 8, 2022

@dracon80 I've only just got round to trying this and confirm that it fixed my issue too. Thanks for the info as it was driving me mad and I would have never found that.

Strange that only my -I unit was affected as pretty much any branded Dahua recorder starts with DHI.

@mcdhome
Copy link

mcdhome commented Jun 5, 2022

I have been troubleshooting this for weeks with no events flowing. It was working fine before for many months until maybe 1 month ago. Not sure why this turned up as an issue now when I think this lib has had no changes. But I can confirm editing out the m.startswith("DHI") restores events flowing. My cams/nvr is N85DL6Z cam, N54B3P2 NVR. I have no doorbell. The cams all appear fine in home assistant, but the events for motion (or anthing it seemed) stopped flowing maybe 1 month ago and all my automations didn't work.

This was the error that was showing up, same as above and all events stopped flowing until this fix was applied. Now this error no longer appears and events flow.

[custom_components.dahua] Connection to VTO failed will try to connect in 30 seconds, error: [Errno 111] Connect call failed ('{edit}', 5000),

My suspicion is that a recent NVR firmware and camera firmwware updates (I did both) altered the name it returned and used by this library. So maybe before it didn't start with DHI, but did now.

@mooton85
Copy link
Author

If anyone has both an NVR and VTO like me, then you're better off renaming it to "m.startswith("DHI-VTO") otherwise removing it completely fixes the NVR but introduces the issue on the VTO.

@mcdhome
Copy link

mcdhome commented Aug 24, 2022

{Putting this comment back in but using my personal account; this comment was just before mooton85 last comment before}....Circling back on this. Recent update on this line in the init.py still has an issue for folks with no doorbell, but have certain types of NVR. Suggest striking the "m.startswith("DHI")" or making it more specific like m.startswith("DHI-VTO"). Right now the line as is with DHI will quietly have all events fail for people using this but have no doorbell. My NVR is model N54B3P. It apparently returns DHI in the name but there is no doorbell. The logs ends up with notes around VTO failed to connect and no events flow, silently.

def is_doorbell(self) -> bool:
""" Returns true if this is a doorbell (VTO) """
m = self.model.upper()
#return m.startswith("VTO") or m.startswith("DH-VTO") or m.startswith("DHI") or self.is_amcrest_doorbell()
return m.startswith("VTO") or m.startswith("DH-VTO") or self.is_amcrest_doorbell()

@timvdsm
Copy link

timvdsm commented Aug 24, 2022

I have exactly the same problem with my NVR: DHI-NVR5216-16P-4KS2E.
I have 8 cameras Dahua IPC-HDW3849HP-AS-PV-28-S3 connected to it.
And I have activated https.

I don't see any event in HA using the standard custom_integration. When removing the DHI check, events are working.

@BasTijs
Copy link

BasTijs commented Sep 4, 2022

{Putting this comment back in but using my personal account; this comment was just before mooton85 last comment before}....Circling back on this. Recent update on this line in the init.py still has an issue for folks with no doorbell, but have certain types of NVR. Suggest striking the "m.startswith("DHI")" or making it more specific like m.startswith("DHI-VTO"). Right now the line as is with DHI will quietly have all events fail for people using this but have no doorbell. My NVR is model N54B3P. It apparently returns DHI in the name but there is no doorbell. The logs ends up with notes around VTO failed to connect and no events flow, silently.

def is_doorbell(self) -> bool: """ Returns true if this is a doorbell (VTO) """ m = self.model.upper() #return m.startswith("VTO") or m.startswith("DH-VTO") or m.startswith("DHI") or self.is_amcrest_doorbell() return m.startswith("VTO") or m.startswith("DH-VTO") or self.is_amcrest_doorbell()

Thanks, this solved it for me. I have a DHI-NVR5216-16P-4KS2E NVR.

@tomlut
Copy link

tomlut commented Oct 21, 2022

Same issue with my DHI-NVR5208-8P-4KS2E NVR.

I changed this in __init__.py

def is_doorbell(self) -> bool:
        """ Returns true if this is a doorbell (VTO) """
        m = self.model.upper()
        """return m.startswith("VTO") or m.startswith("DHI") or self.is_amcrest_doorbell()"""
        return m.startswith("VTO") or self.is_amcrest_doorbell()

to:

def is_doorbell(self) -> bool:
        """ Returns true if this is a doorbell (VTO) """
        m = self.model.upper()
        """return m.startswith("VTO") or self.is_amcrest_doorbell()"""
        return m.startswith("VTO") or self.is_amcrest_doorbell()

And after a restart the NVR was no longer detected as a doorbell and stopped generating errors about connection to VTO.

Thanks dracon80 for the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants