2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

74_UnifiVideo.pm: handle changed log format (starting with 3.10.4 ?)

git-svn-id: https://svn.fhem.de/fhem/trunk@19679 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
justme-1968 2019-06-21 14:14:29 +00:00
parent 3d33fef49c
commit 0393185b95

View File

@ -385,13 +385,23 @@ UnifiVideo_Read($)
my $line;
($line,$data) = split("\n", $data, 2);
my($cam, $type);
if( $line =~ m/password/ ) {
UnifiVideo_killLogWatcher($hash);
} elsif( $line =~ m/Camera\[([^\]]+)\].*type:([^\s]+)/ ) {
my $cam = $1;
my $type = $2;
$cam = $1;
$type = $2;
} elsif( $line =~ m/AnalyticsService[^[]+\[([^|]+).*type:([^\s]+)/ ) {
$cam = $1;
$type = $2;
} else {
Log3 $name, 2, "$name: got unknown event: $line";
}
if( $cam && $type ) {
if( $type eq 'start' ) {
my $json = $hash->{helper}{json};
$json = [] if( !$json );
@ -399,22 +409,20 @@ UnifiVideo_Read($)
foreach my $entry (@{$json->{data}}) {
last if( $entry->{mac} eq $cam );
++$i;
}
if( $i >= $json->{meta}{totalCount} ) {
Log3 $name, 2, "$name: got motion event for unknown cam: $cam";
}
if( $i >= $json->{meta}{totalCount} ) {
Log3 $name, 2, "$name: got motion event for unknown cam: $cam";
} else {
readingsSingleUpdate($hash, "cam${i}motion", $type, 1);
}
} elsif( $type eq 'stop' ) {
} else {
Log3 $name, 2, "$name: got unknown event type from cam: $cam";
readingsSingleUpdate($hash, "cam${i}motion", $type, 1);
}
} else {
Log3 $name, 2, "$name: got unknown event: $line";
} elsif( $type eq 'stop' ) {
} else {
Log3 $name, 2, "$name: got unknown event type from cam: $cam";
}
}
}
$hash->{PARTIAL} = $data