diff --git a/fhem/CHANGED b/fhem/CHANGED index fe0d336b1..81b1e2999 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,11 @@ # 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. + - change: 49_SSCAM: changed DEF in order to remove credentials from string, + added "set credentials" command to save username/password, + added Attribute "session" to make login-session selectable, + NOTE: You have to adapt your define-strings after update !! + look at commandref or forum-post for details: + forum.fhem.de/index.php/topic,45671.msg397449.html#msg397449 - bugfix: 73_GasCalculator: Bugfix in Commandref and 2 attributes renamed. - feature: 98_weekprofile: including topics\categories - change: 98_weekprofile: filter for homatic channel devices diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index 9648e7231..49f06500e 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -27,6 +27,12 @@ ########################################################################################################## # Versions History: # +# 1.8 25.01.2016 changed define in order to remove credentials from string, +# added "set credentials" command to save username/password, +# added Attribute "session" to make login-session selectable, +# Note: You have to adapt your define-strings !! +# Refere to commandref or look in forum at: +# http://forum.fhem.de/index.php/topic,45671.msg397449.html#msg397449 # 1.7 18.01.2016 Attribute "httptimeout" added # 1.6 16.01.2016 Change the define-string related to rectime. # Note: See all changes to rectime usage in commandref or here: @@ -48,9 +54,9 @@ # LWP is not needed anymore # # -# Definition: define SSCam +# Definition: define SSCam # -# Example: define CamCP1 SSCAM 192.168.2.20 5000 apiuser apipw Carport +# Example: define CamCP1 SSCAM Carport 192.168.2.20 5000 # @@ -59,7 +65,8 @@ package main; use JSON qw( decode_json ); # From CPAN,, Debian libjson-perl use Data::Dumper; # Perl Core module use strict; -use warnings; +use warnings; +use MIME::Base64; use HttpUtils; @@ -78,6 +85,7 @@ sub SSCam_Initialize($) { "pollcaminfoall ". "pollnologging:1,0 ". "rectime ". + "session:SurveillanceStation,DSM ". "webCmd ". $readingFnAttributes; @@ -87,29 +95,24 @@ sub SSCam_Initialize($) { 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 192.168.2.20 5000 apiuser Support4me Carport - # ($hash) [1] [2] [3] [4] [5] [6] + # define CamCP1 SSCAM Carport 192.168.2.20 5000 + # ($hash) [1] [2] [3] [4] # my ($hash, $def) = @_; my $name = $hash->{NAME}; my @a = split("[ \t][ \t]*", $def); - if(int(@a) < 7) { - return "You need to specify more parameters.\n". "Format: define SSCAM "; + if(int(@a) < 5) { + return "You need to specify more parameters.\n". "Format: define SSCAM "; } - my $serveraddr = $a[2]; - my $serverport = $a[3]; - my $username = $a[4]; - my $password = $a[5]; - my $camname = $a[6]; - + my $camname = $a[2]; + my $serveraddr = $a[3]; + my $serverport = $a[4]; $hash->{SERVERADDR} = $serveraddr; $hash->{SERVERPORT} = $serverport; - $hash->{HELPER}{USERNAME} = $username; - $hash->{HELPER}{PASSWORD} = $password; $hash->{CAMNAME} = $camname; # benötigte API's in $hash einfügen @@ -120,7 +123,7 @@ sub SSCam_Define { $hash->{HELPER}{APISNAPSHOT} = "SYNO.SurveillanceStation.SnapShot"; $hash->{HELPER}{APIPTZ} = "SYNO.SurveillanceStation.PTZ"; - # Anfangswerte setzen + # Startwerte setzen $attr{$name}{webCmd} = "on:off:snap:enable:disable"; # initiale Webkommandos setzen $hash->{HELPER}{ACTIVE} = "off"; # Funktionstoken "off", Funktionen können sofort starten $hash->{HELPER}{OLDVALPOLLNOLOGGING} = "0"; # Loggingfunktion für Polling ist an @@ -129,8 +132,8 @@ sub SSCam_Define { readingsSingleUpdate($hash,"Record","Stop",0); # Recordings laufen nicht readingsSingleUpdate($hash,"Availability", "", 0); # Verfügbarkeit ist unbekannt readingsSingleUpdate($hash,"PollState","Inactive",0); # es ist keine Gerätepolling aktiv - - RemoveInternalTimer($hash); # alle evtl. noch laufenden Timer löschen + getcredentials($hash,1); # Credentials lesen und in RAM laden ($boot=1) + RemoveInternalTimer($hash); # alle Timer löschen # Subroutine Watchdog-Timer starten (sollen Cam-Infos abgerufen werden ?), verzögerter zufälliger Start 0-60s @@ -169,11 +172,13 @@ return undef; sub SSCam_Set { my ($hash, @a) = @_; return "\"set X\" needs at least an argument" if ( @a < 2 ); - my $name = $a[0]; - my $opt = $a[1]; - my $prop = $a[2]; + my $name = $a[0]; + my $opt = $a[1]; + my $prop = $a[2]; + my $prop1 = $a[3]; my %SSCam_sets = ( + "credentials" => "credentials", "on" => "on", "off" => "off", "snap" => "snap:", @@ -187,10 +192,12 @@ sub SSCam_Set { # return SetExtensions($hash, $list, $name, $opt) if( !grep( $_ =~ /^\Q$opt\E($|:)/, split( ' ', $list ) ) ); - my $camname = $hash->{CAMNAME}; + my $camname = $hash->{CAMNAME}; + my $success; my $logstr; my @cList; - + + # ist die angegebene Option verfügbar ? if(!defined($SSCam_sets{$opt})) { @@ -200,6 +207,8 @@ sub SSCam_Set { } else { + if ($opt ne "credentials" and !$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";} + if ($opt eq "on") { @@ -227,6 +236,14 @@ sub SSCam_Set { { &camdisable($hash); } + elsif ($opt eq "credentials") + { + return "Credentials are incomplete, use username password" if (!$prop || !$prop1); + + ($success) = setcredentials($hash,$prop,$prop1); + return $success ? "Username and Password saved successfully" : "Error while saving Username / Password - see logfile for details"; + } + } return undef; @@ -261,6 +278,110 @@ sub SSCam_Get { return undef; } +###################################################################################### +### Username / Paßwort speichern + +sub setcredentials ($@) { + my ($hash, @credentials) = @_; + my $logstr; + my $success; + my $credstr; + my $index; + my $retcode; + my (@key,$len,$i); + + $credstr = encode_base64(join(':', @credentials)); + + # Beginn Scramble-Routine + @key = qw(1 3 4 5 6 3 2 1 9); + $len = scalar @key; + $i = 0; + $credstr = join "", + map { $i = ($i + 1) % $len; + chr((ord($_) + $key[$i]) % 256) } split //, $credstr; + # End Scramble-Routine + + $index = $hash->{TYPE}."_".$hash->{NAME}."_credentials"; + $retcode = setKeyValue($index, $credstr); + + if ($retcode) { + $logstr = "Error while saving the Credentials - $retcode"; + &printlog($hash,$logstr,"1"); + $success = 0; + } + else + { + getcredentials($hash,1); # Credentials nach Speicherung lesen und in RAM laden ($boot=1) + $success = 1; + } + +return ($success); +} + +###################################################################################### +### Username / Paßwort abrufen + +sub getcredentials ($$) { + my ($hash,$boot) = @_; + my $logstr; + my $success; + my $username; + my $passwd; + my $index; + my ($retcode, $credstr); + my (@key,$len,$i); + + if ($boot eq 1) { + # mit $boot=1 Credentials von Platte lesen und als scrambled-String in RAM legen + $index = $hash->{TYPE}."_".$hash->{NAME}."_credentials"; + ($retcode, $credstr) = getKeyValue($index); + + if ($retcode) { + $logstr = "Unable to read password from file: $retcode"; + &printlog($hash,$logstr,"1"); + $success = 0; + } + + if ($credstr) { + + # beim Boot scrambled Credentials in den RAM laden + $hash->{HELPER}{CREDENTIALS} = $credstr; + + # "Credentials" wird als Statusbit ausgewertet. Wenn nicht gesetzt -> Warnmeldung und keine weitere Verarbeitung + $hash->{CREDENTIALS} = "Set"; + $success = 1; + } + } + else + { + # boot = 0 -> Credentials aus RAM lesen, decoden und zurückgeben + $credstr = $hash->{HELPER}{CREDENTIALS}; + + # Beginn Descramble-Routine + @key = qw(1 3 4 5 6 3 2 1 9); + $len = scalar @key; + $i = 0; + $credstr = join "", + map { $i = ($i + 1) % $len; + chr((ord($_) - $key[$i] + 256) % 256) } + split //, $credstr; + # Ende Descramble-Routine + + ($username, $passwd) = split(":",decode_base64($credstr)); + + $logstr = "Credentials read from RAM: $username $passwd"; + &printlog($hash,$logstr,"4"); + + $success = (defined($passwd)) ? 1 : 0; + } + +return ($success, $username, $passwd); +} + + + +###################################################################################### +### Polling Überwachung sub watchdogpollcaminfo ($) { # Überwacht die Wert von Attribut "pollcaminfoall" und Reading "PollState" @@ -920,12 +1041,23 @@ sub login_nonbl ($) { $logstr = "--- Begin Function serverlogin nonblocking ---"; &printlog($hash,$logstr,"4"); + # 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)}; + $httptimeout = AttrVal($name, "httptimeout",undef) ? AttrVal($name, "httptimeout",undef) : "4"; + # Logausgabe $logstr = "HTTP-Call will be done with httptimeout-Value: $httptimeout s"; &printlog($hash,$logstr,"5"); - $url = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=$password&session=SurveillanceStation&format=\"sid\""; + if (AttrVal($name, "session", undef) eq "SurveillanceStation") { + $url = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=$password&session=SurveillanceStation&format=\"sid\""; + } + else + { + $url = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=$password&format=\"sid\""; + } $param = { url => $url, @@ -938,10 +1070,10 @@ sub login_nonbl ($) { # login wird ausgeführt, $sid ermittelt und mit Routine "getcamid_nonbl" verarbeitet HttpUtils_NonblockingGet ($param); - - } + + ############################################################################### #### Rückkehr aus Funktion login und $sid ermitteln, #### nach erfolgreicher Verarbeitung wird Kamera-ID ermittelt @@ -949,18 +1081,17 @@ sub login_nonbl ($) { sub getcamid_nonbl ($) { my ($param, $err, $myjson) = @_; - my $hash = $param->{hash}; - my $name = $hash->{NAME}; - my $serveraddr = $hash->{SERVERADDR}; - my $serverport = $hash->{SERVERPORT}; - my $username = $hash->{HELPER}{USERNAME}; - my $apicam = $hash->{HELPER}{APICAM}; - my $apicampath = $hash->{HELPER}{APICAMPATH}; - my $apicammaxver = $hash->{HELPER}{APICAMMAXVER}; + my $hash = $param->{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}; + my ($success, $username) = getcredentials($hash,0); my $url; my $data; my $logstr; - my $success; my $sid; my $error; my $errorcode; @@ -1061,8 +1192,8 @@ sub getcamid_nonbl ($) { # einlesen aller Kameras - Auswertung in Rückkehrfunktion "camop_nonbl" # $apicammaxver um 1 verringern - Issue in API ! - if (defined $apicammaxver) {$apicammaxver -= 1}; - $url = "http://$serveraddr:$serverport/webapi/$apicampath?api=$apicam&version=$apicammaxver&method=List&_sid=\"$sid\""; + # if (defined $apicammaxver) {$apicammaxver -= 1}; + $url = "http://$serveraddr:$serverport/webapi/$apicampath?api=$apicam&version=$apicammaxver&method=List&basic=true&streamInfo=true&camStm=true&_sid=\"$sid\""; $param = { url => $url, @@ -1090,7 +1221,6 @@ sub camop_nonbl ($) { my $serveraddr = $hash->{SERVERADDR}; my $serverport = $hash->{SERVERPORT}; my $camname = $hash->{CAMNAME}; - my $username = $hash->{HELPER}{USERNAME}; my $apicam = $hash->{HELPER}{APICAM}; my $apicampath = $hash->{HELPER}{APICAMPATH}; my $apicammaxver = $hash->{HELPER}{APICAMMAXVER}; @@ -1190,7 +1320,7 @@ sub camop_nonbl ($) { readingsEndUpdate($hash, 1); # Logausgabe - $logstr = "ERROR - Cameraname $camname wasn't found in Surveillance Station. Check Userrights ($username), Cameraname and Spelling."; + $logstr = "ERROR - Cameraname $camname wasn't found in Surveillance Station. Check Userrights, Cameraname and Spelling."; &printlog($hash,$logstr,"1"); $logstr = "--- End Function getcamid nonblocking with error ---"; &printlog($hash,$logstr,"4"); @@ -1793,7 +1923,13 @@ sub camret_nonbl ($) { $logstr = "HTTP-Call will be done with httptimeout-Value: $httptimeout s"; &printlog($hash,$logstr,"5"); - $url = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Logout&_sid=$sid"; + if (AttrVal($name, "session", undef) eq "SurveillanceStation") { + $url = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Logout&session=SurveillanceStation&_sid=$sid"; + } + else + { + $url = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Logout&_sid=$sid"; + } $param = { url => $url, @@ -1815,12 +1951,11 @@ sub camret_nonbl ($) { sub logout_nonbl ($) { my ($param, $err, $myjson) = @_; - my $hash = $param->{hash}; - my $username = $hash->{HELPER}{USERNAME}; - my $sid = $hash->{HELPER}{SID}; + my $hash = $param->{hash}; + my $sid = $hash->{HELPER}{SID}; + my ($success, $username) = getcredentials($hash,0); my $data; my $logstr; - my $success; my $error; my $errorcode; @@ -1940,7 +2075,7 @@ sub experrorauth { 102 => "API does not exist", 400 => "Invalid user or password", 401 => "Guest or disabled account", - 402 => "Permission denied", + 402 => "Permission denied - make sure user is member of Admin-group if DSM-Session is used", 403 => "One time password not specified", 404 => "One time password authenticate failed", ); @@ -1972,6 +2107,7 @@ sub experror { 105 => "Insufficient user privilege", 106 => "Connection time out", 107 => "Multiple login detected", + 117 => "need manager rights in SurveillanceStation for operation", 400 => "Execution failed", 401 => "Parameter invalid", 402 => "Camera disabled", @@ -2021,7 +2157,7 @@ return; At present the following functions are available:

      -
    • Start a Rocording
    • +
    • Start a Recording
    • Stop a Recording (using command or automatically after the <RecordTime> period
    • Trigger a Snapshot
    • Deaktivate a Camera in Synology Surveillance Station
    • @@ -2038,21 +2174,22 @@ return; Prerequisites

      This module uses the CPAN-module JSON. Please consider to install this package (Debian: libjson-perl).
      You don't need to install LWP anymore, because of SSCam is completely using the nonblocking functions of HttpUtils respectively HttpUtils_NonblockingGet now.
      - You also need to add an user in Synology DSM as member of Administrators group.

      + In DSM respectively in Synology Surveillance Station an User has to be created. The login credentials are needed later when using a set-command to assign the login-data to a device.
      + Further informations could be find among Credentials.

      Define

        - define <name> SSCam <ServerAddr> <Port> <Username> <Password> <Cameraname>
        + 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.

        The Modul SSCam ist based on functions of Synology Surveillance Station API.
        Please refer the Web API Guide.

        - At present only HTTP-protocol is supported to call Synology DS.

        + Currently only HTTP-protocol is supported to call Synology DS.

        The parameters are in detail:
        @@ -2061,18 +2198,16 @@ 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)
        Username: Username defined in the Diskstation. Has to be a member of Admin-group
        Password: the Password for the User
        Cameraname: Cameraname as defined in Synology Surveillance Station, Spaces are not allowed in Cameraname !


        - Examples: + Example:
        -      define CamCP SSCAM 192.168.2.20 5000 apiuser apipass Carport     
        +      define CamCP SSCAM Carport 192.168.2.20 5000  
             
        @@ -2088,8 +2223,54 @@ return; In that case the command "set <name> on 0" leads also to an endless recording.

        - If you have specified a pre-recording time in SVS it will be considered too.

        + If you have specified a pre-recording time in SVS it will be considered too.


        + + + Credentials

        + + After a camera-device is defined, firstly it is needed to save the credentials. This will be done with command: + +
         
        +     set <name> credentials <username> <password>
        +    
        + + The operator can, dependend on what functions are planned to execute, create an user in DSM respectively in Synology Surveillance Station as well.
        + If the user is member of admin-group, he has access to all module functions. Without this membership the user can only execute functions with lower need of rights.
        + The required minimum rights to execute functions are listed in a table further down.
        + + Alternatively to DSM-user a user created in SVS can be used. Also in that case a user of type "manager" has the right to execute all functions,
        + whereat the access to particular cameras can be restricted by the privilege profile (please see help function in SVS for details).
        + As best practice it is proposed to create an user in DSM as well as in SVS too:

        + +
          +
        • DSM-User as member of admin group: unrestricted test of all module functions -> session: DSM
        • +
        • SVS-User as Manager or observer: adjusted privilege profile -> session: SurveillanceStation
        • +
        +
        + + Using the Attribute "session" can be selected, if the session should be established to DSM or the SVS instead.
        + If the session will be established to DSM, SVS Web-API methods are available as well as further API methods of other API's what possibly needed for processing.

        + + After device definition the default is "login to DSM", that means credentials with admin rights can be used to test all camera-functions firstly.
        + After this the credentials can be switched to a SVS-session with a restricted privilege profile as needed on dependency what module functions are want to be executed.

        + + The following list shows the minimum rights what the particular module function needs.

        +
          + + + + + + + + + +
        • set ... on
        • session: ServeillanceStation - observer with enhanced privilege "manual recording"
        • set ... off
        • session: ServeillanceStation - observer with enhanced privilege "manual recording"
        • set ... snap
        • session: ServeillanceStation - observer
        • set ... disable
        • session: ServeillanceStation - manager
        • set ... enable
        • session: ServeillanceStation - manager
        • set ... credentials
        • -
        • get ... caminfoall
        • session: ServeillanceStation - observer
          +
        +

        + + HTTP-Timeout Settings

        All functions of the SSCam-Module are using HTTP-Calls to the SVS Web API.
        The Default-Value of the HTTP-Timeout amounts 4 seconds. You can set the Attribute "httptimeout" > 0 to adjust the value as needed in your technical environment.
        @@ -2190,10 +2371,10 @@ return; Polling of Camera-Properties:

        - Retrieval of Camera-Properties can be done automatically if the attribute "pollcaminfoall" will be set to a value > 10.
        + Retrieval of Camera-Properties can be done automatically if the attribute "pollcaminfoall" will be set to a value > 10.
        As default that attribute "pollcaminfoall" isn't be set and the automatic polling isn't be active.
        - The value of that attribute determines the interval of property-retrieval in seconds. If that attribute isn't be set or < 10 the automatic polling won't be started
        - respectively stopped when the value was set to > 10 before.

        + The value of that attribute determines the interval of property-retrieval in seconds. If that attribute isn't be set or < 10 the automatic polling won't be started
        + respectively stopped when the value was set to > 10 before.

        The attribute "pollcaminfoall" is monitored by a watchdog-timer. Changes of th attributevalue will be checked every 90 seconds and transact correspondig.
        Changes of the pollingstate and pollinginterval will be reported in FHEM-Logfile. The reporting can be switched off by setting the attribute "pollnologging=1".
        @@ -2202,12 +2383,14 @@ return; If FHEM will be restarted, the first data retrieval will be done within 60 seconds after start.

        - The state of automatic polling will be displayed by reading "PollState":
        -
        -    PollState = Active     -    automatic polling will be executed with interval correspondig value of attribute 
        -    PollState = Inactive   -    automatic polling won't be executed
        -  
        - + The state of automatic polling will be displayed by reading "PollState":

        + +
          +
        • PollState = Active - automatic polling will be executed with interval correspondig value of attribute "pollcaminfoall"
        • +
        • PollState = Inactive - automatic polling won't be executed
        • +
        +
        + The meaning of reading values is described under Readings .

        Notes:

        @@ -2223,6 +2406,23 @@ return; A marginal difference between the polling intervals of the defined cameras, e.g. 1 second, can already be faced as sufficient value.

      + +Internals
      +
        + The meaning of used Internals is depicted in following list:

        +
          +
        • CAMID - the ID of camera defined in SVS, the value will be retrieved automatically on the basis of SVS-cameraname
        • +
        • CAMNAME - the name of the camera in SVS
        • +
        • CREDENTIALS - the value is "Set" if Credentials are set
        • +
        • NAME - the cameraname in FHEM
        • +
        • OPMODE - the last executed operation of the module
        • +
        • SERVERADDR - IP-Address of SVS Host
        • +
        • SERVERPORT - SVS-Port
        • + +

          +
        +
      + Readings
        @@ -2272,12 +2472,14 @@ return;
        • httptimeout - Timeout-Value of HTTP-Calls to Synology Surveillance Station, Default: 4 seconds (if httptimeout = "0" or not set)
        • -
        • pollcaminfoall - Interval of automatic polling the Camera properties (if < 10: no polling, if > 10: polling with interval)
        • +
        • pollcaminfoall - Interval of automatic polling the Camera properties (if < 10: no polling, if > 10: polling with interval)
        • pollnologging - "0" resp. not set = Logging device polling active (default), "1" = Logging device polling inactive
        • rectime - the determined recordtime when a recording starts. If rectime = 0 an endless recording will be started. If it isn't defined, the default recordtime of 15s is activated
        • +
        • session - selection of login-Session. Not set or set to "DSM" -> session will be established to DSM (Sdefault). "SurveillanceStation" -> session will be established to SVS

        • +
        • verbose

          • @@ -2286,11 +2488,12 @@ return; - - - - - + + + + + +
            0 Start/Stop-Event will be logged
            1 Error messages will be logged
            3 sended commands will be logged
            4 sended and received informations will be logged
            5 all outputs will be logged for error-analyses. Caution: a lot of data could be written into logfile !
            0 - Start/Stop-Event will be logged
            1 - Error messages will be logged
            2 - messages according to important events were logged
            3 - sended commands will be logged
            4 - sended and received informations will be logged
            5 - all outputs will be logged for error-analyses. Caution: a lot of data could be written into logfile !


          @@ -2331,13 +2534,14 @@ return; Vorbereitung

          Dieses Modul nutzt das CPAN Module JSON. Bitte darauf achten dieses Paket zu installieren. (Debian: libjson-perl).
          Das CPAN-Modul LWP wird für SSCam nicht mehr benötigt. Das Modul verwendet für HTTP-Calls die nichtblockierenden Funktionen von HttpUtils bzw. HttpUtils_NonblockingGet.
          - Im DSM muß ebenfalls ein Nutzer als Mitglied der Administratorgruppe angelegt sein. Die Daten werden bei der Definition des Gerätes benötigt.

          + Im DSM bzw. der Synology Surveillance Station muß ein Nutzer angelegt sein. Die Zugangsdaten werden später über ein Set-Kommando dem angelegten Gerät zugewiesen.
          + Nähere Informationen dazu unter Credentials

          - + Definition

            - define <name> SSCam <ServerAddr> <Port> <Username> <Password> <Kameraname in SVS>
            + 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.

            @@ -2353,18 +2557,16 @@ 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)
            Username: Name des in der Diskstation definierten Nutzers. Er muß ein Mitglied der Admin-Gruppe sein
            Password: das Passwort des Nutzers
            Cameraname: Kameraname wie er in der Synology Surveillance Station angegeben ist. Leerzeichen im Namen sind nicht erlaubt !


            Beispiel:
            -      define CamCP SSCAM 192.168.2.20 5000 apiuser apipass Carport     
            +      define CamCP SSCAM Carport 192.168.2.20 5000      
                  
            @@ -2377,7 +2579,54 @@ return; Mit dem Befehl "set <name> on [rectime]" wird die Aufnahmedauer temporär festgelegt und überschreibt einmalig sowohl den Defaultwert als auch den Wert des gesetzten Attributs "rectime".
            Auch in diesem Fall führt "set <name> on 0" zu einer Daueraufnahme.

            - Eine eventuell in der SVS eingestellte Dauer der Voraufzeichnung wird weiterhin berücksichtigt.

            + Eine eventuell in der SVS eingestellte Dauer der Voraufzeichnung wird weiterhin berücksichtigt.


            + + + + Credentials

            + + Nach dem Definieren des Gerätes müssen zuerst die Zugangsrechte gespeichert werden. Das geschieht mit dem Befehl: + +
             
            +     set <name> credentials <username> <password>
            +    
            + + Der Anwender kann in Abhängigkeit der beabsichtigten einzusetzenden Funktionen einen Nutzer im DSM bzw. in der Surveillance Station einrichten.
            + Ist der DSM-Nutzer der Gruppe Administratoren zugeordnet, hat er auf alle Funktionen Zugriff. Ohne diese Gruppenzugehörigkeit können nur Funktionen mit niedrigeren
            + Rechtebedarf ausgeführt werden. Die benötigten Mindestrechte der Funktionen sind in der Tabelle weiter unten aufgeführt.
            + + Alternativ zum DSM-Nutzer kann ein in der SVS angelegter Nutzer verwendet werden. Auch in diesem Fall hat ein Nutzer vom Typ Manager das Recht alle Funktionen
            + auszuführen, wobei der Zugriff auf bestimmte Kameras/ im Privilegienprofil beschränkt werden kann (siehe Hilfefunktion in SVS).
            + Als Best Practice wird vorgeschlagen jeweils einen User im DSM und einen in der SVS anzulegen:

            + +
              +
            • DSM-User als Mitglied der Admin-Gruppe: uneingeschränkter Test aller Modulfunktionen -> session:DSM
            • +
            • SVS-User als Manager oder Betrachter: angepasstes Privilegienprofil -> session: SurveillanceStation
            • +
            +
            + + Über das Attribut "session" kann ausgewählt werden, ob die Session mit dem DSM oder der SVS augebaut werden soll.
            + Erfolgt der Session-Aufbau mit dem DSM, stehen neben der SVS Web-API auch darüber hinaus gehende API-Zugriffe zur Verfügung die unter Umständen zur Verarbeitung benötigt werden.

            + + Nach der Gerätedefinition ist die Grundeinstellung "Login in das DSM", d.h. es können Credentials mit Admin-Berechtigungen genutzt werden um zunächst alle
            + Funktionen der Kameras testen zu können. Danach können die Credentials z.B. in Abhängigkeit der benötigten Funktionen auf eine SVS-Session mit entsprechend beschränkten Privilegienprofil umgestellt werden.

            + + Die nachfolgende Aufstellung zeigt die Mindestanforderungen der jeweiligen Modulfunktionen an die Nutzerrechte.

            +
              + + + + + + + + + +
            • set ... on
            • session: ServeillanceStation - Betrachter mit erweiterten Privileg "manuelle Aufnahme"
            • set ... off
            • session: ServeillanceStation - Betrachter mit erweiterten Privileg "manuelle Aufnahme"
            • set ... snap
            • session: ServeillanceStation - Betrachter
            • set ... disable
            • session: ServeillanceStation - Manager
            • set ... enable
            • session: ServeillanceStation - Manager
            • set ... credentials
            • -
            • get ... caminfoall
            • session: ServeillanceStation - Betrachter
              +
            +

            + + HTTP-Timeout setzen

            Alle Funktionen dieses Moduls verwenden HTTP-Aufrufe gegenüber der SVS Web API.
            @@ -2394,13 +2643,14 @@ return; Es gibt zur Zeit folgende Optionen für "Set <name> ...":

            - - - - - - - + + + + + + + +
            "on [rectime]": startet eine Aufnahme. Die Aufnahme wird automatisch nach Ablauf der Zeit [rectime] gestoppt.
            Mit rectime = 0 wird eine Daueraufnahme gestartet die durch "set <name> off" wieder gestoppt werden muß.
            "off" : stoppt eine laufende Aufnahme manuell oder durch die Nutzung anderer Events (z.B. über at, notify)
            "snap": löst einen Schnappschuß der entsprechenden Kamera aus und speichert ihn in der Synology Surveillance Station
            "disable": deaktiviert eine Kamera in der Synology Surveillance Station
            "enable": aktiviert eine Kamera in der Synology Surveillance Station
            "on [rectime]": startet eine Aufnahme. Die Aufnahme wird automatisch nach Ablauf der Zeit [rectime] gestoppt.
            Mit rectime = 0 wird eine Daueraufnahme gestartet die durch "set <name> off" wieder gestoppt werden muß.
            "off" : stoppt eine laufende Aufnahme manuell oder durch die Nutzung anderer Events (z.B. über at, notify)
            "snap": löst einen Schnappschuß der entsprechenden Kamera aus und speichert ihn in der Synology Surveillance Station
            "disable": deaktiviert eine Kamera in der Synology Surveillance Station
            "enable": aktiviert eine Kamera in der Synology Surveillance Station
            "credentials <username> <password>": speichert die Zugangsinformationen


            @@ -2477,10 +2727,10 @@ return; Polling der Kameraeigenschaften:

            - Die Abfrage der Kameraeigenschaften erfolgt automatisch, wenn das Attribut "pollcaminfoall" (siehe Attribute) mit einem Wert > 10 gesetzt wird.
            + Die Abfrage der Kameraeigenschaften erfolgt automatisch, wenn das Attribut "pollcaminfoall" (siehe Attribute) mit einem Wert > 10 gesetzt wird.
            Per Default ist das Attribut "pollcaminfoall" nicht gesetzt und das automatische Polling nicht aktiv.
            - Der Wert dieses Attributes legt das Intervall der Abfrage in Sekunden fest. Ist das Attribut nicht gesetzt oder < 10 wird kein automatisches Polling
            - gestartet bzw. gestoppt wenn vorher der Wert > 10 gesetzt war.

            + Der Wert dieses Attributes legt das Intervall der Abfrage in Sekunden fest. Ist das Attribut nicht gesetzt oder < 10 wird kein automatisches Polling
            + gestartet bzw. gestoppt wenn vorher der Wert > 10 gesetzt war.

            Das Attribut "pollcaminfoall" wird durch einen Watchdog-Timer überwacht. Änderungen des Attributwertes werden alle 90 Sekunden ausgewertet und entsprechend umgesetzt.
            Eine Änderung des Pollingstatus / Pollingintervalls wird im FHEM-Logfile protokolliert. Diese Protokollierung kann durch Setzen des Attributes "pollnologging=1" abgeschaltet werden.
            @@ -2489,11 +2739,13 @@ return; Wird FHEM neu gestartet, wird bei aktivierten Polling der ersten Datenabruf innerhalb 60s nach dem Start ausgeführt.

            - Der Status des automatischen Pollings wird durch das Reading "PollState" signalisiert:
            -
            -    PollState = Active     -    automatisches Polling wird mit Intervall entsprechend  ausgeführt
            -    PollState = Inactive   -    automatisches Polling wird nicht ausgeführt
            -  
            + Der Status des automatischen Pollings wird durch das Reading "PollState" signalisiert:

            + +
              +
            • PollState = Active - automatisches Polling wird mit Intervall entsprechend "pollcaminfoall" ausgeführt
            • +
            • PollState = Inactive - automatisches Polling wird nicht ausgeführt
            • +
            +
            Die Bedeutung der Readingwerte ist unter Readings beschrieben.

            @@ -2502,7 +2754,7 @@ return; Wird Polling eingesetzt, sollte das Intervall nur so kurz wie benötigt eingestellt werden da die ermittelten Werte überwiegend statisch sind.
            Das eingestellte Intervall sollte nicht kleiner sein als die Summe aller HTTP-Verarbeitungszeiten. Pro Pollingaufruf und Kamera werden ca. 10 - 20 Http-Calls gegen die Surveillance Station abgesetzt.

            - Bei einem eingestellten HTTP-Timeout (siehe Attribut) "httptimeout") von 4 Sekunden kann die theoretische Verarbeitungszeit Zeit nicht höher als 80 Sekunden betragen.
            + Bei einem eingestellten HTTP-Timeout (siehe Attribut) "httptimeout") von 4 Sekunden kann die theoretische Verarbeitungszeit nicht höher als 80 Sekunden betragen.
            In dem Beispiel sollte man das Pollingintervall mit einem Sicherheitszuschlag auf nicht weniger 160 Sekunden setzen.
            Ein praktikabler Richtwert könnte zwischen 600 - 1800 (s) liegen.
            @@ -2511,6 +2763,24 @@ return; Ein geringfügiger Unterschied zwischen den Pollingintervallen der definierten Kameras von z.B. 1s kann bereits als ausreichend angesehen werden.

          + +Internals
          +
            + Die Bedeutung der verwendeten Internals stellt die nachfolgende Liste dar:

            +
              +
            • CAMID - die ID der Kamera in der SVS, der Wert wird automatisch anhand des SVS-Kameranamens ermittelt.
            • +
            • CAMNAME - der Name der Kamera in der SVS
            • +
            • CREDENTIALS - der Wert ist "Set" wenn die Credentials gesetzt wurden
            • +
            • NAME - der Kameraname in FHEM
            • +
            • OPMODE - die zuletzt ausgeführte Operation des Moduls
            • +
            • SERVERADDR - IP-Adresse des SVS Hostes
            • +
            • SERVERPORT - der SVS-Port
            • + +

              +
            +
          + + Readings
            @@ -2566,6 +2836,8 @@ return;
          • rectime - festgelegte Aufnahmezeit wenn eine Aufnahme gestartet wird. Mit rectime = 0 wird eine Endlosaufnahme gestartet. Ist "rectime" nicht gesetzt, wird der Defaultwert von 15s verwendet.
          • +
          • session - Auswahl der Login-Session. Nicht gesetzt oder "DSM" -> session wird mit DSM aufgebaut (Standard). "SurveillanceStation" -> Session-Aufbau erfolgt mit SVS

          • +
          • verbose

            • @@ -2576,6 +2848,7 @@ return; 0 - Start/Stop-Ereignisse werden geloggt 1 - Fehlermeldungen werden geloggt + 2 - Meldungen über wichtige Ereignisse oder Alarme 3 - gesendete Kommandos werden geloggt 4 - gesendete und empfangene Daten werden geloggt 5 - alle Ausgaben zur Fehleranalyse werden geloggt. ACHTUNG: möglicherweise werden sehr viele Daten in das Logfile geschrieben!