strip leading and trailing " in trigger message. Accept a space instead of a + in enable/disable commands to match on/off

This commit is contained in:
Isaac Connor 2020-04-04 11:08:19 -04:00
parent 2441ae2924
commit 38555b0dd4
1 changed files with 9 additions and 4 deletions

View File

@ -356,11 +356,16 @@ sub handleMessage {
my $connection = shift;
my $message = shift;
# CUA - Axis camera send the message quoted with"
# CUA - Also Axis camera cannot save the plus sign which
$message =~ s/^\"//g;
$message =~ s/\"$//g;
my ( $id, $action, $score, $cause, $text, $showtext )
= split( /\|/, $message );
$score = 0 if ( !defined($score) );
$cause = '' if ( !defined($cause) );
$text = '' if ( !defined($text) );
$score = 0 if !defined($score);
$cause = '' if !defined($cause);
$text = '' if !defined($text);
my $monitor = $monitors{$id};
if ( !$monitor ) {
@ -372,7 +377,7 @@ sub handleMessage {
next if !zmMemVerify($monitor);
Debug("Handling action '$action'");
if ( $action =~ /^(enable|disable)(?:\+(\d+))?$/ ) {
if ( $action =~ /^(enable|disable)(?:[\+ ](\d+))?$/ ) {
my $state = $1;
my $delay = $2;
if ( $state eq 'enable' ) {