Closed dapuzz closed 11 months ago
Hi! Does each camera have a different username or how do you differentiate them?
They have different channels. The channel is included in the alarm message sent by the nvr.
Login and Logout events are firing on channel 0
{ "Address": "0x45B2A8C0", "Channel": 0, "Descrip": "admin,DVRIP-Web:192.168.178.90", "Event": "LogOut", "StartTime": "2023-08-02 10:50:59", "Status": "Start", "Type": "Log" }
while cameras specific alarm have the channel number, 1 to 4
{ "Address": "0x45B2A8C0", "Channel": 1, "Descrip": "", "Event": "MotionDetect", "StartTime": "2023-08-02 10:53:30", "Status": "Start", "Type": "Alarm" }
Oh, I see. I'll have to implement that then. Can the number of channels be queried in advance?
I'll need that to create the entities when the camera is added
I am not sure I get your question. You can ask for the channel number in the initial config flow so you can give different names for sensors in the very first moment.
Let's say I have a 4 channel NVR system but I want to configure binary sensor for just 2 of them
Thanks
My intention is to add all motion sensors when you first add a host. For that I need to ask the host "hey, what channels do you have?"
Yes you can ask the user how many channel has the NVR system for sure the user should know this information. What about the entity name? Can we customizie the name such as
Do you know how to ask it how many channels? I don't have a camera like that. Regarding naming, you'll be able to rename them via the HA UI
Yes you can ask the user how many channel has the NVR
I want to ask the camera instead, this should be queriable :)
Please run these to find out:
pip3 install dvrip
#!/usr/bin/env python3
from pprint import pprint
from dvrip import DVRIPCam
host = "192.168.178.104" username = "admin" password = "camarablanca3"
cam = DVRIPCam(host, user=username, password=password, ) print("logging in") ll = cam.login() print("logged?", ll)
print('\n--------------------- get_info("General") -----------------') pprint(cam.get_info("General"))
print('\n--------------------- get_info("Camera") -----------------') pprint(cam.get_info("Camera"))
print('\n--------------------- get_info("Simplify.Encode") -----------------') pprint(cam.get_info("Simplify.Encode"))
print('\n--------------------- get_general_info() -----------------') pprint(cam.get_general_info())
print('\n--------------------- get_system_info() -----------------') pprint(cam.get_system_info())
print('\n--------------------- get_system_capabilities() -----------------') pprint(cam.get_system_capabilities())
print('\n--------------------- get_info("NetWork") -----------------') pprint(cam.get_info("NetWork"))
* then run it `./test.py`
This will output all the camera data, I suspect either `get_system_info` or `get_system_capabilities` should say how many channels there are for the alarm. As I said, I only have single cameras, so I don't know where to find that.
With that info I can add the feature
Oh, I found another one:
print('\n--------------------- get_info("Detect") -----------------')
pprint(cam.get_info("Detect"))
Yes you can ask the user how many channel has the NVR
I want to ask the camera instead, this should be queriable :)
Please run these to find out:
- In the shell:
pip3 install dvrip
- then make a test.py file
#!/usr/bin/env python3 from pprint import pprint from dvrip import DVRIPCam host = "192.168.178.104" username = "admin" password = "camarablanca3" cam = DVRIPCam(host, user=username, password=password, ) print("logging in") ll = cam.login() print("logged?", ll) print('\n--------------------- get_info("General") -----------------') pprint(cam.get_info("General")) print('\n--------------------- get_info("Camera") -----------------') pprint(cam.get_info("Camera")) print('\n--------------------- get_info("Simplify.Encode") -----------------') pprint(cam.get_info("Simplify.Encode")) print('\n--------------------- get_general_info() -----------------') pprint(cam.get_general_info()) print('\n--------------------- get_system_info() -----------------') pprint(cam.get_system_info()) print('\n--------------------- get_system_capabilities() -----------------') pprint(cam.get_system_capabilities()) print('\n--------------------- get_info("NetWork") -----------------') pprint(cam.get_info("NetWork"))
- then run it
./test.py
This will output all the camera data, I suspect either
get_system_info
orget_system_capabilities
should say how many channels there are for the alarm. As I said, I only have single cameras, so I don't know where to find that. With that info I can add the feature
hey @dbuezas sorry for the silly question, But I tried to execute your code, and I got this error
e03753f1cb86:/config# python3 camera_test.py
Traceback (most recent call last):
File "/config/camera_test.py", line 3, in <module>
from dvrip import DVRIPCam
and Yes I installed this pip3 install dvrip
!
did I miss something else?
That's odd. Can you do this from out of home assistant? (E.g a normal laptop in the network)
The value I suppose to report the number of cameras is the VideoInChannel in get_system_info(). Hope this helps.
can you post the jsons? Then I can compare with mine which only have 1 channel
I'm suspecting on the length of the dvrip.get_info("HumanDetection")["HumanDetection"]
array
I went ahead and used that. It required quite a refactor Please give it a test :)
https://github.com/dbuezas/icsee-ptz/releases/tag/v3.0.0
You'll have to enable beta releases for this integration in hacs
you will need to delete from- and re-add your cameras to- the integration
can you post the jsons? Then I can compare with mine which only have 1 channel I'm suspecting on the length of the
dvrip.get_info("HumanDetection")["HumanDetection"]
array
No HumanDetection at all in my configuration, sorry, I had to disable manually all human detection as the entity was unavailable.
Version 3.0.0 has lot of good new features, also multichannel is working as expected.
Let's wait for some other feedback, may be more clear to start index from 1 instead of 0 but for me it doesn't matter. Motion Alarm 1, 2, 3, 4 instead of Motion Alarm, 1, 2, 3.
I think I do not have HumanDection because of the missing capability.
Cool, then it worked! Oh, right I'll rename the entities so the channels start at one. Except for the first one, which will have no number (so it looks fine in cams with a single one)
Does disabling or enabling motion detection actually work? In my cameras it does change the right config but detections still trigger. I may need to disable them by default to avoid confusing people.
I may need to disable them by default to avoid confusing people.
I strongly agree!
Does disabling or enabling motion detection actually work for you?
I'll close it when I release the final version. I need to find a way to migrate
Hi David, I have a 4 channel chinese nvr system and I can get one camera binary sensor working fine, but if I try to instance the integration multiple times I get the message "Device is already configured" because of the same host. Is there a way to have one binary sensor for each channel?
Thanks a lot Dario