CameraEvents Service - Dahua Events to mqtt

Ole

n3wb
Joined
Feb 5, 2018
Messages
8
Reaction score
0
Hi,

my Model is the Synology DS718+ ( LINK to Specs ).

I am using the Synology Docker Package and for example this Image: Mosquitto and this Unifi Controller. Both are running without any Problem.

Here is also a list of the architecture per Synology NAS: LINK
There is stated that the Docker Package uses X64, afaik.

Thanks for your help.

Regards Sven
 
Last edited:
Joined
Jul 14, 2018
Messages
28
Reaction score
7
Location
New Zealand
As per: NodeJS Module: node-dahua-api

psyciknz/CameraEvents

This is a python service I run in docker. One of the first I wrote from scratch, so the documentation is probably a little light.

I've updated the readme for some run information, (git clone, python CameraEvents.py). And will figure out making the docker image automatically (this is all learning to me).

The main things it can do are to convert all VideoMotion events and IVS events into switches that can then be read by OpenHAB and HomeAssistant (or anything else that uses MQTT). IT also has the ability to pull a snapshot from the camera and post that as binary data to mqtt.
Hi Psyciknz.

I'm also in New Zealand. I'm a bit stuck trying to use your github.

Whats the command for building the docker image. I'm used to having a file called "dockerbuild" not "dockerbuild.cross". I can't figure out how to use it the .cross file. PS. I'm using linux.

If i try and just run the script directly, i get the following error:

mike@server:~/.docker/config/dahua-mqtt-script$ python3 CameraEvents.py
File "CameraEvents.py", line 282
except Exception,ivsExcept:
^
SyntaxError: invalid syntax
 
Last edited:

Ole

n3wb
Joined
Feb 5, 2018
Messages
8
Reaction score
0
Hi,

I finally got it running in docker on my synology NAS.

My camera is a IPC-HDW5231R-ZE. I created a rule on the camera for CrossLineDetection, which is detected by the script correctly. But there are not Details on the IVS data like e.g. crossingdirection. Is IVS data depending on the camera model or is there something more to define in the config?

Here is the log for one event:
Code:
2019-06-23 13:11:54,254 - __main__ - DEBUG - [Carport]: --myboundary
Content-Type: text/plain
Content-Length:44
Code=CrossLineDetection;action=Start;index=0

2019-06-23 13:11:54,254 - __main__ - ERROR - Error getting IVS data: 'data'
2019-06-23 13:11:54,306 - __main__ - INFO - Snapshot Url: http://172.17.2.20:80/cgi-bin/snapshot.cgi?channel=0
2019-06-23 13:11:56,681 - __main__ - DEBUG - [Carport]: --myboundary
Content-Type: text/plain
Content-Length:43
Code=CrossLineDetection;action=Stop;index=0
Regards, Sven
 
Last edited:

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
Hi,

I finally got it running in docker on my synology NAS.

My camera is a IPC-HDW5231R-ZE. I created a rule on the camera for CrossLineDetection, which is detected by the script correctly. But there are not Details on the IVS data like e.g. crossingdirection. Is IVS data depending on the camera model or is there something more to define in the config?

Here is the log for one event:
Code:
2019-06-23 13:11:54,254 - __main__ - DEBUG - [Carport]: --myboundary
Content-Type: text/plain
Content-Length:44
Code=CrossLineDetection;action=Start;index=0

2019-06-23 13:11:54,254 - __main__ - ERROR - Error getting IVS data: 'data'
2019-06-23 13:11:54,306 - __main__ - INFO - Snapshot Url: http://172.17.2.20:80/cgi-bin/snapshot.cgi?channel=0
2019-06-23 13:11:56,681 - __main__ - DEBUG - [Carport]: --myboundary
Content-Type: text/plain
Content-Length:43
Code=CrossLineDetection;action=Stop;index=0
Regards, Sven
The lack of details suggests your camera it not a high enough firmware, or just doesn’t post the json that I saw in mine.

Do you get an event fired? As it should just end up like a video motion event which also has very little details.
 

Ole

n3wb
Joined
Feb 5, 2018
Messages
8
Reaction score
0
Hi,

yes I get an event. But the payload is just "CrossLineDetection". For MotionDetection there are two messages with payload "on" and "off".

Details of my camera:
Code:
Device Type:      IPC-HDW5231R-ZE
System Version:   2.622.0000000.18.R, Build Date: 2017-11-10
WEB Version:      3.2.1.515090
ONVIF Version:    16.12(V2.4.1.510971)
Could you check with your camera what version you are running?
Is there a way I can check if my camera provides a different json string?

EDIT:
Updated the Firmware:

Code:
Device Type:     IPC-HDW5231R-ZE
System Version:   V2.800.0000005.0.R, Build Date: 2019-03-25
WEB Version:   V3.2.1.709882
ONVIF Version:   16.12(V2.4.3.651299)
Now I get more Details :)
"CrossLineDetection With Human in LeftToRight direction for Entrance Region"


Regards Sven
 
Last edited:

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
Hi,

yes I get an event. But the payload is just "CrossLineDetection". For MotionDetection there are two messages with payload "on" and "off".

Details of my camera:
Code:
Device Type:      IPC-HDW5231R-ZE
System Version:   2.622.0000000.18.R, Build Date: 2017-11-10
WEB Version:      3.2.1.515090
ONVIF Version:    16.12(V2.4.1.510971)
Could you check with your camera what version you are running?
Is there a way I can check if my camera provides a different json string?

EDIT:
Updated the Firmware:

Code:
Device Type:     IPC-HDW5231R-ZE
System Version:   V2.800.0000005.0.R, Build Date: 2019-03-25
WEB Version:   V3.2.1.709882
ONVIF Version:   16.12(V2.4.3.651299)
Now I get more Details :)
"CrossLineDetection With Human in LeftToRight direction for Entrance Region"


Regards Sven
That's great. I might, cos it annoys me, make the detected "things" filterable. ie I get "smoke" when it's fuzziness on the camera, so I will exclude those. That will just leave Human and Vehicle.
 
Joined
Jul 14, 2018
Messages
28
Reaction score
7
Location
New Zealand
Hi I still have not been able to get this going.

This is my docker-compose.yaml

Code:
  dahua_camera_events:

    container_name: dahua_camera_events
    image: psyciknz/cameraevents
    restart: always
I was getting this error in the log:

Code:
2019-06-26 09:49:18,243 - __main__ - ERROR - Error starting:Failed to open/find all files,
2019-06-26 09:49:18,242 - __main__ - INFO - Loading config,
So i went and created a config.ini using config-master.ini and changed the docker-compose to:

Code:
  dahua_camera_events:
    container_name: dahua_camera_events
    image: psyciknz/cameraevents
    restart: always
    volumes:
      - ${DOCKERCONFDIR}/dahua_camera_events/config.ini:/config.ini
However I still get errors in the log for the dahua_camera_events container

Code:
2019-06-26 09:48:51,381 - __main__ - ERROR - Error starting:Failed to open/find all files,
2019-06-26 09:48:51,381 - __main__ - INFO - Loading config
Q: Is there a different settings file I need to use for the docker image vs the github page?

Q: Can someone please post their compose.yaml ?
 
Last edited:

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
Hi I still have not been able to get this going.

This is my docker-compose.yaml

Code:
  dahua_camera_events:

    container_name: dahua_camera_events
    image: psyciknz/cameraevents
    restart: always
I was getting this error in the log:

Code:
2019-06-26 09:49:18,243 - __main__ - ERROR - Error starting:Failed to open/find all files,
2019-06-26 09:49:18,242 - __main__ - INFO - Loading config,
So i went and created a config.ini using config-master.ini and changed the docker-compose to:

Code:
  dahua_camera_events:
    container_name: dahua_camera_events
    image: psyciknz/cameraevents
    restart: always
    volumes:
      - ${DOCKERCONFDIR}/dahua_camera_events/config.ini:/config.ini
However I still get errors in the log for the dahua_camera_events container

Code:
2019-06-26 09:48:51,381 - __main__ - ERROR - Error starting:Failed to open/find all files,
2019-06-26 09:48:51,381 - __main__ - INFO - Loading config
Q: Is there a different settings file I need to use for the docker image vs the github page?

Q: Can someone please post their compose.yaml ?
  1. cameraevents:
  2. container_name: cameraevents
  3. depends_on:
  4. - mosquitto
  5. environment:
  6. - ARCH=amd64
  7. - BASEPATH=/hdd/docker-data
  8. #env_file:
  9. # - /hdd/docker-data/env/arch.env
  10. image: psyciknz/cameraevents
  11. restart: always
  12. networks:
  13. - ha
  14. volumes:
  15. - ${BASEPATH}/ha-shared/cameraevents/:/opt/cameraevents/conf
  16. - "/etc/timezone:/etc/timezone:ro"
  17. - "/etc/localtime:/etc/localtime

Sorry posted from phone. Volume command is just to the directory.

The instructions are a little light as I wrote it for me then decided to publish. And I have have much feed back either way to the problems with it.
 
Joined
Jul 14, 2018
Messages
28
Reaction score
7
Location
New Zealand
Thanks.

What files should I put in
${BASEPATH}/ha-shared/cameraevents/

Do I dump the files from the GitHub into that folder?
 

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
Just the config.ini

The problem with most docker containers is they can’t prepopulate the host volumes with a default config. So always have to revert to this sort of manual config to start with
 

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
I've just updated the readme and added run instructions.

I probably wouldn't use my entry of ${BASEPATH}/ha-shared/cameraevents/ since there's a variable in there and it defines a fixed path.
But if you make a cameravents dir, put the config in there, then run the
Code:
docker run -v ${PWD}:/opt/cameraevents/conf psyciknz/cameraevents
you should hopefully get something going.
 
Joined
Jul 14, 2018
Messages
28
Reaction score
7
Location
New Zealand
Thanks. Yea I recognised the $variable. I'll try this tonight and hopefully I'll get in going. Thanks for your help.
 
Joined
Jul 14, 2018
Messages
28
Reaction score
7
Location
New Zealand
It's working.

I haven't played around with all the events yet, so I'm not sure what's supported by the docker.

Can the docker send different mqtt messages for different events so I can have a sensor for face detection in home assistant as well as for motion?
 

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
It's working.

I haven't played around with all the events yet, so I'm not sure what's supported by the docker.

Can the docker send different mqtt messages for different events so I can have a sensor for face detection in home assistant as well as for motion?
Not sure. POSs not. They might all just get identified as Ivs. Can you filter on the content is they’re all in the same topic?

My camera doesn’t tend to do face recognition so I haven’t played with it. I just use line detection and trip wire (and video motion)
 

DDDRelic

n3wb
Joined
Nov 28, 2017
Messages
15
Reaction score
12
@psycik Do you know what units the Center and Bounding Box values are?
The values I receive appear to be too large to be pixels.
I was hoping to use this information to locate where people/cars etc are and take actions accordingly.
 
Top