2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-09 20:57:11 +00:00

49_SSCam: V8.11.3, fhem hang in loop while restart or get snapinfo Forum: #45671.msg915546.html#msg915546

git-svn-id: https://svn.fhem.de/fhem/trunk@18828 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2019-03-08 22:05:35 +00:00
parent f89ab08b06
commit b63a695195
2 changed files with 53 additions and 26 deletions

View File

@ -1,5 +1,7 @@
# 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.
- bugfix: 49_SSCam: V8.11.3, fhem hang in loop while restart or get snapinfo
Forum: #45671.msg915546.html#msg915546
- feature: mqtt2.template: A_00_MQTT2_CLIENT_general_bridge revised for better
compability with popular devices
- bugfix: 49_SSCam: back to V8.11.0 due to some problems with 8.11.2

View File

@ -36,17 +36,20 @@ package main;
use strict;
use warnings;
eval "use JSON qw( decode_json );1;" or my $SScamMMDBI = "JSON"; # Debian: apt-get install libjson-perl
eval "use JSON;1;" or my $SScamMMDBI = "JSON"; # Debian: apt-get install libjson-perl
use Data::Dumper; # Perl Core module
use MIME::Base64;
use Time::HiRes;
use HttpUtils;
use Blocking; # für EMail-Versand
use Encode;
use Encode;
# no if $] >= 5.017011, warnings => 'experimental';
# Versions History intern
our %SSCam_vNotesIntern = (
"8.11.3" => "08.03.2019 avoid possible JSON errors, fix fhem is hanging while restart or get snapinfo - Forum: #45671.msg915546.html#msg915546 ",
"8.11.2" => "04.03.2019 bugfix no snapinfos when snap was done by SVS itself, Forum: https://forum.fhem.de/index.php/topic,45671.msg914685.html#msg914685",
"8.11.1" => "28.02.2019 commandref revised, minor fixes ",
"8.11.0" => "25.02.2019 changed compatibility check, compatibility to SVS version 8.2.3, Popup possible for \"generic\"-Streamdevices, ".
"support for \"genericStrmHtmlTag\" in streaming devices ",
"8.10.1" => "19.02.2019 fix warning when starting fhem, and Forum:#97706",
@ -597,7 +600,7 @@ sub SSCam_Attr($$$$) {
$hash->{HELPER}{GETSNAPGALLERY} = 1;
$slim = AttrVal($name,"snapGalleryNumber",$SSCam_slim); # Anzahl der abzurufenden Snaps
$ssize = $do;
RemoveInternalTimer("SSCam_getsnapinfo");
RemoveInternalTimer($hash, "SSCam_getsnapinfo");
InternalTimer(gettimeofday()+0.7, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
}
}
@ -622,7 +625,7 @@ sub SSCam_Attr($$$$) {
$slim = AttrVal($name,"snapGalleryNumber",$SSCam_slim); # Anzahl der abzurufenden Snaps
my $sg = AttrVal($name,"snapGallerySize","Icon"); # Auflösung Image
$ssize = ($sg eq "Icon")?1:2;
RemoveInternalTimer("SSCam_getsnapinfo");
RemoveInternalTimer($hash, "SSCam_getsnapinfo");
InternalTimer(gettimeofday()+0.7, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
}
}
@ -643,7 +646,7 @@ sub SSCam_Attr($$$$) {
$hash->{HELPER}{GETSNAPGALLERY} = 1;
my $sg = AttrVal($name,"snapGallerySize","Icon"); # Auflösung Image
$ssize = ($sg eq "Icon")?1:2;
RemoveInternalTimer("SSCam_getsnapinfo");
RemoveInternalTimer($hash, "SSCam_getsnapinfo");
InternalTimer(gettimeofday()+0.7, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
}
@ -1539,9 +1542,9 @@ sub SSCam_Get($@) {
}
} elsif ($opt eq "snapinfo" && SSCam_IsModelCam($hash)) {
# Schnappschußgalerie abrufen (snapGalleryBoost) oder nur Info des letzten Snaps
# Schnappschußgalerie abrufen oder nur Info des letzten Snaps
if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
my ($slim,$ssize) = SSCam_snaplimsize($hash);
my ($slim,$ssize) = SSCam_snaplimsize($hash,1); # Force-Bit, es wird $hash->{HELPER}{GETSNAPGALLERY} gesetzt !
SSCam_getsnapinfo("$name:$slim:$ssize");
} elsif ($opt eq "snapfileinfo" && SSCam_IsModelCam($hash)) {
@ -1875,9 +1878,9 @@ sub SSCam_initonboot ($) {
SSCam_getptzlistpreset($hash);
SSCam_getptzlistpatrol($hash);
# Schnappschußgalerie abrufen (snapGalleryBoost) oder nur Info des letzten Snaps
my ($slim,$ssize) = SSCam_snaplimsize($hash);
RemoveInternalTimer("SSCam_getsnapinfo");
# Schnappschußgalerie abrufen oder nur Info des letzten Snaps
my ($slim,$ssize) = SSCam_snaplimsize($hash,1); # Force-Bit, es wird $hash->{HELPER}{GETSNAPGALLERY} erzwungen !
RemoveInternalTimer($hash, "SSCam_getsnapinfo");
InternalTimer(gettimeofday()+0.9, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
}
SSCam_versionCheck($hash); # Einstieg in regelmäßigen Check Kompatibilität
@ -3244,8 +3247,8 @@ sub SSCam_getcaminfoall ($$) {
InternalTimer(gettimeofday()+1.4, "SSCam_getstreamformat", $hash, 0);
# Schnappschußgalerie abrufen (snapGalleryBoost) oder nur Info des letzten Snaps
my ($slim,$ssize) = SSCam_snaplimsize($hash);
RemoveInternalTimer("SSCam_getsnapinfo");
my ($slim,$ssize) = SSCam_snaplimsize($hash,1); # Force-Bit, es wird $hash->{HELPER}{GETSNAPGALLERY} erzwungen !
RemoveInternalTimer($hash, "SSCam_getsnapinfo");
InternalTimer(gettimeofday()+1.5, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
RemoveInternalTimer($hash, "SSCam_getptzlistpreset");
@ -3292,6 +3295,10 @@ return;
###########################################################################
# Infos zu Snaps abfragen (z.B. weil nicht über SSCam ausgelöst)
#
# $slim = Anzahl der abzurufenden Snapinfos (snaps)
# $ssize = Snapgröße
# $tac = Transaktionscode (für gemeinsamen Versand)
###########################################################################
sub SSCam_getsnapinfo ($) {
my ($str) = @_;
@ -3302,7 +3309,7 @@ sub SSCam_getsnapinfo ($) {
$tac = (defined $tac)?$tac:5000;
my $ta = $hash->{HELPER}{TRANSACTION};
RemoveInternalTimer("SSCam_getsnapinfo");
RemoveInternalTimer($hash, "SSCam_getsnapinfo");
return if(IsDisabled($name));
if ($hash->{HELPER}{ACTIVE} eq "off" || ((defined $ta) && $ta == $tac)) {
@ -4455,9 +4462,11 @@ sub SSCam_camop ($) {
my $keyword = $hash->{HELPER}{KEYWORD};
my $snapid = ReadingsVal("$name", "LastSnapId", " ");
if($OpMode eq "getsnapinfo" && $snapid =~/\d+/) {
# getsnapinfo UND Reading LastSnapId gesetzt
Log3($name,4, "$name - Call getsnapinfo with params: Image numbers => $limit, Image size => $imgsize, Id => $snapid");
$url = "$proto://$serveraddr:$serverport/webapi/$apitakesnappath?api=\"$apitakesnap\"&method=\"List\"&version=\"$apitakesnapmaxver\"&idList=\"$snapid\"&imgSize=\"$imgsize\"&limit=\"$limit\"&_sid=\"$sid\"";
} else {
# snapgallery oder kein Reading LastSnapId gesetzt
Log3($name,4, "$name - Call getsnapinfo with params: Image numbers => $limit, Image size => $imgsize, Keyword => $keyword");
$url = "$proto://$serveraddr:$serverport/webapi/$apitakesnappath?api=\"$apitakesnap\"&method=\"List\"&version=\"$apitakesnapmaxver\"&keyword=\"$keyword\"&imgSize=\"$imgsize\"&limit=\"$limit\"&_sid=\"$sid\"";
}
@ -5213,7 +5222,7 @@ sub SSCam_camop_parse ($) {
SSCam_delActiveToken($hash);
}
RemoveInternalTimer("SSCam_getsnapinfo");
RemoveInternalTimer($hash, "SSCam_getsnapinfo");
InternalTimer(gettimeofday()+0.6, "SSCam_getsnapinfo", "$name:$slim:$ssize:$tac", 0);
return;
@ -5227,9 +5236,9 @@ sub SSCam_camop_parse ($) {
my %snaps = ( 0 => {'createdTm' => 'n.a.', 'fileName' => 'n.a.','snapid' => 'n.a.'} ); # Hilfshash
my ($k,$l) = (0,0);
if(exists($data->{data}{data}[0]{createdTm})) {
if($data->{'data'}{'data'}[0]{'createdTm'}) {
while ($data->{'data'}{'data'}[$k]) {
if($data->{'data'}{'data'}[$k]{'camName'} ne $camname) {
if(!$data->{'data'}{'data'}[$k]{'camName'} || $data->{'data'}{'data'}[$k]{'camName'} ne $camname) { # Forum:#97706
$k += 1;
next;
}
@ -5285,7 +5294,7 @@ sub SSCam_camop_parse ($) {
my %sendsnaps = (); # Schnappschuss Hash zum Versand wird leer erstellt
while ($data->{'data'}{'data'}[$i]) {
if($data->{'data'}{'data'}[$i]{'camName'} ne $camname) {
if(!$data->{'data'}{'data'}[$i]{'camName'} || $data->{'data'}{'data'}[$i]{'camName'} ne $camname) { # Forum:#97706
$i += 1;
next;
}
@ -5333,11 +5342,10 @@ sub SSCam_camop_parse ($) {
$hash->{HELPER}{TOTALCNT} = $data->{data}{total}; # total Anzahl Schnappschüsse
while ($data->{'data'}{'data'}[$i]) {
next if(!$data->{'data'}{'data'}[$i]{'camName'}); # Forum:#97706
if($data->{'data'}{'data'}[$i]{'camName'} ne $camname) {
$i += 1;
next;
}
if(!$data->{'data'}{'data'}[$i]{'camName'} || $data->{'data'}{'data'}[$i]{'camName'} ne $camname) { # Forum:#97706
$i += 1;
next;
}
$snapid = $data->{data}{data}[$i]{id};
my $createdTm = $data->{data}{data}[$i]{createdTm};
my $fileName = $data->{data}{data}[$i]{fileName};
@ -6612,9 +6620,12 @@ return $bool;
###############################################################################
# Ermittlung Anzahl und Größe der abzurufenden Schnappschußdaten
#
# $force = wenn auf jeden Fall der/die letzten Snaps von der SVS
# abgerufen werden sollen unabhängig ob LastSnapId vorhanden ist
###############################################################################
sub SSCam_snaplimsize ($) {
my ($hash)= @_;
sub SSCam_snaplimsize ($;$) {
my ($hash,$force) = @_;
my $name = $hash->{NAME};
my ($slim,$ssize);
@ -6647,6 +6658,8 @@ sub SSCam_snaplimsize ($) {
Log3($name, 4, "$name - Streaming devs of type \"lastsnap\": @strmdevs");
}
$hash->{HELPER}{GETSNAPGALLERY} = 1 if($force); # Bugfix 04.03.2019 Forum:https://forum.fhem.de/index.php/topic,45671.msg914685.html#msg914685
return ($slim,$ssize);
}
@ -8176,8 +8189,8 @@ sub SSCam_TBotSendIt($$$$$$$;$$$) {
# add parseMode
$ret = SSCam_TBotAddMultipart($hash, $fname, $hash->{HU_DO_PARAMS}, "parse_mode", undef, $parseMode, 0) if((!defined($ret)) && ($parseMode));
# add disable_web_page_preview
$ret = SSCam_TBotAddMultipart($hash, $fname, $hash->{HU_DO_PARAMS}, "disable_web_page_preview", undef, JSON::true, 0)
# add disable_web_page_preview
$ret = SSCam_TBotAddMultipart($hash, $fname, $hash->{HU_DO_PARAMS}, "disable_web_page_preview", undef, \1, 0)
if ((!defined($ret))&&(!AttrVal($name,'webPagePreview',1)));
}
@ -8814,6 +8827,8 @@ return ($str);
# Hint Hash EN
#############################################################################################
%SSCam_vHintsExt_en = (
"8" => "Link to official <a href=\"https://community.synology.com/forum/3\">Surveillance Forum</a> in Synology community".
"<br><br>",
"7" => "<b>Setup Email Shipping <br>".
"==================== </b> <br><br>".
"Snapshots can be sent by <b>Email</b> alltogether after creation. For this purpose the module contains<br>".
@ -8872,6 +8887,8 @@ return ($str);
# Hint Hash DE
#############################################################################################
%SSCam_vHintsExt_de = (
"8" => "Link zur offiziellen <a href=\"https://community.synology.com/forum/3\">Surveillance Forum</a> Seite innerhalb der Synology Community".
"<br><br>",
"7" => "<b>Einstellung Email-Versand <br>".
"========================= </b> <br><br>".
"Schnappschüsse können nach der Erstellung per <b>Email</b> gemeinsam versendet werden. Dazu enthält das Modul einen<br>".
@ -9722,6 +9739,10 @@ attr &lt;name&gt; genericStrmHtmlTag &lt;img $HTMLATTR
The video format of the camera has to be set to H.264 in the Synology Surveillance Station and not every camera type is
a proper device for HLS-Streaming.
At the time only the Mac Safari Browser and modern mobile iOS/Android-Devices are able to playback HLS-Streams.
<br><br>
<b>Note for MJPEG:</b> <br>
The MJPEG stream is SVS internal transcoded from other codec and is usally only about 1 fps.
</ul>
<br><br>
@ -11479,6 +11500,10 @@ attr &lt;name&gt; genericStrmHtmlTag &lt;img $HTMLATTR
Die Kamera muss in der SVS auf das Videoformat H.264 eingestellt sein und nicht jeder Kameratyp ist gleichermassen für
HLS-Streaming geeignet.
Momentan kann HLS nur durch den Mac Safari Browser sowie auf mobilen iOS/Android-Geräten wiedergegeben werden.
<br><br>
<b>Hinweis zu MJPEG:</b> <br>
Der MJPEG Stream wird innerhalb der SVS aus anderen Codecs (H.264) transkodiert und beträgt normalerweise ca. 1 Fps.
</ul>
<br><br>