How to trigger Zoneminder cameras from Domoticz

I have been researching for a way to trigger Zoneminder from Domoticz and want to share how I did it.

Zoneminder have a port open for api communication, it can be for example trigger alarm on camera X.
The default port is 6802 and the string is

[cameraId]|[command]|[priority]|[cause]|[comment]
  • The cameraId you can find in Zoneminder, its called mid.
  • The command is ”on+20” where the +20 is the time in seconds to activate the camera.
  • Priority I’m not sure about but it seems to be how much weight the triggering have in Zoneminder, I use 123 but it might need some experimentation.
  • Cause is the text it will save in Zoneminder for why it was activated, for example ”Domoticz”
  • Message is a longer message that can be used to log what sensor it was, you can see it if you click the Cause link in the event list in Zoneminder.

Example:

5|on+10|123|Domoticz|Front yard sensor

For it all to work we need a way to trigger it from Domoticz and from what I have seen they do not have a native way to control Zoneminder. But they do have a block in blocky called start script that we can use. I picked python to do this but I’m sure you can use other scripts.

Script on the domoticz server

You need to open the console on the domoticz server, one easy way is to use putty and open a ssh connection.
1 . Login with your username and password.

Add a script in your /home/user/domoticz/scripts (Where user is the user that runs domoticz) called zoneminder.py
2. nano ~/domoticz/scripts/zoneminder.py

3. Copy the following: (Copy the text and right click in putty to paste it)

#!/usr/bin/env python

# Echo client program
import socket, sys

HOST = "192.168.1.29" # The remote host
PORT = 6802 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send (sys.argv[1]+"|on+"+sys.argv[2]+"|123|"+sys.argv[3]+"|"+sys.argv[4]+"\n")
s.close()

4. Change the host IP to the zoneminder server or use 127.0.0.1 if its the same server as the one running domoticz

5. Ctrl X and answer yes when it asks to save it.

6. Make the file executable

chmod a+x ~/domoticz/scripts/zoneminder.py

Domoticz blocky event

Now open you domoticz page and go to events (Setup->More options->Events)

This is a simple example:

Domoticz Blocky event

Note: If you want to skip the Message use ”” to send a empty string, the script might not like that you leave it empty.

I have not been using this for a very long time but it seems to work fine so far.
Hope it will work for you too, if not maybe you got far enough to figure out how to get it to work on your own.

I used:
Zoneminder v. 1.30.0
Domoticz v. 3.5744

References:

https://wiki.zoneminder.com/How_to_use_your_external_camera’s_motion_detection_with_ZM

http://www.sparxeng.com/blog/software/zoneminder-network-triggering

 

One Comment:

  1. I have noticed you don’t monetize your website, don’t waste your traffic, you can earn extra cash every month.
    You can use the best adsense alternative for any type of website (they approve all websites), for more details simply search in gooogle:
    boorfe’s tips monetize your website

Lämna ett svar

Din e-postadress kommer inte publiceras. Obligatoriska fält är märkta *

Denna webbplats använder Akismet för att minska skräppost. Lär dig hur din kommentardata bearbetas.