-
Notifications
You must be signed in to change notification settings - Fork 89
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
NVR support #9
Comments
I think that's doable. But I don't have an nvr and I'd need one to build out the functionality. |
I can help with debugging and testing. Is there a list of API somewhere? |
The problem is that I need an actual NVR so I can do edit-test cycles locally to get all the APIs correct. Without that I have no idea if my code would work or even where to start. I have to play around with the APIs to understand them and for that I need an NVR unit. |
I have already tested some API:
But I don't know what I should test next... If you can guide me, I may be able to send a PR... |
|
This looks like a way to detect number of channels/cameras:
|
I’m also interested in the NVR integration. I have a Dahua 4108 NVR, installed this great integration and I see “main” camera added and I have a preview of one of the cameras. But only one camera is visible. I simply added the IP of the dahua NVR and it detected 1 Device with 5 entities. |
I'll try to prepare PR. |
im also using dahua nvr and like to see it supported, when adding the nvr today im getting one camera. |
I did not find any API to detect number of cameras... However it may be possible to detect if the device is NVR (via |
Okay So I was going through the code and in camera.py I saw this
Channel refers to dvr/xvr/nvr channels. Channels are offset by one. Channel 0 = Camera 1; 1=2; 2=3 etc. I use this right now and I am able to get all events from an xvr running 11 analog cameras. https://github.com/algirdasc/appdaemon-apps/blob/master/dahua_mqtt.py |
Probably the most important part, the only thing I had to modify was a setting. Instead of defining a camera in the form of |
noob questone, what file is this replacing in the Dahua folder/whats should your file be named as? (i cant see any file named dahua_mqtt.py) |
I'm sorry if I was unclear, I did not change anything on this integration nor do I have it working. The link I posted is a different integration all together. It works through appdaemon. I only referenced so the maintainer of this integration has a working example of a script that will log on to a nvr/dvr/xvr. Perhaps it maybe helpful. Follow this post for details of the other integration, if you have further questions please post them to that thread. I'm subscribed and will answer there as not to derail this thread. https://community.home-assistant.io/t/dahua-ipc-to-mqtt-app/93327/174?u=mikefila |
what is this section undr init.py? If we use NVR address, it works and events are registered, but only for channel 1. Also there is no way to modify entity name, so even if we modify the channel in the code, it will link it to the same one. |
Yeah I have a hard coded channel coded through the code. I can make that an option when configuring the integration to allow you to pick the channel. I think that will work. |
And make am option for entity name pick, otherwise it assigns the same name to the same NVR when adding and no option to change it. |
I'm close to completing a change that allows one to set the name during configuration time. This will be the building blocks needed to support channels. It's basically the same configuration form now, but after you click submit, it'll open a new form with the name of the camera and lets you edit it. |
great! thank you. |
Platform dahua does not generate unique IDs. ID 3CPAZ5EF403317U_motion_detection already exists - ignoring switch.nvr_motion_detection Can you please add the sensor unique IDs as well? |
@rroller Ill be eager to test this when you have finished. |
Thanks. I'll make this the next thing I work on. I need to un-hard-code all the channels I currently have hard coded |
Amazing, I'm readily available to test this out for you. I currently have an NVR installed with 4 cameras (channels). The integration is able to pick up just the main channel at the moment. |
@haid45 when you added your camera, for the IP address, do you use your NVR IP Address? I assume you don't use the IP of the camera? So you'd be adding 4 camera's all with the IP of your NVR? |
@rroller, yes I used the IP address of the NVR as I wasn't able to get the individual ip's of the cameras. Well actually, I was but they seemed to be on a local network within the NVR because the ip's where along the lines of 10.0.0.1. |
Awesome, this is totally doable. I'm working on the changes now. |
How exciting! looking forward to trying it out 🥳 |
Hi I just installed this today for an XVR. I am able to add additional cameras, however, all the motion events for the cameras are tied together. When one has motion they are all triggered. I also noticed that the cross region detection is randomly firing and not reflecting actual events. I use dahua to mqtt and I am anle to see the events just fine, I had disabled it when I tried this intergration. I don't know if it's helpful but here is the yaml I use to make sensors from motion events.
|
@Mikefila thanks. Can you enable debug logs and post me the event logs? I think I'm probably missing something when triggering events... I think I need to include a channel. |
@Mikefila and others, I released 0.9.16 to address the events issues. Please give it a try. Now each motion event should be per cam as expected. |
Thanks for the quick response but it is still the same, mailbox is
|
@Mikefila weird, all the index values are |
That is because
btw I removed and reinstalled the cams just to make sure the indexes were right, that is why |
Thanks, this helps a lot. I'm going to try an make another fix. I'll report back once it is ready. |
This is the actual data that comes back from the device...
Notice it doesn't have anything to identify the device itself. That's fine for single cams, but when we are attached to an NVR I'm not sure I know how to identify which cam the event came from. |
The index is the right way to know which cam triggered the event. Would it be easier to add just one device (the dvr or nvr) and then select the channels to listen to. |
I've just released 0.9.17 with some extra debug logs. @Mikefila can you upgrade and paste in your event logs as you did before? |
I think I see a problem with how I've coded this. For single cams it works great. But for NVR's I'm creating a thread per channel to listen for events. Say you have 10 cams. I'll create 10 threads connected to the NVR to listen to events. Now all 10 threads will get the same events. And that's why we are seeing this duplication. Really I need a single thread to listen for events and have it dispatch to the correct cam integration |
Yes, I think that's the problem. |
I think I can put in a short term fix for now and work on the single thread approach (which is more involved) in a future update. |
OK 0.9.18 is released with a short term fix that hopefully fixes this duplication issue. |
As far as I can see this solved the duplication issue for now. |
I haven't installed .18 this is .17 The script i use now just basically transfers the event log to mqtt.
Same goes for
Where This is the value template I use to get events by name, I dont need to reference the camera index
To truncate, you can name events but not motion events. |
@Mikefila yeah it's best to use the event bus in HA to do these automations instead of the sensors I made. The sensors work for the simple case that lots of people will use but if you have a more advanced setup then you'll need to use the event fired on the bus as you correctly point out, has all the needed data.And with the latest update I believe they are deduplicated. |
This is great .18 is working separating the events. I am going to add my other cameras and I'll report if there are any issues. I apologize, I often leave out pertinent parts but expand on details. I spent sometime sorting through the JSON from the other script, so I'm pretty familiar with the event outputs. I though I saw you mention about using names. I wanted to explain that names can be unique but requires additional configuration by the user, so not really a viable option. What is the event type for the cameras? |
@Mikefila it's in the readme (let me know if it's missing anything and I'll update).. but it looks like this...
You can use anything in the event data (the data you posted above). Here's an example...
|
I was involved in a now defunct PR to add event handling to the Amcrest Integration. The developer had a very hard time getting it approved and gave up. One of the reasons was he added a config yaml change which was a no-no, so he went back and added config flow code, and then was told there were too many changes at once, break the PR apart. In this PR discussion, Balloob reviewed it as well, and had this to say about events and binary sensors... See home-assistant/core#40496 (comment) balloob on Nov 13, 2020
In revisiting this PR I just discovered that another developer picked up where blademckain left off and was somehow able to get event handling added to the Amcrest integration. (https://www.home-assistant.io/integrations/amcrest/#events) And I see some config yaml updates were added as well for tripwire detection as binary sensors!. Whoa. So inconsistent. No idea how that got approved I mention all of this because there is a LOT of overlap between the Amcrest integration and your new Dahua code. I started using your code because the original code owner for Amcrest bailed out, and it lacked doorbell support, tripwire, etc. Now I see the Amcrest integration has this capability as well (plus PTZ, and new support for NVR channels). What it still lacks is config flow support. I'm wondering what the possibility is for collaboration between the two integrations? It maybe boils down to which library is supported better - python_amcrest or python DahuaVTO. |
I don't like the HA model where you have to go through very rigorous code review and long release cycles for integrations. The HACS model is more ideal IMO where we can update integrations out of band with official HA releases. I'm just doing this for fun so I'll continue to build this integration. I also don't like the Amcrest branding. Amcrest are Dahua cameras rebranded (I know it's trivial :) ) The main blocker for me working on the Amcrest integration is the inability to get code merged because of the code review process. |
I understand! I was not suggesting dropping what you are doing here and working on the Amcrest Integration at all. I recall seeing somwhere in your comments that the eventual roadmap for this Dahua code was to be part of core. My intent was 2 parts - to show the direction the code needed to take in terms of how sensors and events should be handled from a HASS developer's perspective (and review). And to show that there is a lot of code that can be shared. BTW - All my cameras and NVR's are Dahua, except for the doorbells. Not a big deal, but I put up with the Amcrest branding and even suggested to blademckain that he fork Amcrest to be the new Dahua integration. I love what you are doing here and am finding it works really well for my needs. I just had not realized that the Amcrest core code had improved so much lately as well. |
Also using Dahua NVR. -rtsp_transport tcp -i rtsp://user:onvifpassword@172.16.4.102:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif |
the dissident programmer is here :) @rroller your work is great |
My DHI-NVR5208-8P-4KS2E with 7 cameras set up no issues. I'm getting camera feeds and intelligent motion alerts. However it takes 15 times longer than the Onvif integration to set up (60 sec as opposed to 4 sec for Onvif). Is this normal? Can anything be done? |
Nvr/dvr/xvr support was added after the fact. So it treats each instance as if it was a standalone ip camera. Instead of logging in once to the nvr, it logs in for each camera and slows the unit down. I don't think anything can be done on our side. I have 11 cameras on a ssd pi and it takes longer than a minute to load. I have 5 streams enabled. |
Can the logins be done simultaneously? |
Is it possible to support NVR? It would be nice to add one device (NVR) and all info about cameras would be detected automatically.
It should also solve a problem when cameras cannot be added because they are connected via NVR and NVR use specific custom IP addresses for them - and the IP addresses are not usable directly.
The text was updated successfully, but these errors were encountered: