How to use your external camera's motion detection with ZM

From ZoneMinder Wiki
Jump to navigationJump to search

<Home

Background

Zone minder has an awesome 'trigger' architecture which allows any external event to trigger a recording on ZoneMinder. This section explains the basic architecture and then goes on to describe how you can use your own camera's HW motion detection to trigger a recording on ZM. You can replace this 'trigger' with any other event - such as, for example, triggering your ZM recording when say your Nest thermostat goes to Away mode. The options are limitless

Core Trigger Architecture

                      +-----------------+                                                                
                      |  zmtrigger.pl   |  record on/off                                                 
                      |listening on port|  directives over TCP                                           
                      |      6802       |<------+                                                        
                      |                 |       |                          polling or notification   x   
                      +-+---------------+       |                          - depends on device      / \  
                        |                       |                          capabilities            /   \ 
                        |                       |                                 +--------------->     |
                        |                       |                                 |                \   / 
                        |                       |                                 |                 \ /  
+----------------+      | record                |       +---------+               |                      
|                |      |                       |       | my own  |               |                device
|  Rest of Zone  |      |                       +-------| script  |<--------------+                      
|     Minder     <------+                               +---------+                                      
|                |                                                                                       
+----------------+                                                                                       

If you enable OPT_TRIGGERS in Options->System, then ZoneMinder starts a process called "zmtrigger.pl" (/usr/bin/zmtrigger.pl). This is a perl script that basically offers an easy to use interface for anyone to send it commands to its default TCP port (6802) to initiate/stop recordings. Note that zmtrigger also offers other means of IPC - I just found the TCP channel easy and reliable.

zmtrigger does not care what caused the event. All it is waiting for is a simple text instruction from anyone capable of sending a command to port 6802. So what that means is I can write any program that monitors anything, and when my program thinks something happened which warrants a recording, all I need to tell zmtrigger is "please record monitor 3" (and optionally specify more parameters)

Quick test

Lets assume you have a monitor id of 1. As a quick test (remember to enable OPT_TRIGGERS), just try this telnet zm_ip 6802 And when connected via telnet simply type in

1|on+20|1|External Motion|External Motion