-
Notifications
You must be signed in to change notification settings - Fork 19
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
AlarmLocal on NVR #8
Comments
Little update. I'm using MQTT Explorer and I disconnect it then reconnected and all alarm are disappeared. Is this the behavior? But remains the issue of NVR under my camera name. What happens when I'll connect to the NVR all other cameras? |
I'll start with this one. Unsure if I have retain turned on for the message. I'm assuming by what you say I don't. But if Home assistant is looking at it, it should hold the last state until it gets a change (ie when cameraeveents restarts and an alarm is posted. If no alarm is posted, then HA will continue to display the last state, |
Techinically if you only have one camera, and it's channel 1 (or 0), you don't tell to tell the "camera" it's an NVR. Thats said, I've not dealt with AlarmLocal as a state....is this an external alarm connected to a camera? How would you expect to see it?
This could be it, which is part of a fall through of events, which looks like it's posted the channel name (CAM-05) then the name of the device (NVR - from the config.ini). Where as an IVS event is
To be consistent, the fall through should be: |
Is It possible to have an alarm on and an alarm off topics? I saw in the log that cameraevents receives the start and stop messages |
No, this alarm is connected to alarm inputs of the NVR (not to the camera) so I'm expect to see a topic like CameraEvents/NVR/AlarmLocal and then the number of the alarm input (my NVR has 4 inputs and 2 outputs) and the start and stop states |
Hmm any ideas how I would similate that, to look at it? Do I just need to jumper (make a circuit) the alarm input to trigger it? Can you post this as a new issue. I think the mqtt authentication is done. |
@valepe - Moved here. |
Yes, I wired so on my NVR input then I enabled the alarm setting the NO (normally open) or the NC (normally closed) type. |
I add an extract of my log if it can help you. |
I might be able to do it off this. I’ll make it like a video motion event. 2020-02-12 22:53:23,stdout,"2020-02-12 22:53:23,836 - main - INFO - dahua_event_received: NVR Index: CAM-05 Code: AlarmLocal In your log I don’t see a action=start, which I use the start the event. |
It is at the bottom of the file: Is it that do you search? |
I haven't tryed but I suppose that the index number is the number of the triggered alarm input. |
So Video Modion events have a start and stop mqtt topics? Good for alarms but for IVS events? Can you make them like video motion so? |
Yeah, so should trigger something like CameraEvents/AlarmLocal/CAM-05 payload true or false or on off. Whatever I have in videomotion events. Then in home assistant you can have a switch, or something to report on it. |
Good! |
Hmm that line |
I suppose that, for API compatibility, they are using the index of camera channel for reporting the alarm input number. |
Or maybe the index 0 is for the NVR itself and from 1 for the cameras? |
Another thing I found on the log: Does this line should match a mqtt publish of a snapshot? I will try adding the snapshotoffset=1 in the config and see if something change |
Found that on Dahua API:
Example URL: Link to API v1.67 pdf: |
Ok. So that mean it should be cameraevents/alarmlocal/0 or 1 with on/off Since it’s not the camera channel. |
Exactly, 0 - 1 - ... - X are the alarm input indexes. My NVR has only four inputs but other models can have up to 16 inputs. |
Sorry, I made a mistake. Output alarms can't be driven directly but you can drive the alarm inputs remotely with netalarm function. Then you can set an input to drive the output. I found this page about netalarm: Do you think that is it possible to add this functionality? |
So looking at this now, I'm not sure pulling an image or going to work, since the alarm channel does not relate to a camera. So I will remove that. If want a snapshot, I think you can send a I think it will get the index wrong - ie should start at 1 and it doesn't use the snapshot offset. |
I've pushed a new branch alarm-local which will add the alarm local message with a payload on ON and OFF when an event is received. I will be posted to: There is potential at the moment if the Alarm local index is greater than the number of cameras that it will crash. EDIT: just confirmed, it doesn't care, and will just post any index number of any alarm, regardless of the number of cameras. |
Thank you! How can I test it? I have it running in a docker container of my nas. Or can you build a container (I don't know how to do that)? |
Ok, yes. Can build one tomorrow. |
Thanks a lot! |
See if this works for you
I had issues with travis tests, which I fixed today...and wjhile I was at it, got automated travis builds to docker (with multiarchitecture) |
It doesn't work :( 2020-02-15 10:07:22,stdout, import requests 2020-02-15 10:07:22,stdout," File "CameraEvents.py", line 12, in <module> |
Cool, that was a good teaching lesson for me, so was able to add a docker test on the newly built image....and then i fixed the issue with the mossing requests. There's a new image to pull now. I'll have to figure out the build when the repo is tagged, but it's running in this branch ok now. |
It's online but nothing else. This is the log: 2020-02-16 07:24:58,stdout," Data = data.encode().decode("utf-8", errors="ignore") 2020-02-16 07:24:31,stdout,"2020-02-16 07:24:31,572 - main - DEBUG - [NVR] OnDisconnect(Success) 2020-02-16 07:24:26,stdout," Data = data.encode().decode("utf-8", errors="ignore") 2020-02-16 07:24:12,stdout,"2020-02-16 07:24:12,563 - main - DEBUG - Heartbeat: 2020-02-16 07:24:12.562919 2020-02-16 07:23:55,stdout," Data = data.encode().decode("utf-8", errors="ignore") 2020-02-16 07:23:22,stdout,"2020-02-16 07:23:22,422 - main - DEBUG - Heartbeat: 2020-02-16 07:23:22.422608 |
Sorry about that, something introduced in the tests caused that. New build is coming now (21:21) will take about ten mins. And I've just ran it here to verify it works. |
Thnaks, it works now. |
Snapshot seems corrupted because It start with double quotes but ends with nothing. Probably the full topic is truncated |
Yeah it did, I copied the code block fo the video motion. Which as above was not how I thought it should run. In my mind, as this isn't attached to a physical camera, it shouldn't trigger a snapshot, so I'll remove the download and post of an image. So now it should just post an AlarmLocal ON and OFF. Just committing, and it should make a new build shortly. |
It works like a charm! Thank you very much. I tried also the IVS event and all good but the topic, as already said, is corrupted:
As you can see the image ends without quotes and without the ending brace. |
I'm not seeing this. Yes sometimes the image is not there, but are you looking at it in something? Or saving the image with something and seeing it corrupted? If you're using an mqtt tool it may not show it all, at it's about 1-3mb of data for the image. |
I copied the image string and tryed to convert with an online tool but, as you pointed out, it can be MQTT Explorer that truncates the topics. |
I'm looking at your code but something that I don't understand: |
Pull the latest, updated about 1-2 days ago. I changed how the event notifications work for IVS and motion events. And now they do publish a close. IVS events do trigger a lot more than a motion event. So I’m not 100% happy with that Regaring the alarm local, as the alarm local is an nvr event and not tied to a camera, it does not make sense to try and attach it to a camera. Also if you only have 4 alarm locals and 16 camera channels, it will never work. |
So in your alarm local (1) config, you trigger a Recording of cam 02 and 03? Does that trigger an event on the cameras? What do the logs say on the NVR web site? what type of event does it trigger? Is suspect none. If it's just start recording because xyz event has happened, then surely thats like having cam 02 with a videomotion event also recording cam 03. Cam03 does not get any events triggered as that is the result of an event, not the cause. What version of the docker image are you running? Actually i need to make that a retained topic. |
Ok, just today I've pushed a new image that will post the alert state of devices and the code version as retained events. Current version is 0.2.0. Can you make sure you're on that, and then check the Hmmm, this might be the confusion:
Is published for an AlarmLocal. I'm not sure I should be doing this.....the Alarm["channel"]. |
I'm on 0.2.0 and no alarm input is setup to trigger cam recordings.
I'm agree with you, the second row shouldn't be there |
OK. I'll make a 0.2.1 and push a new version dropping
|
It works. Thank you for your help |
Ok, I just tried and it works but not as I like.
I'm trying the NVR with one camera only and CameraEvents connects to it and to my mqtt broker.
But when I tryed a input alarm on the NVR I saw these command on mqtt:
CameraEvents/CAM-05/NVR = AlarmLocal
Now two things that I don't know:
This becomes useless because my domotic hub knows when an alarm starts but not when it ends.
Can you help me?
My config reflects your example: I haven't listed the camera channels and I don't add the snapshotoffset
Originally posted by @valepe in #4 (comment)
The text was updated successfully, but these errors were encountered: