diff --git a/fhem/CHANGED b/fhem/CHANGED index 836f0f385..47f3fe72d 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,8 @@ # 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. + - changed: 49_SSCam: usage of attribute \"livestreamprefix\" changed, + minor code changes, SSCamSTRM changed for compatibility + and new attributes with direct attribute help - feature: 74_Unifi: Added readings for wan_ip and results of speedtest - feature: 77_UWZ: new language support, french and hollandisch - change: 93_DbRep: V8.6.0, devices and readings can be excluded by diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index ef77fc235..12adb9cde 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -36,9 +36,17 @@ package main; use strict; use warnings; +eval "use JSON qw( decode_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; +# no if $] >= 5.017011, warnings => 'experimental'; # Versions History intern our %SSCam_vNotesIntern = ( + "7.3.1" => "31.10.2018 fix connection lost failure if several SSCamSTRM devices are defined and updated by longpoll from same parent device ", + "7.3.0" => "28.10.2018 usage of attribute \"livestreamprefix\" changed, exec SSCam_getStmUrlPath on boot ", "7.2.1" => "23.10.2018 new routine SSCam_versionCheck, COMPATIBILITY changed to 8.2.1 ", "7.2.0" => "20.10.2018 direct help for attributes, new get versionNotes command, fix PERL WARNING: Use of uninitialized value \$small, get versionNotes ", "7.1.1" => "18.10.2018 Message of \"Your current/simulated SVS-version...\" changed, commandref corrected ", @@ -83,6 +91,7 @@ our %SSCam_vNotesIntern = ( # Versions History extern our %SSCam_vNotesExtern = ( + "7.3.0" => "28.10.2018 In attribute \"livestreamprefix\" can now \"DEF\" be specified to overwrite livestream address by specification from device definition ", "7.2.1" => "23.10.2018 COMPATIBILITY changed to 8.2.1 ", "7.2.0" => "20.10.2018 direct help for attributes, new get versionNotes command, please see commandref for details ", "7.1.1" => "18.10.2018 Message of \"current/simulated SVS-version...\" changed, commandref corrected ", @@ -190,13 +199,6 @@ our %SSCam_vHintsExt_de = ( "Diese Vorlage kann zum Beispiel mit Paint.Net bearbeitet werden. ", "1" => "Hilfreiche Hinweise zu SSCam im FHEM-Wiki" ); - -eval "use JSON qw( decode_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; -# no if $] >= 5.017011, warnings => 'experimental'; # getestete SVS-Version my $compstat = "8.2.1"; @@ -433,7 +435,7 @@ sub SSCam_Attr($$$$) { if($aName =~ m/ptzPanel_row.*|ptzPanel_Home|ptzPanel_use/) { InternalTimer(gettimeofday()+0.7, "SSCam_addptzattr", "$name", 0); } - + if ($aName eq "disable") { if($cmd eq "set") { $do = ($aVal) ? 1 : 0; @@ -556,8 +558,7 @@ sub SSCam_Attr($$$$) { } if($aName =~ m/pollcaminfoall/) { return "The value of \"$aName\" has to be greater than 10 seconds." if($aVal <= 10); - } - + } } if ($cmd eq "del") { @@ -1427,8 +1428,8 @@ sub SSCam_initonboot ($) { if(SSCam_IsModelCam($hash)) { # Kameraspezifische Infos holen SSCam_getcaminfo($hash); - SSCam_getcapabilities($hash); + SSCam_getStmUrlPath($hash); # Preset/Patrollisten in Hash einlesen zur PTZ-Steuerung SSCam_getptzlistpreset($hash); @@ -3806,8 +3807,6 @@ return SSCam_camop($hash); sub SSCam_camop ($) { my ($hash) = @_; my $name = $hash->{NAME}; - my $serveraddr = $hash->{SERVERADDR}; - my $serverport = $hash->{SERVERPORT}; my $apicam = $hash->{HELPER}{APICAM}; my $apicampath = $hash->{HELPER}{APICAMPATH}; my $apicammaxver = $hash->{HELPER}{APICAMMAXVER}; @@ -3857,6 +3856,8 @@ sub SSCam_camop ($) { my $OpMode = $hash->{OPMODE}; my $camid = $hash->{CAMID}; my $proto = $hash->{PROTOCOL}; + my $serveraddr = $hash->{SERVERADDR}; + my $serverport = $hash->{SERVERPORT}; my ($exturl,$winname,$attr,$room,$param); my ($url,$snapid,$httptimeout,$expmode,$motdetsc); @@ -4120,7 +4121,9 @@ sub SSCam_camop ($) { Log3($name, 4, "$name - trigger external event \"$hash->{HELPER}{EVENTID}\""); $url = "$proto://$serveraddr:$serverport/webapi/$apiextevtpath?api=$apiextevt&version=$apiextevtmaxver&method=Trigger&eventId=$hash->{HELPER}{EVENTID}&eventName=$hash->{HELPER}{EVENTID}&_sid=\"$sid\""; - } elsif ($OpMode eq "runliveview" && $hash->{HELPER}{RUNVIEW} !~ m/snap|^live_.*hls$/) { + } elsif ($OpMode eq "runliveview" && $hash->{HELPER}{RUNVIEW} !~ m/snap|^live_.*hls$/) { + $exturl = AttrVal($name, "livestreamprefix", "$proto://$serveraddr:$serverport"); + $exturl = ($exturl eq "DEF")?"$proto://$serveraddr:$serverport":$exturl; if ($hash->{HELPER}{RUNVIEW} =~ m/live/) { if($apiaudiostmmaxver) { # API "SYNO.SurveillanceStation.AudioStream" vorhanden ? (removed ab API v2.8) $hash->{HELPER}{AUDIOLINK} = "$proto://$serveraddr:$serverport/webapi/$apiaudiostmpath?api=$apiaudiostm&version=$apiaudiostmmaxver&method=Stream&cameraId=$camid&_sid=$sid"; @@ -4128,7 +4131,6 @@ sub SSCam_camop ($) { delete $hash->{HELPER}{AUDIOLINK} if($hash->{HELPER}{AUDIOLINK}); } - $exturl = AttrVal($name, "livestreamprefix", "$proto://$serveraddr:$serverport"); if($apivideostmsmaxver) { # API "SYNO.SurveillanceStation.VideoStream" vorhanden ? (removed ab API v2.8) # externe URL in Reading setzen $exturl .= "/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Stream&cameraId=$camid&format=mjpeg&_sid=$sid"; @@ -4142,7 +4144,6 @@ sub SSCam_camop ($) { } else { # Abspielen der letzten Aufnahme (EventId) - $exturl = AttrVal($name, "livestreamprefix", "$proto://$serveraddr:$serverport"); # externe URL in Reading setzen $exturl .= "/webapi/$apistmpath?api=$apistm&version=$apistmmaxver&method=EventStream&eventId=$hash->{HELPER}{CAMLASTRECID}×tamp=1&_sid=$sid"; @@ -4939,12 +4940,14 @@ sub SSCam_camop_parse ($) { $unicastPath = $data->{'data'}[0]{'rtspPath'}; } - # Rewrite Url's falls livestreamprefix ist gesetzt + # Rewrite Url's falls livestreamprefix ist gesetzt if (AttrVal($name, "livestreamprefix", undef)) { + my $exturl = AttrVal($name, "livestreamprefix", "$proto://$serveraddr:$serverport"); + $exturl = ($exturl eq "DEF")?"$proto://$serveraddr:$serverport":$exturl; my @mjh = split(/\//, $mjpegHttp, 4); - $mjpegHttp = AttrVal($name, "livestreamprefix", undef)."/".$mjh[3]; + $mjpegHttp = $exturl."/".$mjh[3]; my @mxh = split(/\//, $mxpegHttp, 4); - $mxpegHttp = AttrVal($name, "livestreamprefix", undef)."/".$mxh[3]; + $mxpegHttp = $exturl."/".$mxh[3]; if($unicastPath) { my @ucp = split(/[@\|:]/, $unicastPath); my @lspf = split(/[\/\/\|:]/, AttrVal($name, "livestreamprefix", undef)); @@ -5778,18 +5781,15 @@ sub SSCam_refresh($$$$) { } # parentState des SSCamSTRM-Device mit Opmode updaten (mit/ohne Event) - my @strmdvs = devspec2array("TYPE=SSCamSTRM:FILTER=PARENT=".$name); - if(@strmdvs) { - foreach (@strmdvs) { - my $strmhash = $defs{$_}; - if($lpoll_strm) { - readingsSingleUpdate($strmhash,"parentState", $hash->{OPMODE}, 1); - } else { - readingsSingleUpdate($strmhash,"parentState", $hash->{OPMODE}, 0); - } - } + if($hash->{HELPER}{STRMDEV}) { + my $strmhash = $defs{$hash->{HELPER}{STRMDEV}}; + if($lpoll_strm) { + readingsSingleUpdate($strmhash,"parentState", $hash->{OPMODE}, 1); + } else { + readingsSingleUpdate($strmhash,"parentState", $hash->{OPMODE}, 0); + } } - + return; } @@ -7543,8 +7543,20 @@ attr <name> genericStrmHtmlTag <video $HTMLATTR controls autoplay>
  • livestreamprefix
    - overwrites the specifications of protocol, servername and port for further use of the livestream address, e.g. - as an link to external use. It has to be specified as "http(s)://<servername>:<port>"

  • + Overwrites the specifications of protocol, servername and port for further use in livestream address and + StmKey.*-readings , e.g. as a link for external use.
    + It can be specified of two ways as follows:

    + + + + + +
    DEF : the protocol, servername and port as specified in device + definition is used
    http(s)://<servername>:<port> : your own address specification is used
    +
    + + Servername can be the name or the IP-address of your Synology Surveillance Station. +
  • loginRetries
    @@ -8874,9 +8886,21 @@ attr <name> genericStrmHtmlTag <video $HTMLATTR controls autoplay>
  • livestreamprefix
    - überschreibt die Angaben zu Protokoll, Servernamen und Port zur Weiterverwendung der - Livestreamadresse als z.B. externer Link. Anzugeben in der Form - "http(s)://<servername>:<port>"

  • + Überschreibt die Angaben zu Protokoll, Servernamen und Port in StmKey.*-Readings bzw. der Livestreamadresse zur + Weiterverwendung z.B. als externer Link.
    + Die Spezifikation kann auf zwei Arten erfolgen:

    + + + + + +
    DEF : es wird Protokoll, Servername und Port aus der Definition + des SSCam-Devices verwendet
    http(s)://<servername>:<port> : eine eigene Adressenangabe wird verwendet
    +
    + + Servername kann der Name oder die IP-Adresse der Synology Surveillance Station sein. + +
  • loginRetries
    diff --git a/fhem/FHEM/49_SSCamSTRM.pm b/fhem/FHEM/49_SSCamSTRM.pm index 590b39365..af4951585 100644 --- a/fhem/FHEM/49_SSCamSTRM.pm +++ b/fhem/FHEM/49_SSCamSTRM.pm @@ -26,34 +26,49 @@ # along with fhem. If not, see . # ######################################################################################################################### -# Versions History: -# -# 1.2.3 03.07.2018 behavior changed if device is disabled -# 1.2.2 26.06.2018 make changes for generic stream dev -# 1.2.1 23.06.2018 no name add-on if MODEL is snapgallery -# 1.2.0 20.06.2018 running stream as human readable entry for SSCamSTRM-Device -# 1.1.0 16.06.2018 attr hideDisplayName regarding to Forum #88667 -# 1.0.1 14.06.2018 commandref revised -# 1.0.0 14.06.2018 switch to longpoll refresh -# 0.4 13.06.2018 new attribute "noDetaillink" (deleted in V1.0.0) -# 0.3 12.06.2018 new attribute "forcePageRefresh" -# 0.2 11.06.2018 check in with SSCam 5.0.0 -# 0.1 10.06.2018 initial Version - package main; use strict; use warnings; -my $SSCamSTRMVersion = "1.2.3"; +# Versions History intern +our %SSCamSTRM_vNotesIntern = ( + "1.4.1" => "31.10.2018 attribute \"autoLoop\" changed to \"autoRefresh\", new attribute \"autoRefreshFW\" ", + "1.4.0" => "29.10.2018 readingFnAttributes added ", + "1.3.0" => "28.10.2018 direct help for attributes, new attribute \"autoLoop\" ", + "1.2.4" => "27.10.2018 fix undefined subroutine &main::SSCam_ptzpanel (https://forum.fhem.de/index.php/topic,45671.msg850505.html#msg850505) ", + "1.2.3" => "03.07.2018 behavior changed if device is disabled ", + "1.2.2" => "26.06.2018 make changes for generic stream dev ", + "1.2.1" => "23.06.2018 no name add-on if MODEL is snapgallery ", + "1.2.0" => "20.06.2018 running stream as human readable entry for SSCamSTRM-Device ", + "1.1.0" => "16.06.2018 attr hideDisplayName regarding to Forum #88667 ", + "1.0.1" => "14.06.2018 commandref revised ", + "1.0.0" => "14.06.2018 switch to longpoll refresh ", + "0.4.0" => "13.06.2018 new attribute \"noDetaillink\" (deleted in V1.0.0) ", + "0.3.0" => "12.06.2018 new attribute \"forcePageRefresh\" ", + "0.2.0" => "11.06.2018 check in with SSCam 5.0.0 ", + "0.1.0" => "10.06.2018 initial Version " +); + +# Standardvariablen und Forward-Declaration +sub SSCam_ptzpanel($;$$); +sub SSCam_StreamDev($$$); ################################################################ sub SSCamSTRM_Initialize($) { my ($hash) = @_; + my $fwd = join(",",devspec2array("TYPE=FHEMWEB:FILTER=STATE=Initialized")); + $hash->{DefFn} = "SSCamSTRM_Define"; - $hash->{AttrList} = "disable:1,0 forcePageRefresh:1,0 htmlattr hideDisplayName:1,0 "; + $hash->{AttrList} = "autoRefresh:selectnumbers,120,0.2,1800,0,log10 ". + "autoRefreshFW:$fwd ". + "disable:1,0 ". + "forcePageRefresh:1,0 ". + "htmlattr ". + "hideDisplayName:1,0 ". + $readingFnAttributes; $hash->{FW_summaryFn} = "SSCamSTRM_FwFn"; $hash->{FW_detailFn} = "SSCamSTRM_FwFn"; $hash->{AttrFn} = "SSCamSTRM_Attr"; @@ -76,7 +91,7 @@ sub SSCamSTRM_Define($$) { $arg =~ s/'//g; ($hash->{PARENT},$hash->{MODEL}) = ((split(",",$arg))[0],(split(",",$arg))[2]); - $hash->{VERSION} = $SSCamSTRMVersion; + $hash->{VERSION} = $hash->{VERSION} = (reverse sort(keys %SSCamSTRM_vNotesIntern))[0]; $hash->{LINK} = $link; readingsSingleUpdate($hash,"state", "initialized", 1); # Init für "state" @@ -108,13 +123,14 @@ return undef; } ################################################################ -sub SSCamSTRM_FwFn($$$$) { +sub SSCamSTRM_FwFn($;$$$) { my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn. my $hash = $defs{$d}; my $link = $hash->{LINK}; - # return undef if(IsDisabled($d)); - + RemoveInternalTimer($hash); + $hash->{HELPER}{FW} = $FW_wname; + $link = AnalyzePerlCommand(undef, $link) if($link =~ m/^{(.*)}$/s); my $show = $defs{$hash->{PARENT}}->{HELPER}{ACTSTRM} if($hash->{MODEL} =~ /switched/); $show = $show?"($show)":""; @@ -133,10 +149,37 @@ sub SSCamSTRM_FwFn($$$$) { } else { $ret .= $link; } + + # Autorefresh nur des aufrufenden FHEMWEB-Devices + my $al = AttrVal($d, "autoRefresh", 0); + if($al) { + InternalTimer(gettimeofday()+$al, "SSCamSTRM_refresh", $hash, 0); + Log3($d, 5, "$d - next start of autoRefresh: ".FmtDateTime(gettimeofday()+$al)); + } return $ret; } +################################################################ +sub SSCamSTRM_refresh($) { + my ($hash) = @_; + my $d = $hash->{NAME}; + + # Seitenrefresh festgelegt durch SSCamSTRM-Attribut "autoRefresh" und "autoRefreshFW" + my $rd = AttrVal($d, "autoRefreshFW", $hash->{HELPER}{FW}); + { map { FW_directNotify("#FHEMWEB:$_", "location.reload('true')", "") } $rd } + + my $al = AttrVal($d, "autoRefresh", 0); + if($al) { + InternalTimer(gettimeofday()+$al, "SSCamSTRM_refresh", $hash, 0); + Log3($d, 5, "$d - next start of autoRefresh: ".FmtDateTime(gettimeofday()+$al)); + } else { + RemoveInternalTimer($hash); + } + +return; +} + 1; =pod @@ -192,30 +235,51 @@ Dependend of the Streaming-Device state, different buttons are provided to start