From 92056a5df10a5005d8d5ff0e928f9146d75b4eac Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Mon, 15 Aug 2016 19:14:35 +0000 Subject: [PATCH] 49_SSCam: commandref revised, more v4 logging in special case git-svn-id: https://svn.fhem.de/fhem/trunk@11975 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/49_SSCam.pm | 48 ++++++++++++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 2d1a38dba..a9a7d8aab 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. + - changed: 49_SSCam: commandref revised, more v4 logging in special case - updated: 74_AMAD: New Version 2.6.1 support for more Mediaplayer Readings new error handling for "send data to AMADCommBridge Flow" - change: 38_netatmo: status "no data" diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index 79b10cf10..eda5ca8fb 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -27,6 +27,7 @@ ########################################################################################################## # Versions History: # +# 1.30 15.08.2016 commandref revised, more v4 logging in special case # 1.29 02.07.2016 add regex for adaption SVS version, url call for "snap" changed # 1.28 30.06.2016 Attr "showPassInLog" added, per default no password will be shown in log # 1.27 29.06.2016 Attr "simu_SVSversion" added, sub login_nonbl changed, @@ -132,7 +133,7 @@ package main; -use JSON qw( decode_json ); # from CPAN, Debian: apt-get install libperl-JSON +use JSON qw( decode_json ); # from CPAN, Debian: apt-get install libjson-perl use Data::Dumper; # Perl Core module use strict; use warnings; @@ -2177,18 +2178,21 @@ sub login_nonbl ($) { Log3($name, 5, "$name - HTTP-Call will be done with httptimeout-Value: $httptimeout s"); my $url; + my $urlwopw; # nur zur Anzeige bei verbose >=4 und "showPassInLog" == 0 my $apiauthpath = $hash->{HELPER}{APIAUTHPATH}; my $apiauthmaxver = $hash->{HELPER}{APIAUTHMAXVER}; if (defined($attr{$name}{session}) and $attr{$name}{session} eq "SurveillanceStation") { $url = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=$password&session=SurveillanceStation&format=\"sid\""; + $urlwopw = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=*****&session=SurveillanceStation&format=\"sid\""; } else { $url = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=$password&format=\"sid\""; + $urlwopw = "http://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=*****&format=\"sid\""; } - Log3($name, 4, "$name - Call-Out now: $url"); + AttrVal($name, "showPassInLog", "0") == 1 ? Log3($name, 4, "$name - Call-Out now: $url") : Log3($name, 4, "$name - Call-Out now: $urlwopw"); $param = { url => $url, @@ -2198,8 +2202,6 @@ sub login_nonbl ($) { header => "Accept: application/json", callback => \&getcamid_nonbl }; - - # login wird ausgeführt, $sid ermittelt und mit Routine "getcamid_nonbl" verarbeitet HttpUtils_NonblockingGet ($param); } @@ -2260,16 +2262,18 @@ sub getcamid_nonbl ($) { return; } + Log3($name, 5, "$name - Data returned: ".$myjson); + $data = decode_json($myjson); + + # Logausgabe decodierte JSON Daten + Log3($name, 4, "$name - JSON decoded: ". Dumper $data); $success = $data->{'success'}; # login war erfolgreich if ($success) - { - # Logausgabe decodierte JSON Daten - Log3($name, 4, "$name - JSON returned: ". Dumper $data); - + { $sid = $data->{'data'}->{'sid'}; # Session ID in hash eintragen @@ -2286,7 +2290,7 @@ sub getcamid_nonbl ($) { Log3($name, 4, "$name - --- End Function serverlogin nonblocking ---"); } else - { + { # Errorcode aus JSON ermitteln $errorcode = $data->{'error'}->{'code'}; @@ -3850,12 +3854,20 @@ sub experror { 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.
+ SSCam is completely using the nonblocking functions of HttpUtils respectively HttpUtils_NonblockingGet.
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.

+ Further informations could be find among Credentials.

+ + Overview which Perl-modules SSCam is using:

+ + JSON
+ Data::Dumper
+ MIME::Base64
+ Time::HiRes
+ HttpUtils (FHEM-module)

- + Define