From 96f7cd7a4e3fabb68953db203cc68618d458c538 Mon Sep 17 00:00:00 2001 From: ovargasp Date: Fri, 5 Aug 2022 16:46:11 -0600 Subject: [PATCH] Latest version of zmAlarmServer --- .../lib/ZoneMinder/ConfigData.pm.in | 47 +++++++++++++++++++ scripts/zmalarm-server.py | 2 +- scripts/zmdc.pl.in | 3 +- scripts/zmpkg.pl.in | 24 ++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in index 6e3242894..3b975c5a2 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in +++ b/scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in @@ -3834,6 +3834,53 @@ our @options = ( type => $types{string}, category => 'config', }, +# Add options for Alarm Server + { + name => 'ZM_OPT_USE_ALARMSERVER', + default => 'no', + description => 'Enable NETSurveillance WEB Camera ALARM SERVER', + help => q` + Alarm Server that works with cameras that use Netsurveillance Web Server, + and has the Alarm Server option it receives alarms sent by this cameras + (once enabled), and pass to Zoneminder the events. + It requires pyzm installed, visit https://pyzm.readthedocs.io/en/latest/ + for installation instructions. + `, + type => $types{boolean}, + category => 'system', + }, + { + name => 'ZM_OPT_ALS_LOGENTRY', + default => 'no', + description => 'Makes ALARM SERVER create a log entry in ZoneMinder on Human Detected', + help => '', + type => $types{boolean}, + category => 'system', + }, + { + name => 'ZM_OPT_ALS_ALARM', + default => 'no', + description => 'Send the Human Detected alarm from ALARM SERVER to ZoneMinder, It does not work along with OPT_ALS_TRIGGEREVENT', + help => '', + type => $types{boolean}, + category => 'system', + }, + { + name => 'ZM_OPT_ALS_TRIGGEREVENT', + default => 'no', + description => 'Trigger an event on Human Detected alarm from ALARM SERVER to ZoneMinder. Requires the zmTrigger option Enabled', + help => '', + type => $types{boolean}, + category => 'system', + }, + { + name => 'ZM_OPT_ALS_PORT', + default => '15002', + description => 'Port Number to receive alarms from Alarm Server', + help => '', + type => $types{integer}, + category => 'system', + }, ); our %options_hash = map { ( $_->{name}, $_ ) } @options; diff --git a/scripts/zmalarm-server.py b/scripts/zmalarm-server.py index 891efba5a..4a3717cbe 100755 --- a/scripts/zmalarm-server.py +++ b/scripts/zmalarm-server.py @@ -108,7 +108,7 @@ if len(sys.argv) > 1: else: print('Usage: %s [--port|-p= --log|-l= --alarm|-a= --event|-e=]' % os.path.basename(sys.argv[0])) - sys.exit() + sys.exit(1) print ('Create log entry: ', wrzmlog) print ('Trigger event: ', wrzmlog) diff --git a/scripts/zmdc.pl.in b/scripts/zmdc.pl.in index 911ac57dc..c4e7bd1a6 100644 --- a/scripts/zmdc.pl.in +++ b/scripts/zmdc.pl.in @@ -102,7 +102,8 @@ my @daemons = ( 'zmtrack.pl', 'zmcontrol.pl', 'zm_rtsp_server', - 'zmtelemetry.pl' + 'zmtelemetry.pl', + 'zmalarm-server.py' ); if ( $Config{ZM_OPT_USE_EVENTNOTIFICATION} ) { diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index 08b36f536..651966bf9 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -288,6 +288,30 @@ if ( $command =~ /^(?:start|restart)$/ ) { if ( $Config{ZM_MIN_RTSP_PORT} ) { runCommand('zmdc.pl start zm_rtsp_server'); } + # run and pass parameters to AlarmServer.py + if ($Config{ZM_OPT_USE_ALARMSERVER} ) { + my $cmd='zmdc.pl start zmalarm-server.py '. $Config{ZM_OPT_ALS_PORT}; + if ($Config{ZM_OPT_ALS_LOGENTRY} ) { + $cmd = $cmd . ' --log=y'; + } + else { + $cmd = $cmd . ' --log=n'; + } + if ($Config{ZM_OPT_ALS_TRIGGEREVENT} ) { + $cmd = $cmd . ' --event=y'; + } + else { + $cmd = $cmd . ' --event=n'; + } + + if ($Config{ZM_OPT_ALS_ALARM} ) { + $cmd = $cmd . ' --alarm=y'; + } + else { + $cmd = $cmd . ' --alarm=n'; + } + runCommand($cmd); + } } else { $retval = 1; }