diff --git a/fhem/CHANGED b/fhem/CHANGED index fb714e3ef..e996d62fe 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: command "extevent" added - bugfix: 10_SOMFY: removed "setlist" (obsolete) and updated loglevels - bugfix 49_SSCAM: "uninitialized value $lastrecstarttime", "uninitialized value $lastrecstoptime" diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index eb5b5db69..ebc183056 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -27,6 +27,7 @@ ########################################################################################################## # Versions History: # +# 1.20 09.03.2016 command "extevent" added # 1.19.3 07.03.2016 bugfix "uninitialized value $lastrecstarttime", # "uninitialized value $lastrecstoptime", # new attribute "videofolderMap" @@ -172,7 +173,8 @@ sub SSCam_Define { $hash->{HELPER}{APIAUTH} = "SYNO.API.Auth"; $hash->{HELPER}{APISVSINFO} = "SYNO.SurveillanceStation.Info"; $hash->{HELPER}{APIEVENT} = "SYNO.SurveillanceStation.Event"; - $hash->{HELPER}{APIEXTREC} = "SYNO.SurveillanceStation.ExternalRecording"; + $hash->{HELPER}{APIEXTREC} = "SYNO.SurveillanceStation.ExternalRecording"; + $hash->{HELPER}{APIEXTEVT} = "SYNO.SurveillanceStation.ExternalEvent"; $hash->{HELPER}{APICAM} = "SYNO.SurveillanceStation.Camera"; $hash->{HELPER}{APISNAPSHOT} = "SYNO.SurveillanceStation.SnapShot"; $hash->{HELPER}{APIPTZ} = "SYNO.SurveillanceStation.PTZ"; @@ -272,6 +274,7 @@ sub SSCam_Set { "disable ". "runView:image,link,link_open ". "stopView:noArg ". + "extevent:1,2,3,4,5,6,7,8,9,10 ". ((ReadingsVal("$name", "DeviceType", "Camera") eq "PTZ") ? "runPatrol:".ReadingsVal("$name", "Patrols", "")." " : ""). ((ReadingsVal("$name", "DeviceType", "Camera") eq "PTZ") ? "goPreset:".ReadingsVal("$name", "Presets", "")." " : ""). ((ReadingsVal("$name", "CapPTZAbs", "false")) ? "goAbsPTZ"." " : ""). @@ -416,6 +419,13 @@ sub SSCam_Set { $hash->{HELPER}{WLTYPE} = $prop; runliveview($hash); } + elsif ($opt eq "extevent") + { + if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";} + + $hash->{HELPER}{EVENTID} = $prop; + extevent($hash); + } elsif ($opt eq "stopView") { stopliveview($hash); @@ -840,7 +850,7 @@ sub camstoprec ($) { } ############################################################################### -### Kamera Nightmode setzen +### Kamera Auto / Day / Nightmode setzen sub camexpmode ($) { my ($hash) = @_; @@ -1144,6 +1154,37 @@ sub getsnapfilename ($) { } } + +############################################################################### +### external Event 1-10 auslösen + +sub extevent ($) { + my ($hash) = @_; + my $name = $hash->{NAME}; + my $logstr; + + + if ($hash->{HELPER}{ACTIVE} eq "off") { + + $logstr = "trigger external event \"$hash->{HELPER}{EVENTID}\" "; + &printlog($hash,$logstr,"4"); + + $hash->{OPMODE} = "extevent"; + $hash->{HELPER}{ACTIVE} = "on"; + + if ($attr{$name}{debugactivetoken}) { + $logstr = "Active-Token was set by OPMODE: $hash->{OPMODE}" ; + &printlog($hash,$logstr,"3"); + } + + getapisites_nonbl($hash); + } + else + { + InternalTimer(gettimeofday()+0.24, "extevent", $hash, 0); + } +} + ############################################################################### ### PTZ-Kamera auf Position fahren @@ -1266,7 +1307,7 @@ sub doptzaction ($) { } ############################################################################### -### stoppen continue move +### stoppen continues move sub movestop ($) { my ($hash) = @_; @@ -1655,7 +1696,8 @@ sub getapisites_nonbl { my $apiinfo = $hash->{HELPER}{APIINFO}; # Info-Seite für alle API's, einzige statische Seite ! my $apiauth = $hash->{HELPER}{APIAUTH}; # benötigte API-Pfade für Funktionen, my $apiextrec = $hash->{HELPER}{APIEXTREC}; # in der Abfrage-Url an Parameter "&query=" - my $apicam = $hash->{HELPER}{APICAM}; # mit Komma getrennt angeben + my $apiextevt = $hash->{HELPER}{APIEXTEVT}; # mit Komma getrennt angeben + my $apicam = $hash->{HELPER}{APICAM}; my $apitakesnap = $hash->{HELPER}{APISNAPSHOT}; my $apiptz = $hash->{HELPER}{APIPTZ}; my $apisvsinfo = $hash->{HELPER}{APISVSINFO}; @@ -1678,7 +1720,7 @@ sub getapisites_nonbl { &printlog($hash,$logstr,"5"); # URL zur Abfrage der Eigenschaften der API's - $url = "http://$serveraddr:$serverport/webapi/query.cgi?api=$apiinfo&method=Query&version=1&query=$apiauth,$apiextrec,$apicam,$apitakesnap,$apiptz,$apisvsinfo,$apicamevent,$apievent,$apivideostm"; + $url = "http://$serveraddr:$serverport/webapi/query.cgi?api=$apiinfo&method=Query&version=1&query=$apiauth,$apiextrec,$apicam,$apitakesnap,$apiptz,$apisvsinfo,$apicamevent,$apievent,$apivideostm,$apiextevt"; $logstr = "Call-Out now: $url"; &printlog($hash,$logstr,"4"); @@ -1710,6 +1752,7 @@ sub login_nonbl ($) { my $password = $hash->{HELPER}{PASSWORD}; my $apiauth = $hash->{HELPER}{APIAUTH}; my $apiextrec = $hash->{HELPER}{APIEXTREC}; + my $apiextevt = $hash->{HELPER}{APIEXTEVT}; my $apicam = $hash->{HELPER}{APICAM}; my $apitakesnap = $hash->{HELPER}{APISNAPSHOT}; my $apiptz = $hash->{HELPER}{APIPTZ}; @@ -1735,10 +1778,9 @@ sub login_nonbl ($) { my $apisvsinfomaxver; my $apicameventpath; my $apicameventmaxver; - my $apieventpath; - my $apieventmaxver; - my $apivideostmpath; - my $apivideostmmaxver; + my ($apieventpath,$apieventmaxver); + my ($apivideostmpath,$apivideostmmaxver); + my ($apiextevtpath,$apiextevtmaxver); my $error; my $httptimeout; @@ -1896,6 +1938,18 @@ sub login_nonbl ($) { &printlog($hash, $logstr,"4"); $logstr = defined($apivideostmmaxver) ? "MaxVersion of $apivideostm: $apivideostmmaxver" : "MaxVersion of $apivideostm undefined - Surveillance Station may be stopped"; &printlog($hash, $logstr,"4"); + + # Pfad und Maxversion von "SYNO.SurveillanceStation.ExternalEvent" ermitteln + + $apiextevtpath = $data->{'data'}->{$apiextevt}->{'path'}; + # Unterstriche im Ergebnis z.B. "_______entry.cgi" eleminieren + $apiextevtpath =~ tr/_//d if (defined($apiextevtpath)); + $apiextevtmaxver = $data->{'data'}->{$apiextevt}->{'maxVersion'}; + + $logstr = defined($apiextevtpath) ? "Path of $apiextevt selected: $apiextevtpath" : "Path of $apiextevt undefined - Surveillance Station may be stopped"; + &printlog($hash, $logstr,"4"); + $logstr = defined($apiextevtmaxver) ? "MaxVersion of $apiextevt selected: $apiextevtmaxver" : "MaxVersion of $apiextevt undefined - Surveillance Station may be stopped"; + &printlog($hash, $logstr,"4"); # ermittelte Werte in $hash einfügen $hash->{HELPER}{APIAUTHPATH} = $apiauthpath; @@ -1916,6 +1970,8 @@ sub login_nonbl ($) { $hash->{HELPER}{APIEVENTMAXVER} = $apieventmaxver; $hash->{HELPER}{APIVIDEOSTMPATH} = $apivideostmpath; $hash->{HELPER}{APIVIDEOSTMMAXVER} = $apivideostmmaxver; + $hash->{HELPER}{APIEXTEVTPATH} = $apiextevtpath; + $hash->{HELPER}{APIEXTEVTMAXVER} = $apiextevtmaxver; # Setreading readingsBeginUpdate($hash); @@ -2178,6 +2234,9 @@ sub camop_nonbl ($) { my $apiextrec = $hash->{HELPER}{APIEXTREC}; my $apiextrecpath = $hash->{HELPER}{APIEXTRECPATH}; my $apiextrecmaxver = $hash->{HELPER}{APIEXTRECMAXVER}; + my $apiextevt = $hash->{HELPER}{APIEXTEVT}; + my $apiextevtpath = $hash->{HELPER}{APIEXTEVTPATH}; + my $apiextevtmaxver = $hash->{HELPER}{APIEXTEVTMAXVER}; my $apitakesnap = $hash->{HELPER}{APISNAPSHOT}; my $apitakesnappath = $hash->{HELPER}{APITAKESNAPPATH}; my $apitakesnapmaxver = $hash->{HELPER}{APITAKESNAPMAXVER}; @@ -2437,6 +2496,10 @@ sub camop_nonbl ($) { { $url = "http://$serveraddr:$serverport/webapi/$apicameventpath?api=\"$apicamevent\"&version=\"$apicameventmaxver\"&method=\"MotionEnum\"&camId=\"$camid\"&_sid=\"$sid\""; } + elsif ($OpMode eq "extevent") + { + $url = "http://$serveraddr:$serverport/webapi/$apiextevtpath?api=$apiextevt&version=$apiextevtmaxver&method=Trigger&eventId=$hash->{HELPER}{EVENTID}&eventName=$hash->{HELPER}{EVENTID}&_sid=\"$sid\""; + } elsif ($OpMode eq "runliveview") { # SID nach SID_STRM sichern und nutzen (für stopLiveview-Routine) @@ -3625,6 +3688,7 @@ return;