57_SSCal: contrib 2.4.0

git-svn-id: https://svn.fhem.de/fhem/trunk@21958 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
DS_Starter
2020-05-17 10:59:56 +00:00
parent 08bfb38fc7
commit a7547f9915

View File

@@ -176,9 +176,6 @@ my %vHintsExt_de = (
"gemäß <a href=\"https://tools.ietf.org/html/rfc5545\">RFC5545</a>. " "gemäß <a href=\"https://tools.ietf.org/html/rfc5545\">RFC5545</a>. "
); );
# Hash der API-Seiten
use vars qw(%api);
# Aufbau Errorcode-Hashes # Aufbau Errorcode-Hashes
my %errauthlist = ( my %errauthlist = (
400 => "No such account or the password is incorrect", 400 => "No such account or the password is incorrect",
@@ -314,14 +311,14 @@ sub Define {
CommandAttr(undef,"$name room SSCal"); CommandAttr(undef,"$name room SSCal");
CommandAttr(undef,"$name event-on-update-reading .*Summary,state"); CommandAttr(undef,"$name event-on-update-reading .*Summary,state");
%api = ( $data{SSCal}{$name}{calapi} = { # in Define um unterschiedliche DSM mit div. Versionen zu ermöglichen
"APIINFO" => { "NAME" => "SYNO.API.Info" }, # Info-Seite für alle API's, einzige statische Seite ! "APIINFO" => { "NAME" => "SYNO.API.Info" }, # Info-Seite für alle API's, einzige statische Seite !
"APIAUTH" => { "NAME" => "SYNO.API.Auth" }, # API used to perform session login and logout "APIAUTH" => { "NAME" => "SYNO.API.Auth" }, # API used to perform session login and logout
"CALCAL" => { "NAME" => "SYNO.Cal.Cal" }, # API to manipulate calendar "CALCAL" => { "NAME" => "SYNO.Cal.Cal" }, # API to manipulate calendar
"CALEVENT" => { "NAME" => "SYNO.Cal.Event" }, # Provide methods to manipulate events in the specific calendar "CALEVENT" => { "NAME" => "SYNO.Cal.Event" }, # Provide methods to manipulate events in the specific calendar
"CALSHARE" => { "NAME" => "SYNO.Cal.Sharing" }, # Get/set sharing setting of calendar "CALSHARE" => { "NAME" => "SYNO.Cal.Sharing" }, # Get/set sharing setting of calendar
"CALTODO" => { "NAME" => "SYNO.Cal.Todo" }, # Provide methods to manipulate events in the specific calendar "CALTODO" => { "NAME" => "SYNO.Cal.Todo" }, # Provide methods to manipulate events in the specific calendar
); };
# Versionsinformationen setzen # Versionsinformationen setzen
setVersionInfo($hash); setVersionInfo($hash);
@@ -429,12 +426,12 @@ sub Attr { ## no critic 'comple
} }
if ($aName =~ /tableSpecs/x) { if ($aName =~ /tableSpecs/x) {
return qq{The attribute "$aName" has wrong syntax. The value must be set into "{ }".} if($aVal !~ m/^\s*\{.*\}\s*$/s); return qq{The attribute "$aName" has wrong syntax. The value must be set into "{ }".} if($aVal !~ m/^\s*?\{.*\}\s*?$/xs);
} }
my $attrVal = $aVal; my $attrVal = $aVal;
if ($attrVal =~ m/^\{.*\}$/s && $attrVal =~ m/=>/x) { if ($attrVal =~ m/^\{.*\}$/xs && $attrVal =~ m/=>/x) {
$attrVal =~ s/\@/\\\@/gx; $attrVal =~ s/\@/\\\@/gx;
$attrVal =~ s/\$/\\\$/gx; $attrVal =~ s/\$/\\\$/gx;
@@ -684,7 +681,7 @@ sub Set { ## no critic 'compl
Log3($name, 5, "$name - Calendar selection for add queue: $cals"); Log3($name, 5, "$name - Calendar selection for add queue: $cals");
# <Name, operation mode, API (siehe %api), auszuführende API-Methode, spezifische API-Parameter> # <Name, operation mode, API (siehe $data{SSCal}{$name}{calapi}), auszuführende API-Methode, spezifische API-Parameter>
addQueue($name,"cleanCompleteTasks","CALTODO","clean_complete","&cal_id_list=[$oids]"); addQueue($name,"cleanCompleteTasks","CALTODO","clean_complete","&cal_id_list=[$oids]");
getApiSites($name); getApiSites($name);
@@ -716,7 +713,7 @@ sub Set { ## no critic 'compl
Log3($name, 3, "$name - The event \"$sum\" with id \"$eventid\" will be deleted in calendar \"$calname\"."); Log3($name, 3, "$name - The event \"$sum\" with id \"$eventid\" will be deleted in calendar \"$calname\".");
# <Name, operation mode, API (siehe %api), auszuführende API-Methode, spezifische API-Parameter> # <Name, operation mode, API (siehe $data{SSCal}{$name}{calapi}), auszuführende API-Methode, spezifische API-Parameter>
addQueue($name,"deleteEventId",$api,"delete","&evt_id=$eventid"); addQueue($name,"deleteEventId",$api,"delete","&evt_id=$eventid");
getApiSites($name); getApiSites($name);
@@ -784,7 +781,7 @@ sub Get {
getclhash($hash,1); getclhash($hash,1);
$hash->{HELPER}{APIPARSET} = 0; # Abruf API Infos erzwingen $hash->{HELPER}{APIPARSET} = 0; # Abruf API Infos erzwingen
# <Name, operation mode, API (siehe %api), auszuführende API-Methode, spezifische API-Parameter> # <Name, operation mode, API (siehe $data{SSCal}{$name}{calapi}), auszuführende API-Methode, spezifische API-Parameter>
addQueue($name,"apiInfo","","",""); addQueue($name,"apiInfo","","","");
getApiSites($name); getApiSites($name);
@@ -964,7 +961,7 @@ return;
# Eintrag zur SendQueue hinzufügen # Eintrag zur SendQueue hinzufügen
# $name = Name Kalenderdevice # $name = Name Kalenderdevice
# $opmode = operation mode # $opmode = operation mode
# $api = API (siehe %api) # $api = API (siehe $data{SSCal}{$name}{calapi})
# $method = auszuführende API-Methode # $method = auszuführende API-Methode
# $params = spezifische API-Parameter # $params = spezifische API-Parameter
# #
@@ -1131,7 +1128,14 @@ sub getApiSites {
Log3($name, 5, "$name - HTTP-Call will be done with timeout: $timeout s"); Log3($name, 5, "$name - HTTP-Call will be done with timeout: $timeout s");
# URL zur Abfrage der Eigenschaften der API's # URL zur Abfrage der Eigenschaften der API's
$url = "$prot://$addr:$port/webapi/query.cgi?api=$api{APIINFO}{NAME}&method=Query&version=1&query=$api{APIAUTH}{NAME},$api{CALCAL}{NAME},$api{CALEVENT}{NAME},$api{CALSHARE}{NAME},$api{CALTODO}{NAME},$api{APIINFO}{NAME}"; my $calapi = $data{SSCal}{$name}{calapi};
$url = "$prot://$addr:$port/webapi/query.cgi?api=".$calapi->{APIINFO}{NAME}."&method=Query&version=1&query=".
$calapi->{APIAUTH}{NAME}.",".
$calapi->{CALCAL}{NAME}.",".
$calapi->{CALEVENT}{NAME}.",".
$calapi->{CALSHARE}{NAME}.",".
$calapi->{CALTODO}{NAME}.",".
$calapi->{APIINFO}{NAME};
Log3($name, 4, "$name - Call-Out: $url"); Log3($name, 4, "$name - Call-Out: $url");
@@ -1192,65 +1196,66 @@ sub getApiSites_parse { ## no
if ($success) { if ($success) {
my $logstr; my $logstr;
my $calapi = $data{SSCal}{$name}{calapi};
# Pfad und Maxversion von "SYNO.API.Auth" ermitteln # Pfad und Maxversion von "SYNO.API.Auth" ermitteln
my $apiauthpath = $data->{data}->{$api{APIAUTH}{NAME}}->{path}; my $apiauthpath = $data->{data}->{$calapi->{APIAUTH}{NAME}}->{path};
$apiauthpath =~ tr/_//d if (defined($apiauthpath)); $apiauthpath =~ tr/_//d if (defined($apiauthpath));
my $apiauthmaxver = $data->{data}->{$api{APIAUTH}{NAME}}->{maxVersion}; my $apiauthmaxver = $data->{data}->{$calapi->{APIAUTH}{NAME}}->{maxVersion};
$logstr = defined($apiauthpath) ? "Path of $api{APIAUTH}{NAME} selected: $apiauthpath" : "Path of $api{APIAUTH}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apiauthpath) ? "Path of $calapi->{APIAUTH}{NAME} selected: $apiauthpath" : "Path of $calapi->{APIAUTH}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
$logstr = defined($apiauthmaxver) ? "MaxVersion of $api{APIAUTH}{NAME} selected: $apiauthmaxver" : "MaxVersion of $api{APIAUTH}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apiauthmaxver) ? "MaxVersion of $calapi->{APIAUTH}{NAME} selected: $apiauthmaxver" : "MaxVersion of $calapi->{APIAUTH}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
# Pfad und Maxversion von "SYNO.Cal.Cal" ermitteln # Pfad und Maxversion von "SYNO.Cal.Cal" ermitteln
my $apicalpath = $data->{data}->{$api{CALCAL}{NAME}}->{path}; my $apicalpath = $data->{data}->{$calapi->{CALCAL}{NAME}}->{path};
$apicalpath =~ tr/_//d if (defined($apicalpath)); $apicalpath =~ tr/_//d if (defined($apicalpath));
my $apicalmaxver = $data->{data}->{$api{CALCAL}{NAME}}->{maxVersion}; my $apicalmaxver = $data->{data}->{$calapi->{CALCAL}{NAME}}->{maxVersion};
$logstr = defined($apicalpath) ? "Path of $api{CALCAL}{NAME} selected: $apicalpath" : "Path of $api{CALCAL}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apicalpath) ? "Path of $calapi->{CALCAL}{NAME} selected: $apicalpath" : "Path of $calapi->{CALCAL}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
$logstr = defined($apicalmaxver) ? "MaxVersion of $api{CALCAL}{NAME} selected: $apicalmaxver" : "MaxVersion of $api{CALCAL}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apicalmaxver) ? "MaxVersion of $calapi->{CALCAL}{NAME} selected: $apicalmaxver" : "MaxVersion of $calapi->{CALCAL}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
# Pfad und Maxversion von "SYNO.Cal.Event" ermitteln # Pfad und Maxversion von "SYNO.Cal.Event" ermitteln
my $apievtpath = $data->{data}->{$api{CALEVENT}{NAME}}->{path}; my $apievtpath = $data->{data}->{$calapi->{CALEVENT}{NAME}}->{path};
$apievtpath =~ tr/_//d if (defined($apievtpath)); $apievtpath =~ tr/_//d if (defined($apievtpath));
my $apievtmaxver = $data->{data}->{$api{CALEVENT}{NAME}}->{maxVersion}; my $apievtmaxver = $data->{data}->{$calapi->{CALEVENT}{NAME}}->{maxVersion};
$logstr = defined($apievtpath) ? "Path of $api{CALEVENT}{NAME} selected: $apievtpath" : "Path of $api{CALEVENT}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apievtpath) ? "Path of $calapi->{CALEVENT}{NAME} selected: $apievtpath" : "Path of $calapi->{CALEVENT}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
$logstr = defined($apievtmaxver) ? "MaxVersion of $api{CALEVENT}{NAME} selected: $apievtmaxver" : "MaxVersion of $api{CALEVENT}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apievtmaxver) ? "MaxVersion of $calapi->{CALEVENT}{NAME} selected: $apievtmaxver" : "MaxVersion of $calapi->{CALEVENT}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
# Pfad und Maxversion von "SYNO.Cal.Sharing" ermitteln # Pfad und Maxversion von "SYNO.Cal.Sharing" ermitteln
my $apisharepath = $data->{data}->{$api{CALSHARE}{NAME}}->{path}; my $apisharepath = $data->{data}->{$calapi->{CALSHARE}{NAME}}->{path};
$apisharepath =~ tr/_//d if (defined($apisharepath)); $apisharepath =~ tr/_//d if (defined($apisharepath));
my $apisharemaxver = $data->{data}->{$api{CALSHARE}{NAME}}->{maxVersion}; my $apisharemaxver = $data->{data}->{$calapi->{CALSHARE}{NAME}}->{maxVersion};
$logstr = defined($apisharepath) ? "Path of $api{CALSHARE}{NAME} selected: $apisharepath" : "Path of $api{CALSHARE}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apisharepath) ? "Path of $calapi->{CALSHARE}{NAME} selected: $apisharepath" : "Path of $calapi->{CALSHARE}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
$logstr = defined($apisharemaxver) ? "MaxVersion of $api{CALSHARE}{NAME} selected: $apisharemaxver" : "MaxVersion of $api{CALSHARE}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apisharemaxver) ? "MaxVersion of $calapi->{CALSHARE}{NAME} selected: $apisharemaxver" : "MaxVersion of $calapi->{CALSHARE}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
# Pfad und Maxversion von "SYNO.Cal.Todo" ermitteln # Pfad und Maxversion von "SYNO.Cal.Todo" ermitteln
my $apitodopath = $data->{data}->{$api{CALTODO}{NAME}}->{path}; my $apitodopath = $data->{data}->{$calapi->{CALTODO}{NAME}}->{path};
$apitodopath =~ tr/_//d if (defined($apitodopath)); $apitodopath =~ tr/_//d if (defined($apitodopath));
my $apitodomaxver = $data->{data}->{$api{CALTODO}{NAME}}->{maxVersion}; my $apitodomaxver = $data->{data}->{$calapi->{CALTODO}{NAME}}->{maxVersion};
$logstr = defined($apitodopath) ? "Path of $api{CALTODO}{NAME} selected: $apitodopath" : "Path of $api{CALTODO}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apitodopath) ? "Path of $calapi->{CALTODO}{NAME} selected: $apitodopath" : "Path of $calapi->{CALTODO}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
$logstr = defined($apitodomaxver) ? "MaxVersion of $api{CALTODO}{NAME} selected: $apitodomaxver" : "MaxVersion of $api{CALTODO}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apitodomaxver) ? "MaxVersion of $calapi->{CALTODO}{NAME} selected: $apitodomaxver" : "MaxVersion of $calapi->{CALTODO}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
# Pfad und Maxversion von "SYNO.API.Info" ermitteln # Pfad und Maxversion von "SYNO.API.Info" ermitteln
my $apiinfopath = $data->{data}->{$api{APIINFO}{NAME}}->{path}; my $apiinfopath = $data->{data}->{$calapi->{APIINFO}{NAME}}->{path};
$apiinfopath =~ tr/_//d if (defined($apiinfopath)); $apiinfopath =~ tr/_//d if (defined($apiinfopath));
my $apiinfomaxver = $data->{data}->{$api{APIINFO}{NAME}}->{maxVersion}; my $apiinfomaxver = $data->{data}->{$calapi->{APIINFO}{NAME}}->{maxVersion};
$logstr = defined($apiinfopath) ? "Path of $api{APIINFO}{NAME} selected: $apiinfopath" : "Path of $api{APIINFO}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apiinfopath) ? "Path of $calapi->{APIINFO}{NAME} selected: $apiinfopath" : "Path of $calapi->{APIINFO}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
$logstr = defined($apiinfomaxver) ? "MaxVersion of $api{APIINFO}{NAME} selected: $apiinfomaxver" : "MaxVersion of $api{APIINFO}{NAME} undefined - Synology cal Server may be stopped"; $logstr = defined($apiinfomaxver) ? "MaxVersion of $calapi->{APIINFO}{NAME} selected: $apiinfomaxver" : "MaxVersion of $calapi->{APIINFO}{NAME} undefined - Synology cal Server may be stopped";
Log3($name, 4, "$name - $logstr"); Log3($name, 4, "$name - $logstr");
@@ -1261,29 +1266,29 @@ sub getApiSites_parse { ## no
$apievtmaxver = 3; $apievtmaxver = 3;
$evtmod = "yes"; $evtmod = "yes";
Log3($name, 4, "$name - MaxVersion of $api{CALEVENT}{NAME} adapted to: $apievtmaxver"); Log3($name, 4, "$name - MaxVersion of $calapi->{CALEVENT}{NAME} adapted to: $apievtmaxver");
Log3($name, 4, "$name - ------- End of adaption section -------"); Log3($name, 4, "$name - ------- End of adaption section -------");
# ermittelte Werte in $hash einfügen # ermittelte Werte in $hash einfügen
$api{APIINFO}{PATH} = $apiinfopath; $calapi->{APIINFO}{PATH} = $apiinfopath;
$api{APIINFO}{MAX} = $apiinfomaxver; $calapi->{APIINFO}{MAX} = $apiinfomaxver;
$api{APIINFO}{MOD} = $infomod // "no"; $calapi->{APIINFO}{MOD} = $infomod // "no";
$api{APIAUTH}{PATH} = $apiauthpath; $calapi->{APIAUTH}{PATH} = $apiauthpath;
$api{APIAUTH}{MAX} = $apiauthmaxver; $calapi->{APIAUTH}{MAX} = $apiauthmaxver;
$api{APIAUTH}{MOD} = $authmod // "no"; $calapi->{APIAUTH}{MOD} = $authmod // "no";
$api{CALCAL}{PATH} = $apicalpath; $calapi->{CALCAL}{PATH} = $apicalpath;
$api{CALCAL}{MAX} = $apicalmaxver; $calapi->{CALCAL}{MAX} = $apicalmaxver;
$api{CALCAL}{MOD} = $calmod // "no"; $calapi->{CALCAL}{MOD} = $calmod // "no";
$api{CALEVENT}{PATH} = $apievtpath; $calapi->{CALEVENT}{PATH} = $apievtpath;
$api{CALEVENT}{MAX} = $apievtmaxver; $calapi->{CALEVENT}{MAX} = $apievtmaxver;
$api{CALEVENT}{MOD} = $evtmod // "no"; $calapi->{CALEVENT}{MOD} = $evtmod // "no";
$api{CALSHARE}{PATH} = $apisharepath; $calapi->{CALSHARE}{PATH} = $apisharepath;
$api{CALSHARE}{MAX} = $apisharemaxver; $calapi->{CALSHARE}{MAX} = $apisharemaxver;
$api{CALSHARE}{MOD} = $sharemod // "no"; $calapi->{CALSHARE}{MOD} = $sharemod // "no";
$api{CALTODO}{PATH} = $apitodopath; $calapi->{CALTODO}{PATH} = $apitodopath;
$api{CALTODO}{MAX} = $apitodomaxver; $calapi->{CALTODO}{MAX} = $apitodomaxver;
$api{CALTODO}{MOD} = $todomod // "no"; $calapi->{CALTODO}{MOD} = $todomod // "no";
# API values sind gesetzt in Hash # API values sind gesetzt in Hash
$hash->{HELPER}{APIPARSET} = 1; $hash->{HELPER}{APIPARSET} = 1;
@@ -1295,11 +1300,11 @@ sub getApiSites_parse { ## no
$out .= "<tr><td> <b>API</b> </td><td> <b>Path</b> </td><td> <b>Version</b> </td><td> <b>Downgraded</b> </td></tr>"; $out .= "<tr><td> <b>API</b> </td><td> <b>Path</b> </td><td> <b>Version</b> </td><td> <b>Downgraded</b> </td></tr>";
$out .= "<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>"; $out .= "<tr><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>";
for my $key (keys %api) { for my $key (keys %{$calapi}) {
my $apiname = $api{$key}{NAME}; my $apiname = $calapi->{$key}{NAME};
my $apipath = $api{$key}{PATH}; my $apipath = $calapi->{$key}{PATH};
my $apiver = $api{$key}{MAX}; my $apiver = $calapi->{$key}{MAX};
my $apimod = $api{$key}{MOD}; my $apimod = $calapi->{$key}{MOD};
$out .= "<tr>"; $out .= "<tr>";
$out .= "<td> $apiname </td>"; $out .= "<td> $apiname </td>";
@@ -1364,6 +1369,7 @@ sub calOp {
my $method = $data{SSCal}{$name}{sendqueue}{entries}{$idx}{method}; my $method = $data{SSCal}{$name}{sendqueue}{entries}{$idx}{method};
my $api = $data{SSCal}{$name}{sendqueue}{entries}{$idx}{api}; my $api = $data{SSCal}{$name}{sendqueue}{entries}{$idx}{api};
my $params = $data{SSCal}{$name}{sendqueue}{entries}{$idx}{params}; my $params = $data{SSCal}{$name}{sendqueue}{entries}{$idx}{params};
my $calapi = $data{SSCal}{$name}{calapi};
Log3($name, 4, "$name - start SendQueue entry index \"$idx\" ($hash->{OPMODE}) for operation."); Log3($name, 4, "$name - start SendQueue entry index \"$idx\" ($hash->{OPMODE}) for operation.");
@@ -1371,10 +1377,10 @@ sub calOp {
Log3($name, 5, "$name - HTTP-Call will be done with timeout: $timeout s"); Log3($name, 5, "$name - HTTP-Call will be done with timeout: $timeout s");
$url = "$prot://$addr:$port/webapi/".$api{$api}{PATH}."?api=".$api{$api}{NAME}."&version=".$api{$api}{MAX}."&method=$method".$params."&_sid=$sid"; $url = "$prot://$addr:$port/webapi/".$calapi->{$api}{PATH}."?api=".$calapi->{$api}{NAME}."&version=".$calapi->{$api}{MAX}."&method=$method".$params."&_sid=$sid";
if($opmode eq "deleteEventId" && $api eq "CALEVENT") { # Workaround !!! Methode delete funktioniert nicht mit SYNO.Cal.Event version > 1 if($opmode eq "deleteEventId" && $api eq "CALEVENT") { # Workaround !!! Methode delete funktioniert nicht mit SYNO.Cal.Event version > 1
$url = "$prot://$addr:$port/webapi/".$api{$api}{PATH}."?api=".$api{$api}{NAME}."&version=1&method=$method".$params."&_sid=$sid"; $url = "$prot://$addr:$port/webapi/".$calapi->{$api}{PATH}."?api=".$calapi->{$api}{NAME}."&version=1&method=$method".$params."&_sid=$sid";
} }
my $part = $url; my $part = $url;
@@ -1418,7 +1424,7 @@ sub calOp_parse { ## n
Log3($name, 2, "$name - ERROR message: $err"); Log3($name, 2, "$name - ERROR message: $err");
$errorcode = "none"; $errorcode = "none";
$errorcode = "800" if($err =~ /: malformed or unsupported URL$/s); $errorcode = "800" if($err =~ /:\smalformed\sor\sunsupported\sURL$/xs);
readingsBeginUpdate ($hash); readingsBeginUpdate ($hash);
readingsBulkUpdateIfChanged ($hash, "Error", $err); readingsBulkUpdateIfChanged ($hash, "Error", $err);
@@ -1675,7 +1681,19 @@ sub extractEventlist { ## no critic 'complexity'
$ignore = 1; $ignore = 1;
$done = 0; $done = 0;
} else { } else {
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
$ignore = 0; $ignore = 0;
$done = 1; $done = 1;
} }
@@ -1757,8 +1775,19 @@ sub extractEventlist { ## no critic 'complexity'
$etime = $netime ? $netime : $etime; $etime = $netime ? $netime : $etime;
$ets = $nets ? $nets : $ets; $ets = $nets ? $nets : $ets;
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
$ignore = 0; $ignore = 0;
$done = 1; $done = 1;
$n++; $n++;
@@ -1811,8 +1840,19 @@ sub extractEventlist { ## no critic 'complexity'
$etime = $netime ? $netime : $etime; $etime = $netime ? $netime : $etime;
$ets = $nets ? $nets : $ets; $ets = $nets ? $nets : $ets;
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
$ignore = 0; $ignore = 0;
$done = 1; $done = 1;
$n++; $n++;
@@ -1901,8 +1941,19 @@ sub extractEventlist { ## no critic 'complexity'
$etime = $netime ? $netime : $etime; $etime = $netime ? $netime : $etime;
$ets = $nets ? $nets : $ets; $ets = $nets ? $nets : $ets;
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
$ignore = 0; $ignore = 0;
$done = 1; $done = 1;
$n++; $n++;
@@ -1972,8 +2023,19 @@ sub extractEventlist { ## no critic 'complexity'
$etime = $netime ? $netime : $etime; $etime = $netime ? $netime : $etime;
$ets = $nets ? $nets : $ets; $ets = $nets ? $nets : $ets;
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
$ignore = 0; $ignore = 0;
$done = 1; $done = 1;
$n++; $n++;
@@ -2022,8 +2084,19 @@ sub extractEventlist { ## no critic 'complexity'
$etime = $netime ? $netime : $etime; $etime = $netime ? $netime : $etime;
$ets = $nets ? $nets : $ets; $ets = $nets ? $nets : $ets;
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
$ignore = 0; $ignore = 0;
$done = 1; $done = 1;
$n++; $n++;
@@ -2072,8 +2145,19 @@ sub extractEventlist { ## no critic 'complexity'
$etime = $netime ? $netime : $etime; $etime = $netime ? $netime : $etime;
$ets = $nets ? $nets : $ets; $ets = $nets ? $nets : $ets;
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
$ignore = 0; $ignore = 0;
$done = 1; $done = 1;
$n++; $n++;
@@ -2098,8 +2182,21 @@ sub extractEventlist { ## no critic 'complexity'
$etime = $netime ? $netime : $etime; $etime = $netime ? $netime : $etime;
$ets = $nets ? $nets : $ets; $ets = $nets ? $nets : $ets;
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
} }
$i++; $i++;
$n++; $n++;
} }
@@ -2162,8 +2259,21 @@ sub extractToDolist { ## no critic 'complexity'
Log3($name, 4, "$name - Ignore single task -> $data->{data}{$key}[$i]{summary} start: $bdate $btime, end: $edate $etime"); Log3($name, 4, "$name - Ignore single task -> $data->{data}{$key}[$i]{summary} start: $bdate $btime, end: $edate $etime");
$ignore = 1; $ignore = 1;
$done = 0; $done = 0;
} else { } else {
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
$ignore = 0; $ignore = 0;
$done = 1; $done = 1;
} }
@@ -2184,7 +2294,19 @@ sub extractToDolist { ## no critic 'complexity'
$etime = $netime ? $netime : $etime; $etime = $netime ? $netime : $etime;
$ets = $nets ? $nets : $ets; $ets = $nets ? $nets : $ets;
@row_array = writeValuesToArray ($name,$n,$data->{data}{$key}[$i],$tz,$bdate,$btime,$bts,$edate,$etime,$ets,\@row_array,$uid); @row_array = writeValuesToArray ({ name => $name,
eventno => $n,
calref => $data->{data}{$key}[$i],
timezone => $tz,
begindate => $bdate,
begintime => $btime,
begints => $bts,
enddate => $edate,
endtime => $etime,
endts => $ets,
sumarrayref => \@row_array,
uid => $uid
});
} }
$i++; $i++;
$n++; $n++;
@@ -2443,7 +2565,20 @@ return ($nbss,$nbmm,$nbhh,$bmday,$bmonth,$byear,$ness,$nemm,$nehh,$emday,$emonth
# #
############################################################################################# #############################################################################################
sub writeValuesToArray { ## no critic 'complexity' sub writeValuesToArray { ## no critic 'complexity'
my ($name,$n,$vh,$tz,$bdate,$btime,$bts,$edate,$etime,$ets,$aref,$uid) = @_; my ($argref) = @_;
my $name = $argref->{name};
my $n = $argref->{eventno};
my $vh = $argref->{calref};
my $tz = $argref->{timezone};
my $bdate = $argref->{begindate};
my $btime = $argref->{begintime};
my $bts = $argref->{begints};
my $edate = $argref->{enddate};
my $etime = $argref->{endtime};
my $ets = $argref->{endts};
my $aref = $argref->{sumarrayref};
my $uid = $argref->{uid};
my @row_array = @{$aref}; my @row_array = @{$aref};
my $hash = $defs{$name}; my $hash = $defs{$name};
my $lang = AttrVal("global", "language", "EN"); my $lang = AttrVal("global", "language", "EN");
@@ -2460,7 +2595,7 @@ sub writeValuesToArray { ## no
if($bdate && $btime) { if($bdate && $btime) {
push(@row_array, $bts+$n." 05_Begin " .$bdate." ".$btime."\n"); push(@row_array, $bts+$n." 05_Begin " .$bdate." ".$btime."\n");
my ($ny,$nm,$nd,undef) = split(/[ -]/, TimeNow()); # Datum Jetzt my ($ny,$nm,$nd,undef) = split(/[\s-]/x, TimeNow()); # Datum Jetzt
my ($by,$bm,$bd) = split("-", $bdate); # Beginn Datum my ($by,$bm,$bd) = split("-", $bdate); # Beginn Datum
my $ntimes = fhemTimeLocal(00, 00, 00, $nd, $nm-1, $ny-1900); my $ntimes = fhemTimeLocal(00, 00, 00, $nd, $nm-1, $ny-1900);
my $btimes = fhemTimeLocal(00, 00, 00, $bd, $bm-1, $by-1900); my $btimes = fhemTimeLocal(00, 00, 00, $bd, $bm-1, $by-1900);
@@ -2851,9 +2986,9 @@ sub login {
my $serveraddr = $hash->{ADDR}; my $serveraddr = $hash->{ADDR};
my $serverport = $hash->{PORT}; my $serverport = $hash->{PORT};
my $proto = $hash->{PROT}; my $proto = $hash->{PROT};
my $apiauth = $api{APIAUTH}{NAME}; my $apiauth = $data{SSCal}{$name}{calapi}{APIAUTH}{NAME};
my $apiauthpath = $api{APIAUTH}{PATH}; my $apiauthpath = $data{SSCal}{$name}{calapi}{APIAUTH}{PATH};
my $apiauthmaxver = $api{APIAUTH}{MAX}; my $apiauthmaxver = $data{SSCal}{$name}{calapi}{APIAUTH}{MAX};
my $lrt = AttrVal($name,"loginRetries",3); my $lrt = AttrVal($name,"loginRetries",3);
my ($url,$param); my ($url,$param);
@@ -2984,9 +3119,9 @@ sub logout {
my $serveraddr = $hash->{ADDR}; my $serveraddr = $hash->{ADDR};
my $serverport = $hash->{PORT}; my $serverport = $hash->{PORT};
my $proto = $hash->{PROT}; my $proto = $hash->{PROT};
my $apiauth = $api{APIAUTH}{NAME}; my $apiauth = $data{SSCal}{$name}{calapi}{APIAUTH}{NAME};
my $apiauthpath = $api{APIAUTH}{PATH}; my $apiauthpath = $data{SSCal}{$name}{calapi}{APIAUTH}{PATH};
my $apiauthmaxver = $api{APIAUTH}{MAX}; my $apiauthmaxver = $data{SSCal}{$name}{calapi}{APIAUTH}{MAX};
my $sid = $hash->{HELPER}{SID}; my $sid = $hash->{HELPER}{SID};
my ($url,$param); my ($url,$param);
@@ -4093,9 +4228,9 @@ sub evalTableSpecs { ## no cr
} }
} else { # ref Wert der Eigenschaft ist nicht HASH oder ARRAY } else { # ref Wert der Eigenschaft ist nicht HASH oder ARRAY
if($specs =~ m/^\{.*\}$/s) { # den Wert als Perl-Funktion ausführen wenn in {} if($specs =~ m/\{.*\}/xs) { # den Wert als Perl-Funktion ausführen wenn in {}
$specs =~ s/\$NAME/$name/g; # Platzhalter $NAME, $BNR ersetzen $specs =~ s/\$NAME/$name/xg; # Platzhalter $NAME, $BNR ersetzen
$specs =~ s/\$BNR/$bnr/g; $specs =~ s/\$BNR/$bnr/xg;
$default = $check->($specs); $default = $check->($specs);
} else { # einfache key-value Zuweisung } else { # einfache key-value Zuweisung
eval ($default = $specs); ## no critic 'eval' eval ($default = $specs); ## no critic 'eval'