<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.staging.zoneminder.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spxzee</id>
	<title>ZoneMinder Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.staging.zoneminder.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spxzee"/>
	<link rel="alternate" type="text/html" href="http://wiki.staging.zoneminder.com/Special:Contributions/Spxzee"/>
	<updated>2026-04-20T07:47:27Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>http://wiki.staging.zoneminder.com/index.php?title=How_to_use_your_external_camera%27s_motion_detection_with_ZM&amp;diff=14390</id>
		<title>How to use your external camera&#039;s motion detection with ZM</title>
		<link rel="alternate" type="text/html" href="http://wiki.staging.zoneminder.com/index.php?title=How_to_use_your_external_camera%27s_motion_detection_with_ZM&amp;diff=14390"/>
		<updated>2017-02-17T02:16:07Z</updated>

		<summary type="html">&lt;p&gt;Spxzee: /* Requirements for Triggering */ With ZoneMinder 1.30.2 I have successfully recorded with a external trigger to a monitor set to Modect, so some of the text appears outdated&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Various Learnings from getting Zomeminder 1.28.1 working well on Ubuntu Server 14.04|&amp;lt;Home]]&lt;br /&gt;
&lt;br /&gt;
===Background===&lt;br /&gt;
Zone minder has an awesome &amp;#039;trigger&amp;#039; 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&amp;#039;s HW motion detection to trigger a recording on ZM. You can replace this &amp;#039;trigger&amp;#039; 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&lt;br /&gt;
&lt;br /&gt;
=== Core Trigger Architecture===&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
                      +-----------------+                                                                &lt;br /&gt;
                      |  zmtrigger.pl   |  record on/off                                                 &lt;br /&gt;
                      |listening on port|  directives over TCP (and other IPC mechanisms)                                          &lt;br /&gt;
                      |      6802       |&amp;lt;------+                                                        &lt;br /&gt;
                      |                 |       |                          polling or notification   x   &lt;br /&gt;
                      +-+---------------+       |                          - depends on device      / \  &lt;br /&gt;
                        |                       |                          capabilities            /   \ &lt;br /&gt;
                        |                       |                                 +---------------&amp;gt;     |&lt;br /&gt;
                        |                       |                                 |                \   / &lt;br /&gt;
                        |                       |                                 |                 \ /  &lt;br /&gt;
+----------------+      | record                |       +---------+               |                      &lt;br /&gt;
|                |      |                       |       | my own  |               |                device&lt;br /&gt;
|  Rest of Zone  |      |                       +-------| script  |&amp;lt;--------------+                      &lt;br /&gt;
|     Minder     &amp;lt;------+                               +---------+                                      &lt;br /&gt;
|                |                                                                                       &lt;br /&gt;
+----------------+                                                                                       &lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you enable OPT_TRIGGERS in Options-&amp;gt;System, then ZoneMinder starts a process called &amp;quot;zmtrigger.pl&amp;quot; (/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. &lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;please record monitor 3&amp;quot; (and optionally specify more parameters)&lt;br /&gt;
&lt;br /&gt;
===Requirements for Triggering===&lt;br /&gt;
* OPT_TRIGGERS need to be enabled&lt;br /&gt;
* Prior to ZoneMinder v1.30.2, the monitor mode MUST be set to Nodect (ZM won&amp;#039;t initiate recordings if in any other mode).&lt;br /&gt;
&lt;br /&gt;
(To combine both ZM normal recording, and say external triggers, with ZoneMinder prior to v1.30.2 you can always add two monitors pointing to the same camera - one in say modect and the other in nodect and use the latter one for external triggers)&lt;br /&gt;
&lt;br /&gt;
===Quick test===&lt;br /&gt;
Lets assume you have a monitor id of 1. As a quick test, just try this &lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
telnet zm_ip 6802&lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
And when connected via telnet simply type in&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
1|on+20|1|External Motion|External Motion&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should see ZM create a new recording for Monitor ID=1 for 20 seconds with a name and cause of &amp;quot;External Motion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Implementation Strategy===&lt;br /&gt;
&lt;br /&gt;
* Foscam&amp;#039;s [http://foscam.us/forum/cgi-sdk-for-hd-camera-t6045.html CGI document] shows that if the camera&amp;#039;s motion detection is enabled, then when it detects motion, you can use the getDevState command - if the value of XML tag &amp;lt;motionDetectAlarm&amp;gt; is 2 then motion is detected. It resets back to 1 if there is no motion detect&lt;br /&gt;
* Unfortunately, Foscam does not support posting events/callbacks when motion is detected. Note that there are cameras that support web hooks for motion notifications, like Axis cameras.&lt;br /&gt;
* so I need to poll it once every few seconds and check this value&lt;br /&gt;
* If this value == 2, send a record request to zmtrigger (and thanks to ZM&amp;#039;s ring buffer, I won&amp;#039;t miss the image that caused the alarm)&lt;br /&gt;
&lt;br /&gt;
===Source code===&lt;br /&gt;
Here is the code to do just that (and some other checks for optimization)&lt;br /&gt;
It loops through all my cameras and sends triggers when motion is detected&lt;br /&gt;
&lt;br /&gt;
https://github.com/pliablepixels/ZoneMinderFoscamHDTrigger/blob/master/arc_zm_foscamHDmotion.pl&lt;br /&gt;
&lt;br /&gt;
===Notes===&lt;br /&gt;
* Your imagination is the limit here - you can create triggers for any thing you want - ZM doesn&amp;#039;t care what the trigger is. As long as your script tells zmtrigger to start/stop recording and for which monitor, that is all ZM needs&lt;br /&gt;
* I initially used my camera&amp;#039;s HW motion detection for a few weeks, after getting frustrated trying to configure ZM&amp;#039;s own zone system, but when I understood how to use ZM&amp;#039;s own zone detection, it was better&lt;br /&gt;
* If you are worried if this constant pinging of the foscam may slow it down, it does not. I used it for weeks without any problem&lt;br /&gt;
&lt;br /&gt;
===References I found useful===&lt;br /&gt;
http://www.sparxeng.com/blog/software/zoneminder-network-triggering&lt;/div&gt;</summary>
		<author><name>Spxzee</name></author>
	</entry>
</feed>