diff --git a/CHANGED b/CHANGED index 01ad20428..68e221fc9 100644 --- a/CHANGED +++ b/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: function "snap" for taking snapshots added, + - bugfix: 49_SSCam: fixed a bug that functions may impact each other - feature: 31_MilightDevice: Add restoreAtStart attribute so group devices (slot 'A') do not restore state by default at startup - bugfix: 30_MilightBridge/31_MilightDevice: Fix startup restore. Fix crash on invalid hostname. - feature: 30_pilight_xyz: possibility to change IO-Device (IODEV) diff --git a/FHEM/49_SSCam.pm b/FHEM/49_SSCam.pm index 9b90ea2d9..e40865775 100644 --- a/FHEM/49_SSCam.pm +++ b/FHEM/49_SSCam.pm @@ -4,7 +4,7 @@ # Copyright by Heiko Maaz # e-mail: Heiko dot Maaz at t-online dot de # -# This Modul is used to manage Cameras defined in Synology Surveillance Station 7.0 or higher +# This Modul is used to operate Cameras defined in Synology Surveillance Station 7.0 or higher # It's based on Synology Surveillance Station API Guide 2.0 # # This file is part of fhem. @@ -25,6 +25,8 @@ ###################################################################################################### # Versionshistorie: # +# 1.3 19.12.2015 function "snap" for taking snapshots added, +# fixed a bug that functions may impact each other # 1.2 14.12.2015 improve usage of verbose-modes # 1.1 13.12.2015 use of InternalTimer instead of fhem(sleep) # 1.0 12.12.2015 changed completly to HttpUtils_NonblockingGet for calling websites nonblocking, @@ -54,9 +56,7 @@ use warnings; use HttpUtils; -sub -SSCam_Initialize($) -{ +sub SSCam_Initialize($) { # die Namen der Funktionen, die das Modul implementiert und die fhem.pl aufrufen soll my ($hash) = @_; $hash->{DefFn} = "SSCam_Define"; @@ -68,7 +68,7 @@ SSCam_Initialize($) $hash->{AttrList} = "webCmd ". $readingFnAttributes; - + } sub SSCam_Define { @@ -105,11 +105,16 @@ sub SSCam_Define { $hash->{RECTIME} = $rectime; # benötigte API's in $hash einfügen - $hash->{HELPER}{APIINFO} = "SYNO.API.Info"; # Info-Seite für alle API's, einzige statische Seite ! - $hash->{HELPER}{APIAUTH} = "SYNO.API.Auth"; - $hash->{HELPER}{APIEXTREC} = "SYNO.SurveillanceStation.ExternalRecording"; - $hash->{HELPER}{APICAM} = "SYNO.SurveillanceStation.Camera"; - + $hash->{HELPER}{APIINFO} = "SYNO.API.Info"; # Info-Seite für alle API's, einzige statische Seite ! + $hash->{HELPER}{APIAUTH} = "SYNO.API.Auth"; + $hash->{HELPER}{APIEXTREC} = "SYNO.SurveillanceStation.ExternalRecording"; + $hash->{HELPER}{APICAM} = "SYNO.SurveillanceStation.Camera"; + $hash->{HELPER}{APISNAPSHOT} = "SYNO.SurveillanceStation.SnapShot"; + + # Anfangswerte setzen + $hash->{HELPER}{ACTIVE} = "off"; + readingsSingleUpdate($hash,"Record","Stop",0); + return undef; } @@ -126,64 +131,149 @@ sub SSCam_Attr { sub SSCam_Set { my ( $hash, @a ) = @_; return "\"set X\" needs at least an argument" if ( @a < 2 ); - my $device = shift @a; + my $name = shift @a; my $opt = shift @a; my %SSCam_sets = ( - on => "on", - off => "off"); - my $camname = $hash->{CAMNAME}; + on => "on", + off => "off", + snap => "snap" + ); + + my $camname = $hash->{CAMNAME}; my $logstr; my @cList; # ist die angegebene Option verfügbar ? - if(!defined($SSCam_sets{$opt})) { - @cList = keys %SSCam_sets; - return "Unknown argument $opt, choose one of " . join(" ", @cList); - } else { - - # Aufnahme starten - if ($opt eq "on") - { - $logstr = "Recording of Camera $camname should be started now"; - &printlog($hash,$logstr,"4"); - - $hash->{OPMODE} = "Start"; - &getapisites_nonbl($hash); - } - - - # Aufnahme stoppen - if ($opt eq "off") - { - $logstr = "Recording of Camera $camname should be stopped now"; - &printlog($hash,$logstr,"4"); - - $hash->{OPMODE} = "Stop"; - &getapisites_nonbl($hash); - } + if(!defined($SSCam_sets{$opt})) + { + @cList = keys %SSCam_sets; + return "Unknown argument $opt, choose one of " . join(" ", @cList); + } + else + { + if ($opt eq "on") + { + &camstartrec($hash); + } + elsif ($opt eq "off") + { + &camstoprec($hash); + } + elsif ($opt eq "snap") + { + &camsnap($hash); + } } } +############################################################################################################################# +######### OpMode-Startroutinen ############# +######### ############# +######### $hash->{HELPER}{ACTIVE} = "on" -> eine Routine läuft, Start anderer Routine erst wenn "off". ############# +######### $hash->{HELPER}{ACTIVE} = "off" -> keine andere Routine läuft, sofortiger Start möglich ############# +############################################################################################################################# + +############################################################################### +### Kamera Aufnahme starten + +sub camstartrec ($) { + my ($hash) = @_; + my $camname = $hash->{CAMNAME}; + my $name = $hash->{NAME}; + my $logstr; + + if ($hash->{HELPER}{ACTIVE} ne "on" and ReadingsVal("$name", "Record", "Start") ne "Start") { + # Aufnahme starten + $logstr = "Recording of Camera $camname should be started now"; + &printlog($hash,$logstr,"4"); + + $hash->{OPMODE} = "Start"; + $hash->{HELPER}{ACTIVE} = "on"; + + &getapisites_nonbl($hash); + } + else + { + InternalTimer(gettimeofday()+0.1, "camstartrec", $hash, 0); + } +} + +############################################################################### +### Kamera Aufnahme stoppen + +sub camstoprec ($) { + my ($hash) = @_; + my $camname = $hash->{CAMNAME}; + my $name = $hash->{NAME}; + my $logstr; + + if ($hash->{HELPER}{ACTIVE} ne "on" and ReadingsVal("$name", "Record", "Stop") ne "Stop") { + # Aufnahme stoppen + $logstr = "Recording of Camera $camname should be stopped now"; + &printlog($hash,$logstr,"4"); + + $hash->{OPMODE} = "Stop"; + $hash->{HELPER}{ACTIVE} = "on"; + + &getapisites_nonbl($hash); + } + else + { + InternalTimer(gettimeofday()+0.1, "camstoprec", $hash, 0); + } +} + +############################################################################### +### Kamera Schappschuß aufnehmen + +sub camsnap ($) { + my ($hash) = @_; + my $camname = $hash->{CAMNAME}; + my $name = $hash->{NAME}; + my $logstr; + + if ($hash->{HELPER}{ACTIVE} ne "on") { + # einen Schnappschuß aufnehmen + $logstr = "Take Snapshot of Camera $camname"; + &printlog($hash,$logstr,"4"); + + $hash->{OPMODE} = "Snap"; + $hash->{HELPER}{ACTIVE} = "on"; + + &getapisites_nonbl($hash); + } + else + { + InternalTimer(gettimeofday()+0.1, "camsnap", $hash, 0); + } +} + + + ############################################################################################################################# ####### Begin Kameraoperationen mit NonblockingGet (nicht blockierender HTTP-Call) ####### ####### ####### ####### Ablauflogik: ####### ####### ####### +####### ####### +####### OpMode-Startroutine ####### +####### | ####### ####### getapisites_nonbl -> login_nonbl -> getcamid_nonbl -> camop_nonbl -> camret_nonbl -> logout_nonbl ####### -####### | | ####### -####### Start Stop ####### +####### | ####### +####### OpMode ####### ####### ####### ############################################################################################################################# sub getapisites_nonbl { my ($hash) = @_; - my $servername = $hash->{SERVERNAME}; - my $serverport = $hash->{SERVERPORT}; - 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 $servername = $hash->{SERVERNAME}; + my $serverport = $hash->{SERVERPORT}; + 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 $apitakesnap = $hash->{HELPER}{APISNAPSHOT}; my $logstr; my $url; my $param; @@ -194,7 +284,7 @@ sub getapisites_nonbl { &printlog($hash,$logstr,"4"); # URL zur Abfrage der Eigenschaften von API SYNO.SurveillanceStation.ExternalRecording,$apicam - $url = "http://$servername:$serverport/webapi/query.cgi?api=$apiinfo&method=Query&version=1&query=$apiauth,$apiextrec,$apicam"; + $url = "http://$servername:$serverport/webapi/query.cgi?api=$apiinfo&method=Query&version=1&query=$apiauth,$apiextrec,$apicam,$apitakesnap"; $param = { url => $url, @@ -216,15 +306,16 @@ sub getapisites_nonbl { sub login_nonbl ($) { my ($param, $err, $myjson) = @_; - my $hash = $param->{hash}; - my $device = $hash->{NAME}; - my $servername = $hash->{SERVERNAME}; - my $serverport = $hash->{SERVERPORT}; - my $username = $hash->{USERNAME}; - my $password = $hash->{HELPER}{PASSWORD}; - my $apiauth = $hash->{HELPER}{APIAUTH}; - my $apiextrec = $hash->{HELPER}{APIEXTREC}; - my $apicam = $hash->{HELPER}{APICAM}; + my $hash = $param->{hash}; + my $device = $hash->{NAME}; + my $servername = $hash->{SERVERNAME}; + my $serverport = $hash->{SERVERPORT}; + my $username = $hash->{USERNAME}; + my $password = $hash->{HELPER}{PASSWORD}; + my $apiauth = $hash->{HELPER}{APIAUTH}; + my $apiextrec = $hash->{HELPER}{APIEXTREC}; + my $apicam = $hash->{HELPER}{APICAM}; + my $apitakesnap = $hash->{HELPER}{APISNAPSHOT}; my $data; my $logstr; my $url; @@ -235,6 +326,8 @@ sub login_nonbl ($) { my $apiextrecmaxver; my $apicampath; my $apicammaxver; + my $apitakesnappath; + my $apitakesnapmaxver; my $error; # Verarbeitung der asynchronen Rückkehrdaten aus sub "getapisites_nonbl" @@ -269,92 +362,100 @@ sub login_nonbl ($) { $logstr = "JSON returned: ". Dumper $data; &printlog($hash,$logstr,"4"); - # Pfad und Maxversion von "SYNO.API.Auth" ermitteln + # Pfad und Maxversion von "SYNO.API.Auth" ermitteln - $apiauthpath = $data->{'data'}->{$apiauth}->{'path'}; - # Unterstriche im Ergebnis z.B. "_______entry.cgi" eleminieren - $apiauthpath =~ tr/_//d; + $apiauthpath = $data->{'data'}->{$apiauth}->{'path'}; + # Unterstriche im Ergebnis z.B. "_______entry.cgi" eleminieren + $apiauthpath =~ tr/_//d; + $apiauthmaxver = $data->{'data'}->{$apiauth}->{'maxVersion'}; - # maximale Version ermitteln - $apiauthmaxver = $data->{'data'}->{$apiauth}->{'maxVersion'}; + $logstr = "Path of $apiauth selected: $apiauthpath"; + &printlog($hash, $logstr,"4"); + $logstr = "MaxVersion of $apiauth selected: $apiauthmaxver"; + &printlog($hash, $logstr,"4"); - $logstr = "Path of $apiauth selected: $apiauthpath"; - &printlog($hash, $logstr,"4"); - $logstr = "MaxVersion of $apiauth selected: $apiauthmaxver"; - &printlog($hash, $logstr,"4"); + # Pfad und Maxversion von "SYNO.SurveillanceStation.ExternalRecording" ermitteln - # Pfad und Maxversion von "SYNO.SurveillanceStation.ExternalRecording" ermitteln + $apiextrecpath = $data->{'data'}->{$apiextrec}->{'path'}; + # Unterstriche im Ergebnis z.B. "_______entry.cgi" eleminieren + $apiextrecpath =~ tr/_//d; + $apiextrecmaxver = $data->{'data'}->{$apiextrec}->{'maxVersion'}; - $apiextrecpath = $data->{'data'}->{$apiextrec}->{'path'}; - # Unterstriche im Ergebnis z.B. "_______entry.cgi" eleminieren - $apiextrecpath =~ tr/_//d; + $logstr = "Path of $apiextrec selected: $apiextrecpath"; + &printlog($hash, $logstr,"4"); + $logstr = "MaxVersion of $apiextrec selected: $apiextrecmaxver"; + &printlog($hash, $logstr,"4"); - # maximale Version ermitteln - $apiextrecmaxver = $data->{'data'}->{$apiextrec}->{'maxVersion'}; + # Pfad und Maxversion von "SYNO.SurveillanceStation.Camera" ermitteln + + $apicampath = $data->{'data'}->{$apicam}->{'path'}; + # Unterstriche im Ergebnis z.B. "_______entry.cgi" eleminieren + $apicampath =~ tr/_//d; + $apicammaxver = $data->{'data'}->{$apicam}->{'maxVersion'}; + # um 1 verringern - Fehlerprävention + if (defined $apicammaxver) {$apicammaxver -= 1}; - $logstr = "Path of $apiextrec selected: $apiextrecpath"; - &printlog($hash, $logstr,"4"); - $logstr = "MaxVersion of $apiextrec selected: $apiextrecmaxver"; - &printlog($hash, $logstr,"4"); + $logstr = "Path of $apicam selected: $apicampath"; + &printlog($hash, $logstr,"4"); + $logstr = "MaxVersion of $apicam (optimized): $apicammaxver"; + &printlog($hash, $logstr,"4"); - # Pfad und Maxversion von "SYNO.SurveillanceStation.Camera" ermitteln - $apicampath = $data->{'data'}->{$apicam}->{'path'}; - # Unterstriche im Ergebnis z.B. "_______entry.cgi" eleminieren - $apicampath =~ tr/_//d; - - # maximale Version ermitteln - $apicammaxver = $data->{'data'}->{$apicam}->{'maxVersion'}; - # um 1 verringern - Fehlerprävention - if (defined $apicammaxver) {$apicammaxver -= 1}; - - $logstr = "Path of $apicam selected: $apicampath"; - &printlog($hash, $logstr,"4"); - $logstr = "MaxVersion of $apicam (optimized): $apicammaxver"; - &printlog($hash, $logstr,"4"); - - # ermittelte Werte in $hash einfügen - $hash->{HELPER}{APIAUTHPATH} = $apiauthpath; - $hash->{HELPER}{APIAUTHMAXVER} = $apiauthmaxver; - $hash->{HELPER}{APIEXTRECPATH} = $apiextrecpath; - $hash->{HELPER}{APIEXTRECMAXVER} = $apiextrecmaxver; - $hash->{HELPER}{APICAMPATH} = $apicampath; - $hash->{HELPER}{APICAMMAXVER} = $apicammaxver; - - - # Setreading - readingsBeginUpdate($hash); - readingsBulkUpdate($hash,"Errorcode","none"); - readingsBulkUpdate($hash,"Error","none"); - readingsEndUpdate($hash,1); - - # Logausgabe - $logstr = "--- End Function getapisites nonblocking ---"; - &printlog($hash,$logstr,"4"); - - } - else - { - - # Fehlertext setzen - $error = "couldn't call API-Infosite"; - - # Setreading - readingsBeginUpdate($hash); - readingsBulkUpdate($hash,"Errorcode","none"); - readingsBulkUpdate($hash,"Error",$error); - readingsEndUpdate($hash, 1); + # Pfad und Maxversion von "SYNO.SurveillanceStation.SnapShot" ermitteln + + $apitakesnappath = $data->{'data'}->{$apitakesnap}->{'path'}; + # Unterstriche im Ergebnis z.B. "_______entry.cgi" eleminieren + $apitakesnappath =~ tr/_//d; + $apitakesnapmaxver = $data->{'data'}->{$apitakesnap}->{'maxVersion'}; + + $logstr = "Path of $apitakesnap selected: $apitakesnappath"; + &printlog($hash, $logstr,"4"); + $logstr = "MaxVersion of $apitakesnap: $apitakesnapmaxver"; + &printlog($hash, $logstr,"4"); - # Logausgabe - $logstr = "ERROR - the API-Query couldn't be executed successfully"; - &printlog($hash,$logstr,"1"); - - $logstr = "--- End Function getapisites nonblocking with error ---"; - &printlog($hash,$logstr,"4"); - return; - } - - + + # ermittelte Werte in $hash einfügen + $hash->{HELPER}{APIAUTHPATH} = $apiauthpath; + $hash->{HELPER}{APIAUTHMAXVER} = $apiauthmaxver; + $hash->{HELPER}{APIEXTRECPATH} = $apiextrecpath; + $hash->{HELPER}{APIEXTRECMAXVER} = $apiextrecmaxver; + $hash->{HELPER}{APICAMPATH} = $apicampath; + $hash->{HELPER}{APICAMMAXVER} = $apicammaxver; + $hash->{HELPER}{APITAKESNAPPATH} = $apitakesnappath; + $hash->{HELPER}{APITAKESNAPMAXVER} = $apitakesnapmaxver; + + + # Setreading + readingsBeginUpdate($hash); + readingsBulkUpdate($hash,"Errorcode","none"); + readingsBulkUpdate($hash,"Error","none"); + readingsEndUpdate($hash,1); + # Logausgabe + $logstr = "--- End Function getapisites nonblocking ---"; + &printlog($hash,$logstr,"4"); + } + else + { + # ausgeführte Funktion ist erledigt + $hash->{HELPER}{ACTIVE} = "off"; + + # Fehlertext setzen + $error = "couldn't call API-Infosite"; + + # Setreading + readingsBeginUpdate($hash); + readingsBulkUpdate($hash,"Errorcode","none"); + readingsBulkUpdate($hash,"Error",$error); + readingsEndUpdate($hash, 1); + + # Logausgabe + $logstr = "ERROR - the API-Query couldn't be executed successfully"; + &printlog($hash,$logstr,"1"); + + $logstr = "--- End Function getapisites nonblocking with error ---"; + &printlog($hash,$logstr,"4"); + return; + } } # Login und SID ermitteln @@ -455,6 +556,9 @@ sub getcamid_nonbl ($) { } else { + # ausgeführte Funktion ist erledigt + $hash->{HELPER}{ACTIVE} = "off"; + # Errorcode aus JSON ermitteln $errorcode = $data->{'error'}->{'code'}; @@ -507,15 +611,18 @@ sub getcamid_nonbl ($) { sub camop_nonbl ($) { my ($param, $err, $myjson) = @_; - my $hash = $param->{hash}; - my $servername = $hash->{SERVERNAME}; - my $serverport = $hash->{SERVERPORT}; - my $camname = $hash->{CAMNAME}; - my $apiextrec = $hash->{HELPER}{APIEXTREC}; - my $apiextrecpath = $hash->{HELPER}{APIEXTRECPATH}; - my $apiextrecmaxver = $hash->{HELPER}{APIEXTRECMAXVER}; - my $sid = $hash->{HELPER}{SID}; - my $OpMode = $hash->{OPMODE}; + my $hash = $param->{hash}; + my $servername = $hash->{SERVERNAME}; + my $serverport = $hash->{SERVERPORT}; + my $camname = $hash->{CAMNAME}; + my $apiextrec = $hash->{HELPER}{APIEXTREC}; + my $apiextrecpath = $hash->{HELPER}{APIEXTRECPATH}; + my $apiextrecmaxver = $hash->{HELPER}{APIEXTRECMAXVER}; + my $apitakesnap = $hash->{HELPER}{APISNAPSHOT}; + my $apitakesnappath = $hash->{HELPER}{APITAKESNAPPATH}; + my $apitakesnapmaxver = $hash->{HELPER}{APITAKESNAPMAXVER}; + my $sid = $hash->{HELPER}{SID}; + my $OpMode = $hash->{OPMODE}; my $url; my $camid; my $data; @@ -607,6 +714,9 @@ sub camop_nonbl ($) { else { # die Abfrage konnte nicht ausgeführt werden + # ausgeführte Funktion ist erledigt + $hash->{HELPER}{ACTIVE} = "off"; + # Errorcode aus JSON ermitteln $errorcode = $data->{'error'}->{'code'}; @@ -641,6 +751,11 @@ sub camop_nonbl ($) { # die Aufnahme wird gestoppt, Rückkehr wird mit "camret_nonbl" verarbeitet $url = "http://$servername:$serverport/webapi/$apiextrecpath?api=$apiextrec&method=Record&version=$apiextrecmaxver&cameraId=$camid&action=stop&session=SurveillanceStation&_sid=\"$sid\""; } + elsif ($OpMode eq "Snap") + { + # ein Schnappschuß wird gemacht und in SS gespeichert, Rückkehr wird mit "camret_nonbl" verarbeitet + $url = "http://$servername:$serverport/webapi/$apitakesnappath?api=\"$apitakesnap\"&dsId=0&method=\"TakeSnapshot\"&version=\"$apitakesnapmaxver\"&camId=$camid&blSave=true&_sid=\"$sid\""; + } $param = { url => $url, @@ -681,6 +796,7 @@ sub camret_nonbl ($) { my $success; my $error; my $errorcode; + my $snapid; # Verarbeitung der asynchronen Rückkehrdaten aus sub "camop_nonbl" if ($err ne "") # wenn ein Fehler bei der HTTP Abfrage aufgetreten ist @@ -717,6 +833,7 @@ sub camret_nonbl ($) { if ($OpMode eq "Start") { + # bedingt Browseraktualisierung und Status der "Lampen" $hash->{STATE} = "on"; # Setreading @@ -725,30 +842,25 @@ sub camret_nonbl ($) { readingsBulkUpdate($hash,"Errorcode","none"); readingsBulkUpdate($hash,"Error","none"); readingsEndUpdate($hash, 1); - + # Logausgabe $logstr = "Camera $camname with Recordtime $rectime"."s started"; &printlog($hash,$logstr,"3"); $logstr = "--- End Function cam: $OpMode nonblocking ---"; &printlog($hash,$logstr,"4"); - # Generiert das Ereignis "on", bedingt Browseraktualisierung und Status der "Lampen" wenn kein longpoll=1 - # { fhem "trigger $device on" } - # Logausgabe $logstr = "Time for Recording is set to: $rectime"; &printlog($hash,$logstr,"4"); - # Stop der Aufnahme wird eingeleitet - $logstr = "Recording of Camera $camname should be stopped in $rectime seconds"; - &printlog($hash,$logstr,"4"); - $hash->{OPMODE} = "Stop"; - InternalTimer(gettimeofday()+$rectime, "getapisites_nonbl", $hash, 0); + # Stop der Aufnahme nach Ablauf $rectime + InternalTimer(gettimeofday()+$rectime, "camstoprec", $hash, 0); } elsif ($OpMode eq "Stop") { + # bedingt Browseraktualisierung und Status der "Lampen" $hash->{STATE} = "off"; # Setreading @@ -769,6 +881,25 @@ sub camret_nonbl ($) { $logstr = "--- End Function cam: $OpMode nonblocking ---"; &printlog($hash,$logstr,"4"); } + elsif ($OpMode eq "Snap") + { + # ein Schnapschuß wurde aufgenommen + + $snapid = $data->{data}{'id'}; + + # Setreading + readingsBeginUpdate($hash); + readingsBulkUpdate($hash,"Errorcode","none"); + readingsBulkUpdate($hash,"Error","none"); + readingsBulkUpdate($hash,"LastSnapId",$snapid); + readingsEndUpdate($hash, 1); + + # Logausgabe + $logstr = "Snapshot of Camera $camname has been done successfully"; + &printlog($hash,$logstr,"3"); + $logstr = "--- End Function cam: $OpMode nonblocking ---"; + &printlog($hash,$logstr,"4"); + } } else { @@ -790,6 +921,10 @@ sub camret_nonbl ($) { &printlog($hash,$logstr,"1"); $logstr = "--- End Function cam: $OpMode nonblocking with error ---"; &printlog($hash,$logstr,"4"); + + # ausgeführte Funktion ist erledigt + $hash->{HELPER}{ACTIVE} = "off"; + return; } @@ -829,7 +964,9 @@ sub logout_nonbl ($) { my $error; my $errorcode; - # Verarbeitung der asynchronen Rückkehrdaten aus sub "camop_nonbl" + # ausgeführte Funktion ist erledigt + $hash->{HELPER}{ACTIVE} = "off"; + if($err ne "") # wenn ein Fehler bei der HTTP Abfrage aufgetreten ist { $logstr = "error while requesting ".$param->{url}." - $err"; @@ -843,7 +980,7 @@ sub logout_nonbl ($) { { $logstr = "URL-Call: ".$param->{url}; &printlog($hash,$logstr,"4"); - + # An dieser Stelle die Antwort parsen / verarbeiten mit $myjson # Evaluiere ob Daten im JSON-Format empfangen wurden @@ -984,7 +1121,7 @@ sub experror { 414 => "Some events not exist", 415 => "message connect failed", 417 => "Test Connection Error", - 418 => "Object is not exist / The VisualStation ID does not exist", + 418 => "Object is not exist", 419 => "Visualstation name repetition", 439 => "Too many items selected", ); @@ -1017,36 +1154,44 @@ return;

SSCam