Any Interest in a Plugin Style event system?

Anything you want added or changed in future versions of ZoneMinder? Post here and there's a chance it will get in! Search to make sure it hasn't already been requested.
Post Reply

Any Interest in a Plugin Style event system?

No
0
No votes
Yes
2
67%
Where have you been all my life?!?
1
33%
 
Total votes: 3

KinkyMunkey
Posts: 2
Joined: Mon Jul 11, 2005 9:30 pm
Location: Baltimore

Any Interest in a Plugin Style event system?

Post by KinkyMunkey »

Hi, I've been wanting a way to have zoneminder trigger events other then X10 for awhile.... (and i haven't been on the forums or upgraded in awhile so if this has been done already please inform me)


Basically, I was going to rewrite the event trigger part so that you can have it run a perl script when an event occurs, this allows for limitless possiblities to have zoneminder trigger external events...

events such as:
-- Popup a window on a computer, or maybe your MythTV box, when someone walk up to the front door.... (event triggers UDP packet to external program runing on another computer)

-- Or same idea, but playing a doorbell sound on a computer when someone walks in the front door

-- Start recording on a different computer when someone triggers an event (just Http request to the other zoneminder box to "force alarm", turning it off is the trick)

--Trigger X10 through a remote computer, if your module doesn't happen to be plugged in to the same computer as the camera triggering the event (i have 3 zoneminder cpus (600mhz p3s) throughout my shop/house)

--Anything else, CURL would be the easiest way, use it to send an secure https request to a remote server. (Curl w/ https is the simplest way to keep anybody from listening/ faking events since they won't know the command being sent even if they can intercept the ethernet packets on your network)

The idea is to allow plugins w/out ever having to modify the actual ZoneMinder Program, you just add your own custom plugin in a seperate directory, this provides the most features without effecting the stablity or size of the main program, plus no problems upgrading if you have specially code triggers or events.

For backwards compatiblity i would propose using the same box where you currently type in X10 trigger codes. The new format would be TriggerScriptName(paramaters to pass to script), etc...

You can provide a comma seperate list of events.... If it doesn't detect a ( or a ) in the trigger it will default back to the old style X10 events for backwards compatiblity (that way we don't mess up people's setups when they upgrade)

The program would search for TriggerScriptName in a TriggerPlugins directory...

if found it would execute it and pass the following variables:
EventID (logging, or to grab the picture that was just saved)
Camera Name
Camera ID #
The contents of ( ), Unformated and untouched

if the script isn't found, an error would be logged and the calling function would continue to run.

If the script crashes, it CAN NOT be allowed to crash the calling functions...

I'm not 100% sure how to do this, hopefully it can be done simply by

include "PluginScript.pl" || LOG "ERROR RUNING PluginScript.pl" but i'm not sure if include will exit gracefully under all conditions...

any suggestions on this part would be appriciated. i would like to avoid launching a seperate instant of perl via shell to execute the script (while an option, this would 'cause an unneccisary amount of system overhead IMO)


I should be able to do this in under 10 lines of code, and w/ the ( ) checking it would skip executing the additional code if it's not needed.


So my only real question is, Is anybody interested in me writing this and submitting it back to the code tree?

has anybody who wrote a simliar hack for zoneminder that needs additonal variables from the main program? such as percentage of area triggered by the motion detector or something else i haven't thought of? (though you could always use EventID to fetch the picture and analyze it seperately)

and last, is passing just the EventID acceptable? or should i somehow allow an option to pass the captured image to the plugin also? (capturing a single image, the first image of detected motion, is more then likely worthless in most cases since nothing would be visible) and this plugin should only run once.

Any tips or suggestions on how exactly to interface the plugin would be greatly appriciated, otherwise i'll just figure it out....

Remember this must support mutiple plugings, so you can't just include the file and call the "main" function, since the 2nd plugin would have the same function name.

using the name of the script as the function name could be dangerous (allowing whatever you type in the event trigger box to be run as a command)

right now i'm going for a direct run approach... it runs when included and exits back out, no function calls required...

Oh, and disclaimer: forgive my syntax and function names, i've been using PHP for the past year, But i grew up on PERL... in fact i think there is a way for me to just exec another perl script (instead of include)... but i forget at the moment
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

If you haven't already I would suggest looking at the new perl API for some of this functionality as well as the new (1.22.0) version of zmtrigger.pl which might also be useful. This script does not invoke actions directly but is designed to communicate with other entities that do. However the API can be used directly in perl scripts of your choice and several of the included scripts (e.g zmtrack.pl) already use it.

Another thing that might be useful is looking at the contributed zmxap script which integrates ZM with the xAP control protocol. IJust search the forums for zmxap and you should find it.
Phil
Post Reply