2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-05 08:20:23 +00:00

49_SSCam(STRM): avoid possible warnings during FHEM shutdown/restart

git-svn-id: https://svn.fhem.de/fhem/trunk@22598 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2020-08-14 14:09:14 +00:00
parent ef37fa8e56
commit 0973043db9
5 changed files with 243 additions and 110 deletions

View File

@ -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.
- bugfix: 49_SSCam(STRM): avoid possible warnings during shutdown/restart
- bugfix: 52_I2C_HDC1008: fix "temperature" (broken by change from Aug, 1st)
- feature: 49_SSCam: new attribute ptzNoCapPrePat
- feature: 60_Watches: control buttons,new attr hideButtons, controlButtonSize

View File

@ -159,6 +159,7 @@ BEGIN {
# Versions History intern
my %vNotesIntern = (
"9.6.1" => "13.08.2020 avoid warnings during FHEM shutdown/restart ",
"9.6.0" => "12.08.2020 new attribute ptzNoCapPrePat ",
"9.5.3" => "27.07.2020 fix warning: Use of uninitialized value in subroutine dereference at ... ",
"9.5.2" => "26.07.2020 more changes according PBP level 3, minor fixes ",
@ -472,11 +473,6 @@ my $valZoom = ".++,+,stop,-,--."; # Inhalt des Setters "
#use vars qw($FW_room); # currently selected room
#use vars qw($FW_detail); # currently selected device for detail view
#use vars qw($FW_wname); # Web instance
# sub FW_pH(@); # add href
#sub SSChatBot_formString;
#sub SSChatBot_addQueue($$$$$$$$);
#sub SSChatBot_getapisites($);
#############################################################################################
# Hint Hash EN
@ -799,15 +795,13 @@ sub delayedShutdown {
my $name = $hash->{NAME};
Log3($name, 2, "$name - Quit session due to shutdown ...");
$hash->{HELPER}{ACTIVE} = "on"; # keine weiteren Aktionen erlauben
logout($hash);
sessionOff($hash);
if($hash->{HELPER}{CACHEKEY}) {
cache($name, "c_destroy");
}
delete $data{SSCam}{$name}; # internen cache löschen
return 1;
}
@ -834,6 +828,8 @@ sub Delete {
CommandDelete($hash->{CL},"TYPE=SSCamSTRM:FILTER=PARENT=$name"); # alle zugeordneten Streaming-Devices löschen falls vorhanden
delete $data{SSCam}{$name}; # internen Cache löschen
return;
}
@ -4109,7 +4105,7 @@ return;
# Session logout
###########################################################################
sub sessionOff {
my ($hash) = @_;
my $hash = shift;
my $camname = $hash->{CAMNAME};
my $name = $hash->{NAME};
@ -8235,16 +8231,15 @@ return $ret;
# Streaming Device Typ: mjpeg
sub _streamDevMJPEG { ## no critic 'complexity not used'
my $params = shift;
my $camname = $params->{camname};
my $strmdev = $params->{strmdev};
my $hash = $defs{$camname};
my $streamHash = $defs{$strmdev};
my $camid = $params->{camid} // return "";
my $sid = $params->{sid} // return "";
my $ftui = $params->{ftui};
my $camid = $params->{camid};
my $proto = $params->{proto};
my $sid = $params->{sid};
my $pws = $params->{pws};
my $ha = $params->{ha};
my $hb = $params->{hb};

View File

@ -91,6 +91,7 @@ BEGIN {
# Versions History intern
my %vNotesIntern = (
"2.14.5" => "12.08.2020 avoid loose of adoption after restart ",
"2.14.4" => "03.08.2020 fix check of ARG in RemoveInternalTimer in _setadoptForTimer sub (sometimes no switch back done) ",
"2.14.3" => "01.08.2020 verbose 5 log in _setadoptForTimer sub ",
"2.14.2" => "29.07.2020 fix: adoptTime accept not only integer values ",
@ -624,7 +625,7 @@ sub FwFn {
my $clink = ReadingsVal($name, "clientLink", "");
sofAdoptSubset ($hash);
explodeLinkData ($hash, $clink, 0);
explodeLinkData ($hash, $clink, 0) if($init_done == 1);
# Beispielsyntax: "{$hash->{LINKFN}('$hash->{LINKPARENT}','$hash->{LINKNAME}','$hash->{LINKMODEL}')}";

View File

@ -1,5 +1,5 @@
########################################################################################################################
# $Id: 49_SSCam.pm 22481 2020-07-27 21:56:22Z DS_Starter $
# $Id: 49_SSCam.pm 22592 2020-08-12 21:28:56Z DS_Starter $
#########################################################################################################################
# 49_SSCam.pm
#
@ -159,7 +159,8 @@ BEGIN {
# Versions History intern
my %vNotesIntern = (
"9.6.0" => "11.08.2020 new attribute ptzNoCapPrePat ",
"9.6.1" => "13.08.2020 avoid warnings during FHEM shutdown/restart ",
"9.6.0" => "12.08.2020 new attribute ptzNoCapPrePat ",
"9.5.3" => "27.07.2020 fix warning: Use of uninitialized value in subroutine dereference at ... ",
"9.5.2" => "26.07.2020 more changes according PBP level 3, minor fixes ",
"9.5.1" => "24.07.2020 set compatibility to 8.2.8, some changes according PBP level 3 ",
@ -212,6 +213,8 @@ my %vNotesIntern = (
# Versions History extern
my %vNotesExtern = (
"9.6.0" => "12.08.2020 The new attribute 'ptzNoCapPrePat' is available. It's helpfull if your PTZ camera doesn't have the capability ".
"to deliver Presets and Patrols. Setting the attribute avoid error log messages in that case. ",
"9.5.0" => "15.07.2020 A new type 'master' supplements the possible createStreamDev command options. The streaming type ".
"'master' cannot play back streams itself, but opens up new possibilities by flexibly accepting streams from ".
"other defined streaming devices. ".
@ -470,11 +473,6 @@ my $valZoom = ".++,+,stop,-,--."; # Inhalt des Setters "
#use vars qw($FW_room); # currently selected room
#use vars qw($FW_detail); # currently selected device for detail view
#use vars qw($FW_wname); # Web instance
# sub FW_pH(@); # add href
#sub SSChatBot_formString;
#sub SSChatBot_addQueue($$$$$$$$);
#sub SSChatBot_getapisites($);
#############################################################################################
# Hint Hash EN
@ -797,15 +795,13 @@ sub delayedShutdown {
my $name = $hash->{NAME};
Log3($name, 2, "$name - Quit session due to shutdown ...");
$hash->{HELPER}{ACTIVE} = "on"; # keine weiteren Aktionen erlauben
logout($hash);
sessionOff($hash);
if($hash->{HELPER}{CACHEKEY}) {
cache($name, "c_destroy");
}
delete $data{SSCam}{$name}; # internen cache löschen
return 1;
}
@ -832,6 +828,8 @@ sub Delete {
CommandDelete($hash->{CL},"TYPE=SSCamSTRM:FILTER=PARENT=$name"); # alle zugeordneten Streaming-Devices löschen falls vorhanden
delete $data{SSCam}{$name}; # internen Cache löschen
return;
}
@ -4107,7 +4105,7 @@ return;
# Session logout
###########################################################################
sub sessionOff {
my ($hash) = @_;
my $hash = shift;
my $camname = $hash->{CAMNAME};
my $name = $hash->{NAME};
@ -8233,16 +8231,15 @@ return $ret;
# Streaming Device Typ: mjpeg
sub _streamDevMJPEG { ## no critic 'complexity not used'
my $params = shift;
my $camname = $params->{camname};
my $strmdev = $params->{strmdev};
my $hash = $defs{$camname};
my $streamHash = $defs{$strmdev};
my $camid = $params->{camid} // return "";
my $sid = $params->{sid} // return "";
my $ftui = $params->{ftui};
my $camid = $params->{camid};
my $proto = $params->{proto};
my $sid = $params->{sid};
my $pws = $params->{pws};
my $ha = $params->{ha};
my $hb = $params->{hb};
@ -11437,12 +11434,12 @@ sub setVersionInfo {
if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) {
# META-Daten sind vorhanden
$modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{SMAPortal}{META}}
if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id: 49_SSCam.pm 22481 2020-07-27 21:56:22Z DS_Starter $ im Kopf komplett! vorhanden )
if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id: 49_SSCam.pm 22592 2020-08-12 21:28:56Z DS_Starter $ im Kopf komplett! vorhanden )
$modules{$type}{META}{x_version} =~ s/1\.1\.1/$v/gx;
} else {
$modules{$type}{META}{x_version} = $v;
}
return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id: 49_SSCam.pm 22481 2020-07-27 21:56:22Z DS_Starter $ im Kopf komplett! vorhanden )
return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id: 49_SSCam.pm 22592 2020-08-12 21:28:56Z DS_Starter $ im Kopf komplett! vorhanden )
if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) {
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden

View File

@ -1,5 +1,5 @@
########################################################################################################################
# $Id: 49_SSCamSTRM.pm 22446 2020-07-20 21:16:31Z DS_Starter $
# $Id: 49_SSCamSTRM.pm 22534 2020-08-03 20:10:28Z DS_Starter $
#########################################################################################################################
# 49_SSCamSTRM.pm
#
@ -47,6 +47,7 @@ BEGIN {
defs
devspec2array
FmtDateTime
init_done
InternalTimer
IsDisabled
Log3
@ -90,6 +91,12 @@ BEGIN {
# Versions History intern
my %vNotesIntern = (
"2.14.5" => "12.08.2020 avoid loose of adoption after restart ",
"2.14.4" => "03.08.2020 fix check of ARG in RemoveInternalTimer in _setadoptForTimer sub (sometimes no switch back done) ",
"2.14.3" => "01.08.2020 verbose 5 log in _setadoptForTimer sub ",
"2.14.2" => "29.07.2020 fix: adoptTime accept not only integer values ",
"2.14.1" => "28.07.2020 switching time increases with each adoptForTimer command ",
"2.14.0" => "27.07.2020 new commands adoptForTimer and control command adoptTime ",
"2.13.1" => "21.07.2020 fix: set of values in attr adoptSubset is empty after restart, changes according level 3 PBP ",
"2.13.0" => "14.07.2020 integrate streamDev master ",
"2.12.0" => "28.06.2020 upgrade SSCam functions due to SSCam switch to packages ",
@ -156,6 +163,8 @@ my %hvattr = ( # Has
my %hset = ( # Hash für Set-Funktion
popupStream => { fn => "_setpopupStream" },
adopt => { fn => "_setadopt" },
adoptForTimer => { fn => "_setadoptForTimer" },
adoptTime => { fn => "_setAdoptTimer" },
reset => { fn => "_setreset" },
);
@ -309,7 +318,9 @@ sub Set {
setReadings($hash, \@ado, 0);
$setlist = "Unknown argument $opt, choose one of ".
"adopt:$sd "
"adopt:$sd ".
"adoptForTimer:$sd ".
"adoptTime "
;
}
@ -323,8 +334,9 @@ sub Set {
no strict "refs"; ## no critic 'NoStrict'
if($hset{$opt}) {
&{$hset{$opt}{fn}} (\%params) if(defined &{$hset{$opt}{fn}});
return;
my $ret = "";
$ret = &{$hset{$opt}{fn}} (\%params) if(defined &{$hset{$opt}{fn}});
return $ret;
}
use strict "refs";
@ -423,6 +435,84 @@ sub _setadopt { ## no critic "not used"
return;
}
###############################################################
# setter adopt-for-timer
# schaltet für eine bestimmte Zeit auf das ausgewählte
# Streaming Device und wieder auf das vorherige zurück
###############################################################
sub _setadoptForTimer { ## no critic "not used"
my $paref = shift;
my $hash = $paref->{hash};
my $name = $paref->{name};
my $opt = $paref->{opt};
my $odev = $paref->{odev}; # bisheriges adoptiertes Device (wird erst im InternalTimer gesetzt und verwendet)
return if(IsDisabled($name) || $init_done != 1);
my $sdev;
my $atime = ReadingsVal($name, "adoptTimer", 10);
if(!$odev) { # Step 1 -> erster Durchlauf ohne odef
$hash->{HELPER}{SWITCHED} = $hash->{LINKNAME} if(!$hash->{HELPER}{SWITCHED});
$paref->{odev} = $hash->{HELPER}{SWITCHED}; # bisheriges adoptiertes Device in %params aufnehmen, InternalTimer mitgeben
} else { # Step 2 -> zweiter Durchlauf mit odef gesetzt
my @a;
delete $hash->{HELPER}{SWITCHED};
$sdev = $odev eq $name ? "--reset--" : $odev;
push @a, $name;
push @a, $opt;
push @a, $sdev;
$paref->{aref} = \@a;
}
no strict "refs"; ## no critic 'NoStrict'
&{$hset{adopt}{fn}} ($paref);
use strict "refs";
Log3($name, 5, "$name - new => $hash->{LINKNAME}, odev => ".($odev // "")." , sdev => ".($sdev // "")." ,Helper SWITCHED => ".($hash->{HELPER}{SWITCHED} // "").", switch time => $atime");
if($odev) {
Log3($name, 4, qq{$name - Switched Stream Device back to "$sdev"});
return;
}
Log3($name, 4, qq{$name - Switched to Stream Device "$hash->{LINKNAME}" for $atime seconds});
RemoveInternalTimer($hash->{HELPER}{ARG}, "FHEM::SSCamSTRM::_setadoptForTimer");
$hash->{HELPER}{ARG} = $paref; # $paref ist Unikat !
InternalTimer(gettimeofday()+$atime, "FHEM::SSCamSTRM::_setadoptForTimer", $paref, 0);
return;
}
################################################################
# Setter adoptTimer
# setzt die Schaltzeit für setter adoptForTimer
################################################################
sub _setAdoptTimer { ## no critic "not used"
my $paref = shift;
my $hash = $paref->{hash};
my $opt = $paref->{opt};
my $prop = $paref->{prop} // 0;
my $ret = "";
$ret = qq{The command "$opt" needs an integer as argument.} if($prop !~ /^[0-9]+?$/x);
return $ret if($ret);
delReadings ($hash, "adoptTimer");
if($prop) { # bei "0" wird das Reading nur gelöscht, nicht wieder gesetzt
my @r;
push @r, "adoptTimer:$prop";
setReadings($hash, \@r, 0);
}
return;
}
################################################################
# Setter reset
@ -535,7 +625,7 @@ sub FwFn {
my $clink = ReadingsVal($name, "clientLink", "");
sofAdoptSubset ($hash);
explodeLinkData ($hash, $clink, 0);
explodeLinkData ($hash, $clink, 0) if($init_done == 1);
# Beispielsyntax: "{$hash->{LINKFN}('$hash->{LINKPARENT}','$hash->{LINKNAME}','$hash->{LINKMODEL}')}";
@ -667,12 +757,12 @@ sub setVersionInfo {
if($modules{$type}{META}{x_prereqs_src} && !$hash->{HELPER}{MODMETAABSENT}) {
# META-Daten sind vorhanden
$modules{$type}{META}{version} = "v".$v; # Version aus META.json überschreiben, Anzeige mit {Dumper $modules{SSCamSTRM}{META}}
if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id: 49_SSCamSTRM.pm 22446 2020-07-20 21:16:31Z DS_Starter $ im Kopf komplett! vorhanden )
if($modules{$type}{META}{x_version}) { # {x_version} ( nur gesetzt wenn $Id: 49_SSCamSTRM.pm 22534 2020-08-03 20:10:28Z DS_Starter $ im Kopf komplett! vorhanden )
$modules{$type}{META}{x_version} =~ s/1\.1\.1/$v/gx;
} else {
$modules{$type}{META}{x_version} = $v;
}
return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id: 49_SSCamSTRM.pm 22446 2020-07-20 21:16:31Z DS_Starter $ im Kopf komplett! vorhanden )
return $@ unless (FHEM::Meta::SetInternals($hash)); # FVERSION wird gesetzt ( nur gesetzt wenn $Id: 49_SSCamSTRM.pm 22534 2020-08-03 20:10:28Z DS_Starter $ im Kopf komplett! vorhanden )
if(__PACKAGE__ eq "FHEM::$type" || __PACKAGE__ eq $type) {
# es wird mit Packages gearbeitet -> Perl übliche Modulversion setzen
# mit {<Modul>->VERSION()} im FHEMWEB kann Modulversion abgefragt werden
@ -736,29 +826,6 @@ sub streamAsHtml {
return $ret;
}
################################################################
# delete Readings
# $rd = angegebenes Reading löschen
################################################################
sub delReadings {
my $hash = shift;
my $rd = shift;
my $name = $hash->{NAME};
my $bl = "state|parentState|adoptSubset"; # Blacklist
if($rd) { # angegebenes Reading löschen wenn nicht im providerLevel enthalten
readingsDelete($hash, $rd) if($rd !~ /$bl/x);
return;
}
for my $key (keys %{$hash->{READINGS}}) {
readingsDelete($hash, $key) if($key !~ /$bl/x);
}
return;
}
################################################################
# Wertevorrat für adoptSubset generieren
################################################################
@ -806,6 +873,30 @@ sub setReadings {
return;
}
################################################################
# delete Readings
# $rd = angegebenes Reading löschen unabhängig vom
# Inhalt der Blacklist
################################################################
sub delReadings {
my $hash = shift;
my $rd = shift;
my $name = $hash->{NAME};
my $bl = "state|parentState|adoptSubset|adoptTimer"; # Blacklist
if($rd) { # angegebenes Reading löschen
readingsDelete($hash, $rd);
return;
}
for my $key (keys %{$hash->{READINGS}}) {
readingsDelete($hash, $key) if($key !~ /$bl/x);
}
return;
}
################################################################
# liefert String aller Streamingdevices außer MODEL = master
# und füllt Hash %sdevs{Alias} = Devicename zu Auflösung
@ -941,6 +1032,38 @@ return $ret;
<b>Set</b>
<ul>
<ul>
<a name="adopt"></a>
<li><b>adopt &lt;Streaming device&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(only valid if MODEL = master)<br>
A Streaming Device of type <b>master</b> adopts the content of another defined Streaming Device.
</li>
</ul>
<br>
<ul>
<a name="adoptForTimer"></a>
<li><b>adoptForTimer &lt;Streaming Device&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(only valid if MODEL = master)<br>
A Streaming Device of type <b>master</b> adopts the content of another defined Streaming Device
for a certain time. <br>
The time is set with the command <b>set &lt;name&gt; adoptTime</b>. <br>
(default: 10 seconds)
</li>
</ul>
<br>
<ul>
<a name="adoptTime"></a>
<li><b>adoptTime &lt;seconds&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(only valid if MODEL = master)<br>
Setting of the switching time when temporarily taking over the content of another Streaming Device.
After the time has expired, playback is switched back to the previously set Streaming Device. <br>
If no argument or "0" is given, the time specification is deleted and the default (10 seconds) is used.
</li>
</ul>
<br>
<ul>
<li><b>popupStream</b> &nbsp;&nbsp;&nbsp;&nbsp;(only valid if MODEL != master)<br>
@ -953,14 +1076,6 @@ return $ret;
</ul>
<br>
<ul>
<li><b>adopt &lt;Streaming device&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(only valid if MODEL = master)<br>
A Streaming Device of type <b>master</b> adopts the content of another defined Streaming Device.
</li>
</ul>
<br>
</ul>
<br>
@ -1203,6 +1318,38 @@ attr &lt;name&gt; genericStrmHtmlTag &lt;img $HTMLATTR
<b>Set</b>
<ul>
<ul>
<a name="adopt"></a>
<li><b>adopt &lt;Streaming Device&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(nur wenn MODEL = master)<br>
Ein Streaming Device vom Type <b>master</b> übernimmt (adoptiert) den Content eines anderen definierten Streaming Devices.
</li>
</ul>
<br>
<ul>
<a name="adoptForTimer"></a>
<li><b>adoptForTimer &lt;Streaming Device&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(nur wenn MODEL = master)<br>
Ein Streaming Device vom Type <b>master</b> übernimmt (adoptiert) den Content eines anderen definierten Streaming Devices
für eine bestimmte Zeit. <br>
Die Zeit wird mit dem Kommando <b>set &lt;name&gt; adoptTime</b> eingestellt. <br>
(default: 10 Sekunden)
</li>
</ul>
<br>
<ul>
<a name="adoptTime"></a>
<li><b>adoptTime &lt;Sekunden&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(nur wenn MODEL = master)<br>
Einstellung der Schaltzeit bei temporärer Übernahme des Contents eines anderen Streaming Devices.
Nach Ablauf der Zeit wird die Wiedergabe auf das vorher eingestellte Streaming Device zurückgeschaltet. <br>
Wird kein Argument oder "0" angegeben, wird die Zeitvorgabe gelöscht und der Standard (10 Sekunden) verwendet.
</li>
</ul>
<br>
<ul>
<li><b>popupStream [OK | &lt;Sekunden&gt;]</b> &nbsp;&nbsp;&nbsp;&nbsp;(nur wenn MODEL != master)<br>
@ -1216,14 +1363,6 @@ attr &lt;name&gt; genericStrmHtmlTag &lt;img $HTMLATTR
</ul>
<br>
<ul>
<li><b>adopt &lt;Streaming Device&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(nur wenn MODEL = master)<br>
Ein Streaming Device vom Type <b>master</b> übernimmt (adoptiert) den Content eines anderen definierten Streaming Devices.
</li>
</ul>
<br>
</ul>
<br>