Use Camera's MD
From:     https://wiki.zoneminder.com/How_to_use_yo ur_external_camera%27s_motion_detection_with_ZM


Intro Contents



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


Contents
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 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)
Requirements for Triggering (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)
Quick test Lets assume you have a monitor id of 1. As a quick test, just try this telnet zm_ip 6802 And when connected via telnet simply type in 1|on+20|1|External Motion|External Motion You should see ZM create a new recording for Monitor ID=1 for 20 seconds with a name and cause of "External Motion"
Implementation Strategy
Source code Here is the code to do just that (and some other checks for optimization) It loops through all my cameras and sends triggers when motion is detected zm_foscam, looks like I deleted that repo by mistake. I don't have a copy. But looks like someone else took that code and improved it - see his repo here.
Notes
References I found useful http://www.sparxeng.com/blog/software/zoneminder-network-triggering