mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
70_ZoneMinder: added cause and notes to alerts. Credits to Obi
git-svn-id: https://svn.fhem.de/fhem/trunk@20028 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
0e0fb447c8
commit
df5f411873
@ -1,5 +1,6 @@
|
||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
||||
# Do not insert empty lines here, update check depends on it.
|
||||
- feature: 70_ZoneMinder: added cause and notes to alerts. Credits to Obi
|
||||
- bugfix: 73_NUKIBridge: fix "Can't use stringas a HASH ref while strict
|
||||
refs in use"
|
||||
- change: 88_HMCCU: New features and bug fixes
|
||||
|
@ -329,15 +329,13 @@ sub ZoneMinder_GetConfigValueByKey {
|
||||
|
||||
sub ZoneMinder_GetConfigArrayByKey {
|
||||
my ($hash, $config, $key) = @_;
|
||||
# my $searchString = '"'.$key.'":[';
|
||||
my $searchString = qr/"$key":\s*\[/;
|
||||
my $searchString = qr/"$key":\s*\[/;
|
||||
return ZoneMinder_GetFromJson($hash, $config, $searchString, ']');
|
||||
}
|
||||
|
||||
sub ZoneMinder_GetConfigValueByName {
|
||||
my ($hash, $config, $key) = @_;
|
||||
# my $searchString = '"Name":"'.$key.'","Value":"';
|
||||
my $searchString = qr/"Name":"$key","Value":"/;
|
||||
my $searchString = qr/"Name":"$key","Value":"/;
|
||||
return ZoneMinder_GetFromJson($hash, $config, $searchString, '"');
|
||||
}
|
||||
|
||||
@ -345,18 +343,14 @@ sub ZoneMinder_GetFromJson {
|
||||
my ($hash, $config, $searchString, $endChar) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
# Log3 $name, 5, "json: $config";
|
||||
# my $searchLength = length($searchString);
|
||||
my $searchLength;
|
||||
my $prema;
|
||||
|
||||
# my $startIdx = index($config, $searchString);
|
||||
my $startIdx;
|
||||
if (my ($match) = $config =~ $searchString) {
|
||||
if ( my ($match) = $config =~ $searchString ) {
|
||||
$prema = $';
|
||||
my $ma = $&;
|
||||
my $poma = $`;
|
||||
# Log3 $name, 1, "ZM_TEST prematch: $prema match: $ma postmatch: $poma startIdx: $startIdx";
|
||||
$searchLength = length($ma);
|
||||
} else {
|
||||
Log3 $name, 1, "ZoneMinder ($name) - $searchString NOT found. Please report, this is a problem.";
|
||||
@ -369,8 +363,6 @@ sub ZoneMinder_GetFromJson {
|
||||
my $endIdx = index($searchResult, $endChar);
|
||||
$searchResult = substr $searchResult, 0, $endIdx;
|
||||
|
||||
# Log3 $name, 5, "ZoneMinder ($name) - looking for $searchString - length: $searchLength. start: $startIdx. end: $endIdx. result: $searchResult";
|
||||
|
||||
return $searchResult;
|
||||
}
|
||||
|
||||
@ -463,8 +455,11 @@ sub ZoneMinder_Write {
|
||||
|
||||
my $zmMonitorId = $arguments->{zmMonitorId};
|
||||
my $zmAlarm = $arguments->{zmAlarm};
|
||||
Log3 $name, 4, "ZoneMinder ($name) method: $method, monitorId:$zmMonitorId, Alarm:$zmAlarm";
|
||||
return ZoneMinder_Trigger_ChangeAlarmState($hash, $zmMonitorId, $zmAlarm);
|
||||
my $zmCause = $arguments->{zmCause};
|
||||
my $zmNotes = $arguments->{zmNotes};
|
||||
|
||||
Log3 $name, 4, "ZoneMinder ($name) method: $method, monitorId:$zmMonitorId, Alarm:$zmAlarm , Cause:$zmCause, Notes:$zmNotes";
|
||||
return ZoneMinder_Trigger_ChangeAlarmState($hash, $zmMonitorId, $zmAlarm, $zmCause, $zmNotes);
|
||||
|
||||
} elsif ($method eq 'changeMonitorText') {
|
||||
|
||||
@ -580,17 +575,17 @@ sub ZoneMinder_API_QueryEventDetails_Callback {
|
||||
|
||||
|
||||
sub ZoneMinder_Trigger_ChangeAlarmState {
|
||||
my ( $hash, $zmMonitorId, $zmAlarm ) = @_;
|
||||
my ( $hash, $zmMonitorId, $zmAlarm, $zmCause, $zmNotes ) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
|
||||
my $msg = "$zmMonitorId|";
|
||||
if ( 'on' eq $zmAlarm ) {
|
||||
DevIo_SimpleWrite( $hash, $msg.'on|1|fhem', 2 );
|
||||
DevIo_SimpleWrite( $hash, $msg.'on|1|'.$zmCause.'|'.$zmNotes, 2 );
|
||||
} elsif ( 'off' eq $zmAlarm ) {
|
||||
DevIo_SimpleWrite( $hash, $msg.'off|1|fhem', 2);
|
||||
DevIo_SimpleWrite( $hash, $msg.'off|1|'.$zmCause.'|'.$zmNotes, 2);
|
||||
} elsif ( $zmAlarm =~ /^on\-for\-timer/ ) {
|
||||
my $duration = $zmAlarm =~ s/on\-for\-timer\ /on\ /r;
|
||||
DevIo_SimpleWrite( $hash, $msg.$duration.'|1|fhem', 2);
|
||||
DevIo_SimpleWrite( $hash, $msg.$duration.'|1|'.$zmCause.'|'.$zmNotes, 2);
|
||||
}
|
||||
|
||||
return undef;
|
||||
|
@ -220,10 +220,23 @@ sub ZM_Monitor_Set {
|
||||
if (grep { $_ eq $arg } @ZM_Alarms) {
|
||||
|
||||
$arg .= ' '.$args[1] if ( 'on-for-timer' eq $arg );
|
||||
|
||||
my ( $unnamedParams, $namedParams ) = parseParams(join(' ', @args));
|
||||
my $cause = 'fhem';
|
||||
my $notes = '';
|
||||
if( defined($namedParams->{'cause'}) ) {
|
||||
$cause = $namedParams->{'cause'};
|
||||
}
|
||||
if( defined($namedParams->{'notes'}) ) {
|
||||
$notes = $namedParams->{'notes'};
|
||||
}
|
||||
|
||||
my $arguments = {
|
||||
method => 'changeMonitorAlarm',
|
||||
zmMonitorId => $hash->{helper}{ZM_MONITOR_ID},
|
||||
zmAlarm => $arg
|
||||
zmAlarm => $arg,
|
||||
zmCause => $cause,
|
||||
zmNotes => $notes
|
||||
};
|
||||
my $result = IOWrite($hash, $arguments);
|
||||
return $result;
|
||||
@ -502,7 +515,7 @@ sub ZM_Monitor_Notify {
|
||||
<a name="ZM_Monitorset"></a>
|
||||
<b>Set</b>
|
||||
<ul>
|
||||
<li><code>alarmState</code><br>Puts a monitor into alarm state or out of alarm state via the ZoneMinder trigger port.</li>
|
||||
<li><code>alarmState</code><br>Puts a monitor into alarm state or out of alarm state via the ZoneMinder trigger port. Can also take one or both of <code>cause="xxx" notes="xxx"</code> parameters</li>
|
||||
<li><code>monitorFunction</code><br>Sets the operating mode of a Monitor in ZoneMinder via the ZoneMinder API.</li>
|
||||
<li><code>motionDetectionEnabled</code><br>Enables or disables monitor detection of a monitor via ZoneMinder API.</li>
|
||||
<li><code>text</code><br/>Allows you to set a text for a Timestamp's <code>%Q</code> portion in ZoneMinder via the ZoneMinder trigger port.</li>
|
||||
|
Loading…
Reference in New Issue
Block a user