diff --git a/fhem/CHANGED b/fhem/CHANGED index 119eab7de..665327bf0 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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. + - feature 49_SSCAM: The port in DEF-String is optional now, + if not given, default port 5000 is used - bugfix: 98_weekprofile: transfer day settings to other days - bugfix: 49_SSCAM: fixed a problem that manual updates using "getcaminfoall" are leading to additional pollingloops diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index 47fbd0a20..0be0b22f2 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -27,6 +27,8 @@ ########################################################################################################## # Versions History: # +# 1.14 the port in DEF-String is optional now, +# if not given, default port 5000 is used # 1.13.2 13.02.2016 fixed a problem that manual updates using "getcaminfoall" are # leading to additional pollingloops if polling is used, # attribute "debugactivetoken" added for debugging-use @@ -78,7 +80,7 @@ # # Definition: define SSCam # -# Example: define CamCP1 SSCAM Carport 192.168.2.20 5000 +# Example: define CamCP1 SSCAM Carport 192.168.2.20 [5000] # @@ -120,7 +122,7 @@ return undef; sub SSCam_Define { # Die Define-Funktion eines Moduls wird von Fhem aufgerufen wenn der Define-Befehl für ein Gerät ausgeführt wird # Welche und wie viele Parameter akzeptiert werden ist Sache dieser Funktion. Die Werte werden nach dem übergebenen Hash in ein Array aufgeteilt - # define CamCP1 SSCAM Carport 192.168.2.20 5000 + # define CamCP1 SSCAM Carport 192.168.2.20 [5000] # ($hash) [1] [2] [3] [4] # my ($hash, $def) = @_; @@ -128,13 +130,13 @@ sub SSCam_Define { my @a = split("[ \t][ \t]*", $def); - if(int(@a) < 5) { + if(int(@a) < 4) { return "You need to specify more parameters.\n". "Format: define SSCAM "; } my $camname = $a[2]; my $serveraddr = $a[3]; - my $serverport = $a[4]; + my $serverport = $a[4] ? $a[4] : 5000; $hash->{SERVERADDR} = $serveraddr; $hash->{SERVERPORT} = $serverport; @@ -768,7 +770,7 @@ sub camexpmode ($) { } else { - InternalTimer(gettimeofday()+1.1, "camexpmode", $hash, 0); + InternalTimer(gettimeofday()+0.13, "camexpmode", $hash, 0); } } @@ -1393,7 +1395,17 @@ sub login_nonbl ($) { # Evaluiere ob Daten im JSON-Format empfangen wurden ($hash, $success) = &evaljson($hash,$myjson,$param->{url}); - unless ($success) {$logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); $hash->{HELPER}{ACTIVE} = "off"; return($hash,$success)}; + + unless ($success) { + $logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); + $hash->{HELPER}{ACTIVE} = "off"; + + if ($attr{$name}{debugactivetoken}) { + $logstr = "Active-Token deleted by OPMODE: $hash->{OPMODE}" ; + &printlog($hash,$logstr,"3"); + } + return; + } $data = decode_json($myjson); @@ -1527,7 +1539,6 @@ sub login_nonbl ($) { $logstr = "Active-Token deleted by OPMODE: $hash->{OPMODE}" ; &printlog($hash,$logstr,"3"); } - return; } } @@ -1539,7 +1550,19 @@ sub login_nonbl ($) { # Credentials abrufen ($success, $username, $password) = getcredentials($hash,0); - unless ($success) {$logstr = "Credentials couldn't be retrieved successfully - make sure you've set it with \"set $name credentials \""; &printlog($hash,$logstr,"1"); $hash->{HELPER}{ACTIVE} = "off"; return($hash,$success)}; + + unless ($success) { + $logstr = "Credentials couldn't be retrieved successfully - make sure you've set it with \"set $name credentials \""; + &printlog($hash,$logstr,"1"); + + $hash->{HELPER}{ACTIVE} = "off"; + + if ($attr{$name}{debugactivetoken}) { + $logstr = "Active-Token deleted by OPMODE: $hash->{OPMODE}" ; + &printlog($hash,$logstr,"3"); + } + return; + } $httptimeout = $attr{$name}{httptimeout} ? $attr{$name}{httptimeout} : "4"; @@ -1596,14 +1619,14 @@ sub getcamid_nonbl ($) { my $httptimeout; # Verarbeitung der asynchronen Rückkehrdaten aus sub "login_nonbl" - if ($err ne "") # wenn ein Fehler bei der HTTP Abfrage aufgetreten ist + if ($err ne "") # wenn ein Fehler bei der HTTP Abfrage aufgetreten ist { $logstr = "error while requesting ".$param->{url}." - $err"; - &printlog($hash,$logstr,"1"); # Eintrag fürs Log + &printlog($hash,$logstr,"1"); $logstr = "--- End Function serverlogin nonblocking with error ---"; &printlog($hash,$logstr,"4"); - readingsSingleUpdate($hash, "Error", $err, 1); # Readings erzeugen + readingsSingleUpdate($hash, "Error", $err, 1); # ausgeführte Funktion ist abgebrochen, Freigabe Funktionstoken $hash->{HELPER}{ACTIVE} = "off"; @@ -1615,11 +1638,21 @@ sub getcamid_nonbl ($) { return; } - elsif ($myjson ne "") # wenn die Abfrage erfolgreich war ($data enthält die Ergebnisdaten des HTTP Aufrufes) + elsif ($myjson ne "") # wenn die Abfrage erfolgreich war ($data enthält die Ergebnisdaten des HTTP Aufrufes) { # Evaluiere ob Daten im JSON-Format empfangen wurden ($hash, $success) = &evaljson($hash,$myjson,$param->{url}); - unless ($success) {$logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); $hash->{HELPER}{ACTIVE} = "off"; return($hash,$success);} + + unless ($success) { + $logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); + $hash->{HELPER}{ACTIVE} = "off"; + + if ($attr{$name}{debugactivetoken}) { + $logstr = "Active-Token deleted by OPMODE: $hash->{OPMODE}" ; + &printlog($hash,$logstr,"3"); + } + return; + } $data = decode_json($myjson); @@ -1774,7 +1807,11 @@ sub camop_nonbl ($) { # Evaluiere ob Daten im JSON-Format empfangen wurden, Achtung: sehr viele Daten mit verbose=5 ($hash, $success) = &evaljson($hash,$myjson,$param->{url}); - unless ($success) {$logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); $hash->{HELPER}{ACTIVE} = "off"; return (logout_nonbl($hash));} + + unless ($success) { + $logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); + return (logout_nonbl($hash)); + } $data = decode_json($myjson); @@ -1921,8 +1958,8 @@ sub camop_nonbl ($) { } elsif ($OpMode eq "Getcaminfo") { - # Infos einer Kamera werden abgerufen, Rückkehr wird mit "camret_nonbl" verarbeitet - $url = "http://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&version=\"$apicammaxver\"&method=\"GetInfo\"&cameraIds=\"$camid\"&deviceOutCap=true&streamInfo=true&ptz=true&basic=true&camAppInfo=true&optimize=true&fisheye=true&eventDetection=true&_sid=\"$sid\""; + # Infos einer Kamera werden abgerufen, Rückkehr wird mit "camret_nonbl" verarbeitet + $url = "http://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&version=\"$apicammaxver\"&method=\"GetInfo\"&cameraIds=\"$camid\"&deviceOutCap=\"true\"&streamInfo=\"true\"&ptz=\"true\"&basic=\"true\"&camAppInfo=\"true\"&optimize=\"true\"&fisheye=\"true\"&eventDetection=\"true\"&_sid=\"$sid\""; } elsif ($OpMode eq "Getptzlistpreset") { @@ -2024,7 +2061,11 @@ sub camret_nonbl ($) { { # Evaluiere ob Daten im JSON-Format empfangen wurden ($hash, $success) = &evaljson($hash,$myjson,$param->{url}); - unless ($success) {$logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); $hash->{HELPER}{ACTIVE} = "off"; return (logout_nonbl($hash));} + + unless ($success) { + $logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); + return (logout_nonbl($hash)); + } $data = decode_json($myjson); @@ -2727,7 +2768,20 @@ sub logoutret_nonbl ($) { # Evaluiere ob Daten im JSON-Format empfangen wurden ($hash, $success) = &evaljson($hash,$myjson,$param->{url}); - unless ($success) {$logstr = "Data returned: ".$myjson; &printlog($hash,$logstr,"4"); $hash->{HELPER}{ACTIVE} = "off"; return($hash,$success)}; + + unless ($success) { + $logstr = "Data returned: ".$myjson; + &printlog($hash,$logstr,"4"); + + $hash->{HELPER}{ACTIVE} = "off"; + + if ($attr{$name}{debugactivetoken}) { + $logstr = "Active-Token deleted by OPMODE: $hash->{OPMODE}" ; + &printlog($hash,$logstr,"3"); + } + + return; + } $data = decode_json($myjson); @@ -2948,7 +3002,7 @@ return; Define

    - define <name> SSCAM <Cameraname in SVS> <ServerAddr> <Port>
    + define <name> SSCAM <Cameraname in SVS> <ServerAddr> [Port]

    Defines a new camera device for SSCam. At first the devices have to be set up and operable in Synology Surveillance Station 7.0 and above.

    @@ -2966,14 +3020,14 @@ return; name: the name of the new device to use in FHEM Cameraname: Cameraname as defined in Synology Surveillance Station, Spaces are not allowed in Cameraname ! ServerAddr: IP-address of Synology Surveillance Station Host. Note: avoid using hostnames because of DNS-Calls are not unblocking in FHEM - Port: the Port Synology surveillance Station Host, normally 5000 (HTTP only) + Port: optional - the port of synology surveillance station, if not set the default of 5000 (HTTP only) is used

    Example:
    -      define CamCP SSCAM Carport 192.168.2.20 5000  
    +      define CamCP SSCAM Carport 192.168.2.20 [5000]  
         
    @@ -3442,7 +3496,7 @@ return; Definition

      - define <name> SSCAM <Kameraname in SVS> <ServerAddr> <Port>
      + define <name> SSCAM <Kameraname in SVS> <ServerAddr> [Port]

      Definiert eine neue Kamera für SSCam. Zunächst muß diese Kamera in der Synology Surveillance Station 7.0 oder höher eingebunden sein und entsprechend funktionieren.

      @@ -3460,14 +3514,14 @@ return; name: der Name des neuen Gerätes in FHEM Kameraname: Kameraname wie er in der Synology Surveillance Station angegeben ist. Leerzeichen im Namen sind nicht erlaubt ! ServerAddr: die IP-Addresse des Synology Surveillance Station Host. Hinweis: Es sollte kein Servername verwendet werden weil DNS-Aufrufe in FHEM blockierend sind. - Port: der Port des Synology Surveillance Station Host. Normalerweise ist das 5000 (nur HTTP) + Port: optional - der Port der Synology Surveillance Station. Wenn nicht angegeben wird der Default-Port 5000 (nur HTTP) gesetzt

      Beispiel:
      -      define CamCP SSCAM Carport 192.168.2.20 5000      
      +      define CamCP SSCAM Carport 192.168.2.20 [5000]