From c497ff4f0cb5e5fac8cae17df16447b71dbb832d Mon Sep 17 00:00:00 2001 From: nasseeder1 <> Date: Wed, 10 Feb 2016 21:05:50 +0000 Subject: [PATCH] 49_SSCAM: feature for retrieval snapfilename added git-svn-id: https://svn.fhem.de/fhem/trunk@10793 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/49_SSCam.pm | 95 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 85 insertions(+), 11 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 30df74e5a..0974deda5 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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. + - feature: 49_SSCAM: feature for retrieval snapfilename added - bugfix: 57_Calendar: weekly recurring events on several weekdays, missing description - feature: 57_Calendar: RDATE enabled diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index 0a8945cae..8fc4ca988 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -27,6 +27,7 @@ ########################################################################################################## # Versions History: # +# 1.13 feature for retrieval snapfilename added # 1.12.1 09.02.2016 bugfix: "goAbsPTZ" may be unavailable on Windows-systems # 1.12 08.02.2016 added function "move" for continuous PTZ action # 1.11.1 07.02.2016 entries with loglevel "2" reviewed, changed to loglevel "3" @@ -330,7 +331,7 @@ sub SSCam_Set { $hash->{HELPER}{PTZACTION} = "movestart"; doptzaction($hash); - } + } else { return $setlist; @@ -347,6 +348,7 @@ sub SSCam_Get { my %SSCam_gets = ( caminfoall => "caminfoall", svsinfo => "svsinfo", + snapfileinfo => "snapfileinfo", ); my @cList; @@ -363,13 +365,18 @@ sub SSCam_Get { # hier die Verarbeitung starten if ($opt eq "caminfoall") - { - &getcaminfoall($hash); - } - if ($opt eq "svsinfo") - { - &getsvsinfo($hash); - } + { + &getcaminfoall($hash); + } + elsif ($opt eq "svsinfo") + { + &getsvsinfo($hash); + } + elsif ($opt eq "snapfileinfo") + { + if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";} + getsnapfilename($hash); + } } return undef; } @@ -791,10 +798,34 @@ sub camsnap ($) { } else { - InternalTimer(gettimeofday()+0.22, "camsnap", $hash, 0); + InternalTimer(gettimeofday()+0.22, "camsnap", $hash, 0); } } +############################################################################### +### Filename zu Schappschuß ermitteln + +sub getsnapfilename ($) { + my ($hash) = @_; + my $name = $hash->{NAME}; + my $logstr; + my $snapid = ReadingsVal("$name", "LastSnapId", " "); + + if ($hash->{HELPER}{ACTIVE} eq "off") { + # den Filenamen zu einem Schnappschuß ermitteln + $logstr = "Get filename of present Snap-ID $snapid "; + &printlog($hash,$logstr,"4"); + + $hash->{OPMODE} = "getsnapfilename"; + $hash->{HELPER}{ACTIVE} = "on"; + + getapisites_nonbl($hash); + } + else + { + InternalTimer(gettimeofday()+0.22, "getsnapfilename", $hash, 0); + } +} ############################################################################### ### PTZ-Kamera auf Position fahren @@ -1615,6 +1646,7 @@ sub camop_nonbl ($) { my $OpMode = $hash->{OPMODE}; my $url; my $camid; + my $snapid; my $data; my $logstr; my $success; @@ -1761,6 +1793,12 @@ sub camop_nonbl ($) { readingsSingleUpdate($hash,"state", "snap", 0); readingsSingleUpdate($hash, "LastSnapId", "", 1); } + elsif ($OpMode eq "getsnapfilename") + { + # der Filename der aktuellen Schnappschuß-ID wird ermittelt + $snapid = ReadingsVal("$name", "LastSnapId", " "); + $url = "http://$serveraddr:$serverport/webapi/$apitakesnappath?api=\"$apitakesnap\"&method=\"List\"&version=\"$apitakesnapmaxver\"&imgSize=\"0\"&idList=\"$snapid\"&_sid=\"$sid\""; + } elsif ($OpMode eq "gopreset") { # mal wieder Maxversion der API funktioniert nicht ! Ticket bei Syno @@ -2005,6 +2043,24 @@ sub camret_nonbl ($) { $logstr = "--- End Function cam: $OpMode nonblocking ---"; &printlog($hash,$logstr,"4"); } + elsif ($OpMode eq "getsnapfilename") + { + # den Filenamen eines Schnapschusses ermitteln + $snapid = ReadingsVal("$name", "LastSnapId", " "); + + # Setreading + readingsBeginUpdate($hash); + readingsBulkUpdate($hash,"Errorcode","none"); + readingsBulkUpdate($hash,"Error","none"); + readingsBulkUpdate($hash,"LastSnapFilename", $data->{'data'}{'data'}[0]{'fileName'}); + readingsEndUpdate($hash, 1); + + # Logausgabe + $logstr = "Filename of Snap-ID $snapid is \"$data->{'data'}{'data'}[0]{'fileName'}\" "; + &printlog($hash,$logstr,"4"); + $logstr = "--- End Function cam: $OpMode nonblocking ---"; + &printlog($hash,$logstr,"4"); + } elsif ($OpMode eq "gopreset") { # eine Presetposition wurde angefahren @@ -2546,6 +2602,7 @@ sub logout_nonbl ($) { my $hash = $param->{hash}; my $sid = $hash->{HELPER}{SID}; my ($success, $username) = getcredentials($hash,0); + my $OpMode = $hash->{OPMODE}; my $data; my $logstr; my $error; @@ -2615,6 +2672,12 @@ sub logout_nonbl ($) { # ausgeführte Funktion ist erledigt (auch wenn logout nicht erfolgreich), Freigabe Funktionstoken $hash->{HELPER}{ACTIVE} = "off"; +# nach Snap Aufnahme Filename des Snaps ermitteln +if ($OpMode eq "Snap") { + return (getsnapfilename($hash)); + } + + return; } @@ -2871,6 +2934,7 @@ return;
  • set ... credentials -
  • get ... caminfoall session: ServeillanceStation - observer
  • get ... svsinfo session: ServeillanceStation - observer
  • +
  • get ... snapfileinfo session: ServeillanceStation - observer


  • @@ -2943,7 +3007,7 @@ return; define he1_snap_2 notify MelderHE1:on.* define h2 at +*{2}00:00:06 set CamHE1 snap - The ID of the last snapshot will be displayed as value of variable "LastSnapId" in the device-Readings.

    + The ID and the filename of the last snapshot will be displayed as value of variable "LastSnapId" respectively "LastSnapFilename" in the device-Readings.

    "set <name> [enable] [disable]"

    @@ -3073,11 +3137,13 @@ return;
           get <name> caminfoall
           get <name> svsinfo
    +      get <name> snapfileinfo
       
    With command "get <name> caminfoall" dependend of the type of Camera (e.g. Fix- or PTZ-Camera) the available properties will be retrieved and provided as Readings.
    For example the Reading "Availability" will be set to "disconnected" if the Camera would be disconnected from Synology Surveillance Station and can be used for further processing like creating events.
    + Using "get <name> snapfileinfo" the filename of the last snapshot will be retrieved. This command will be executed with "get <name> snap" automatically.
    The command "get <name> svsinfo" is not really dependend on a camera, but rather a command to determine common informations about the installed SVS-version and other properties.
    The functions "caminfoall" and "svsinfo" will be executed automatically once-only after FHEM restarts to collect some relevant informations for camera control.
    Please consider to save the credentials what will be used for login to DSM or SVS ! @@ -3172,6 +3238,8 @@ return;
  • DeviceType
  • - device type (Camera, Video_Server, PTZ, Fisheye)
  • Error
  • - message text of last error
  • Errorcode
  • - error code of last error +
  • LastSnapFilename
  • - the filename of the last snapshot +
  • LastSnapId
  • - the ID of the last snapshot
  • LastUpdateTime
  • - date / time of last update of Camera in Synology Surrveillance Station
  • Patrols
  • - in Synology Surveillance Station predefined patrols (at PTZ-Cameras)
  • PollState
  • - shows the state of automatic polling @@ -3355,6 +3423,7 @@ return;
  • set ... credentials -
  • get ... caminfoall session: ServeillanceStation - Betrachter
  • get ... svsinfo session: ServeillanceStation - Betrachter
  • +
  • get ... snapfileinfo session: ServeillanceStation - Betrachter


  • @@ -3428,7 +3497,7 @@ return; define he1_snap_2 notify MelderHE1:on.* define h2 at +*{2}00:00:06 set CamHE1 snap - Es wird die ID des letzten Snapshots als Wert der Variable "LastSnapId" in den Readings der Kamera ausgegeben.

    + Es wird die ID und der Filename des letzten Snapshots als Wert der Variable "LastSnapId" bzw. "LastSnapFilename" in den Readings der Kamera ausgegeben.

    "set <name> [enable] [disable]"

    @@ -3556,11 +3625,13 @@ return;
           get <name> caminfoall
           get <name> svsinfo
    +      get <name> snapfileinfo
       
    Mit dem Befehl "get <name> caminfoall" werden abhängig von der Art der Kamera (z.B. Fix- oder PTZ-Kamera) die verfügbaren Eigenschaften ermittelt und als Readings zur Verfügung gestellt.
    So wird zum Beispiel das Reading "Availability" auf "disconnected" gesetzt falls die Kamera von der Surveillance Station getrennt wird und kann für weitere
    Verarbeitungen genutzt werden.
    + Mit "get <name> snapfileinfo" wird der Filename des letzten Schnapschusses ermittelt. Der Befehl wird implizit mit "get <name> snap" ausgeführt.
    Der Befehl "get <name> svsinfo" ist eigentlich nicht von der Kamera abhängig, sondern ermittelt vielmehr allgemeine Informationen zur installierten SVS-Version und andere Eigenschaften.
    Die Funktionen "caminfoall" und "svsinfo" werden einmalig automatisch beim Start von FHEM ausgeführt um steuerungsrelevante Informationen zu sammeln.
    Es ist darauf zu achten dass die Credentials gespeichert wurden ! @@ -3657,6 +3728,8 @@ return;
  • DeviceType
  • - Kameratyp (Camera, Video_Server, PTZ, Fisheye)
  • Error
  • - Meldungstext des letzten Fehlers
  • Errorcode
  • - Fehlercode des letzten Fehlers +
  • LastSnapFilename
  • - der Filename des letzten Schnapschusses +
  • LastSnapId
  • - die ID des letzten Schnapschusses
  • LastUpdateTime
  • - Datum / Zeit der letzten Aktualisierung der Kamera in der Synology Surveillance Station
  • Patrols
  • - in Surveillance Station voreingestellte Überwachungstouren (bei PTZ-Kameras)
  • PollState
  • - zeigt den Status des automatischen Pollings an