2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

49_SSCam: contrib 9.5.0

git-svn-id: https://svn.fhem.de/fhem/trunk@22430 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2020-07-19 11:53:46 +00:00
parent 44d6390e4b
commit deceace66e
2 changed files with 55 additions and 26 deletions

View File

@ -7477,24 +7477,22 @@ sub roomRefresh {
my @spgs = devspec2array("TYPE=SSCamSTRM"); # alle Streaming Devices !
my @mstd = devspec2array("TYPE=SSCamSTRM:FILTER=MODEL=master"); # alle Streaming MODEL=master Devices
my $room = "";
for my $sd (@spgs) {
if($defs{$sd}{LINKPARENT} eq $name) {
next if(IsDisabled($defs{$sd}{NAME}) || !$hash->{HELPER}{INFORM} || $hash->{HELPER}{INFORM} ne $defs{$sd}{FUUID});
$fpr = AttrVal($defs{$sd}{NAME},"forcePageRefresh",0);
$room = AttrVal($defs{$sd}{NAME},"room","");
Log3($name, 4, "$name - roomRefresh - pagerefresh: $defs{$sd}{NAME}") if($fpr);
Log3($name, 4, qq{$name - roomRefresh - pagerefresh forced by $defs{$sd}{NAME}}) if($fpr);
}
}
# Page-Reload
if($pload && $room) {
if(!$fpr) {
# nur Räume mit dem SSCamSTRM-Device reloaden
my @rooms = split(",",$room);
for my $r (@rooms) {
{ map { FW_directNotify("FILTER=room=$r", "#FHEMWEB:$_", "location.reload('true')", "") } devspec2array("TYPE=FHEMWEB") }
}
if($pload && $room && !$fpr) {
# nur Räume mit dem SSCamSTRM-Device reloaden
my @rooms = split(",",$room);
for my $r (@rooms) {
{ map { FW_directNotify("FILTER=room=$r", "#FHEMWEB:$_", "location.reload('true')", "") } devspec2array("TYPE=FHEMWEB") }
}
} elsif ($pload || $fpr) {
@ -7530,6 +7528,8 @@ sub roomRefresh {
readingsBulkUpdate ($defs{$sm},"parentState", $st);
readingsBulkUpdate ($defs{$sm},"state", "updated");
readingsEndUpdate ($defs{$sm}, 1);
Log3($name, 4, "$name - roomRefresh - caller: $sp, Master: $sm updated");
}
Log3($name, 4, "$name - roomRefresh - caller: $sp, FUUID: $hash->{HELPER}{INFORM}");
@ -7627,6 +7627,14 @@ sub IsCapPIR { # hat K
return $cap;
}
sub IsModelMaster { # ist des Streamdevices MODEL=master
my $model = shift;
my $mm = $model eq "master" ? 1 : 0;
return $mm;
}
###############################################################################
# JSON Boolean Test und Mapping
###############################################################################
@ -8045,13 +8053,17 @@ return;
# $camname = Name der Kamaera (Parent-Device)
# $strmdev = Name des Streaming-Devices
# $fmt = Streaming Format (Vergleich auf "eq" !)
# $omodel = originäres MODEL des Streaming Devices (wg. master)
# $oname = originäres NAME des Streaming Devices (wg. master)
#
######################################################################################
sub streamDev { ## no critic 'complexity'
my $paref = shift;
my $camname = $paref->{linkparent};
my $strmdev = $paref->{linkname};
my $fmt = $paref->{linkmodel};
my $fmt = $paref->{linkmodel};
my $omodel = $paref->{omodel};
my $oname = $paref->{oname};
my $ftui = $paref->{ftui};
my $hash = $defs{$camname};
@ -8232,7 +8244,7 @@ sub streamDev { ## no critic 'comp
$ret .= '<tbody>';
$ret .= '<tr class="odd">';
my $ismm = FHEM::SSCamSTRM::IsModelMaster($streamHash); # prüfen ob Streaming Dev ist MODEL = master
my $ismm = IsModelMaster($omodel); # prüfen ob Streaming Dev ist MODEL = master
if(!$ismm && (!$StmKey || ReadingsVal($camname, "Availability", "") ne "enabled" || IsDisabled($camname))) {
# Ausgabe bei Fehler

View File

@ -266,9 +266,15 @@ sub Set {
"popupStream "
;
} else {
my $sd = allStreamDevs();
my $sd = "--reset--,".allStreamDevs();
my $rsd = $sd;
$rsd =~ s/#/ /g; ## no critic 'regular expression' # Regular expression without "/x" flag nicht anwenden !!!
push my @ado, "adoptList:$rsd";
setReadings($hash, \@ado, 0);
$setlist = "Unknown argument $opt, choose one of ".
"adoptFrom:--reset--,$sd "
"adoptFrom:$sd "
;
}
@ -302,17 +308,17 @@ sub Set {
} elsif ($opt eq "adoptFrom") {
shift @a; shift @a;
$prop = join "#", @a;
$prop = join "#", @a;
if($prop eq "--reset--") {
CommandSet(undef, "$name reset");
return;
}
my $strmd = $sdevs{"$prop"};
my $strmd = $sdevs{"$prop"} // "";
my $valid = ($strmd && $defs{$strmd} && $defs{$strmd}{TYPE} eq "SSCamSTRM");
return qq{The command "$opt" needs a valid SSCamSTRM device as argument} if(!$valid);
return qq{The command "$opt" needs a valid SSCamSTRM device as argument instead of "$strmd"} if(!$valid);
# Übernahme der Readings
my @r;
@ -329,12 +335,13 @@ sub Set {
push @r, "clientLink:$link";
if(@r) {
setReadings($hash, \@r, 0);
setReadings($hash, \@r, 1);
}
my $camname = $hash->{LINKPARENT};
$defs{$camname}{HELPER}{INFORM} = $hash->{FUUID};
FHEM::SSCam::roomRefresh ("$camname,1,0,0");
InternalTimer(gettimeofday()+1.5, "FHEM::SSCam::roomRefresh", "$camname,0,0,0", 0);
} elsif ($opt eq "reset") {
delReadings($hash);
@ -344,11 +351,12 @@ sub Set {
push @r, "parentState:initialized";
push @r, "state:initialized";
setReadings($hash, \@r, 0);
setReadings($hash, \@r, 1);
my $camname = $hash->{LINKPARENT};
$defs{$camname}{HELPER}{INFORM} = $hash->{FUUID};
FHEM::SSCam::roomRefresh ("$camname,1,0,0");
InternalTimer(gettimeofday()+1.5, "FHEM::SSCam::roomRefresh", "$camname,0,0,0", 0);
} else {
return "$setlist";
@ -431,6 +439,8 @@ sub FwFn {
my %pars = ( linkparent => $hash->{LINKPARENT},
linkname => $hash->{LINKNAME},
linkmodel => $hash->{LINKMODEL},
omodel => $hash->{MODEL},
oname => $hash->{NAME},
ftui => $ftui
);
@ -590,6 +600,8 @@ sub streamAsHtml {
my %pars = ( linkparent => $hash->{LINKPARENT},
linkname => $hash->{LINKNAME},
linkmodel => $hash->{LINKMODEL},
omodel => $hash->{MODEL},
oname => $hash->{NAME},
ftui => $ftui
);
@ -679,17 +691,22 @@ sub allStreamDevs {
undef %sdevs;
my @strmdevs = devspec2array("TYPE=SSCamSTRM:FILTER=MODEL!=master"); # Liste Streaming devices außer MODEL = master
for my $d (@strmdevs) {
next if(!$defs{$d});
my $alias = AttrVal($d, "alias", $d);
for my $da (@strmdevs) {
next if(!$defs{$da});
my $alias = AttrVal($da, "alias", $da);
$alias =~ s/\s+/#/gx;
$sdevs{$alias} = "$d";
$sdevs{$alias} = "$da";
}
for my $a (sort keys %sdevs) {
$sd .= "," if($sd);
$sd .= $a;
}
for my $d (@strmdevs) { # Devicenamen zusätzlich als Schlüssel speichern damit set <> adoptFrom ohne Widget funktioniert
next if(!$defs{$d});
$sdevs{$d} = "$d";
}
return $sd;
}
@ -726,7 +743,7 @@ sub sDevsWidget {
if($valAdopts) {
$ret .= "<tr>";
$ret .= "<td>Adopt: </td><td>$Adopts</td>";
$ret .= "<td>Streaming Device: </td><td>$Adopts</td>";
$ret .= "</tr>";
}