2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

57_SSCal: fix problem recurring MONTHLY appointment by day

git-svn-id: https://svn.fhem.de/fhem/trunk@26236 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2022-07-16 16:31:39 +00:00
parent 75ab4b1ff5
commit 3a2f4c61d8
2 changed files with 51 additions and 41 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- bugfix: 57_SSCal: fix problem recurring MONTHLY appointment by day
- bugfix: 96_Snapcast: prevent crash in case of external group commands - bugfix: 96_Snapcast: prevent crash in case of external group commands
- feature: 70_ESCVP21net: added undocumented settings (IMGPROC, IRIS, LIRIS) - feature: 70_ESCVP21net: added undocumented settings (IMGPROC, IRIS, LIRIS)
- feature: 30_HUEBridge, 31_HUEDevice: support for Hue tap dial switch - feature: 30_HUEBridge, 31_HUEDevice: support for Hue tap dial switch

View File

@ -3,7 +3,7 @@
######################################################################################################################### #########################################################################################################################
# 57_SSCal.pm # 57_SSCal.pm
# #
# (c) 2019 - 2021 by Heiko Maaz # (c) 2019 - 2022 by Heiko Maaz
# e-mail: Heiko dot Maaz at t-online dot de # e-mail: Heiko dot Maaz at t-online dot de
# #
# This Module integrate the Synology Calendar into FHEM # This Module integrate the Synology Calendar into FHEM
@ -140,6 +140,8 @@ BEGIN {
# Versions History intern # Versions History intern
my %vNotesIntern = ( my %vNotesIntern = (
"2.4.10" => "16.07.2022 fix problem recurring MONTHLY appointment by day, ".
"forum: https://forum.fhem.de/index.php/topic,106963.msg1228098.html#msg1228098 ",
"2.4.9" => "11.07.2021 set adaption of AUTH for DSM7 compatibility ", "2.4.9" => "11.07.2021 set adaption of AUTH for DSM7 compatibility ",
"2.4.8" => "16.12.2020 accep umlauts in calendar name ", "2.4.8" => "16.12.2020 accep umlauts in calendar name ",
"2.4.7" => "08.12.2020 fix handle code recognition in createAtDevices as single line ", "2.4.7" => "08.12.2020 fix handle code recognition in createAtDevices as single line ",
@ -1561,7 +1563,8 @@ return;
# Extrahiert empfangene Kalendertermine (Events) # Extrahiert empfangene Kalendertermine (Events)
############################################################################################# #############################################################################################
sub extractEventlist { ## no critic 'complexity' sub extractEventlist { ## no critic 'complexity'
my ($name) = @_; my $name = shift;
my $hash = $defs{$name}; my $hash = $defs{$name};
my $data = delete $hash->{eventlist}; # zentrales Eventhash löschen ! my $data = delete $hash->{eventlist}; # zentrales Eventhash löschen !
my $am = AttrVal($name, "asyncMode", 0); my $am = AttrVal($name, "asyncMode", 0);
@ -1573,8 +1576,8 @@ sub extractEventlist { ## no critic 'complexi
my (undef,$tstart,$tend) = timeEdge ($name); # Sollstart- und Sollendezeit der Kalenderereignisse ermitteln my (undef,$tstart,$tend) = timeEdge ($name); # Sollstart- und Sollendezeit der Kalenderereignisse ermitteln
my $datetimestart = FmtDateTime ($tstart); my $datetimestart = FmtDateTime ($tstart);
my $datetimeend = FmtDateTime ($tend); my $datetimeend = FmtDateTime ($tend);
my $n = 0; # Zusatz f. lfd. Nr. zur Unterscheidung exakt zeitgleicher Events my $n = 0; # Zusatz f. lfd. Nr. zur Unterscheidung exakt zeitgleicher Events
for my $key (keys %{$data->{data}}) { for my $key (keys %{$data->{data}}) {
my $i = 0; my $i = 0;
@ -1583,8 +1586,8 @@ sub extractEventlist { ## no critic 'complexi
my $done = 0; my $done = 0;
my $next = 0; my $next = 0;
($nbdate,$nedate) = ("",""); ($nbdate,$nedate) = ("","");
my $uid = $data->{data}{$key}[$i]{ical_uid}; # UID des Events my $uid = $data->{data}{$key}[$i]{ical_uid}; # UID des Events
extractIcal ($name,$data->{data}{$key}[$i]); # VCALENDAR Extrakt in {HELPER}{VCALENDAR} importieren extractIcal ($name,$data->{data}{$key}[$i]); # VCALENDAR Extrakt in {HELPER}{VCALENDAR} importieren
my $isallday = $data->{data}{$key}[$i]{is_all_day}; my $isallday = $data->{data}{$key}[$i]{is_all_day};
@ -1597,9 +1600,9 @@ sub extractEventlist { ## no critic 'complexi
my ($eyear, $emonth, $emday) = $edate =~ /(\d{4})-(\d{2})-(\d{2})/x; my ($eyear, $emonth, $emday) = $edate =~ /(\d{4})-(\d{2})-(\d{2})/x;
$netime = $etime; $netime = $etime;
# Bugfix API - wenn is_all_day und an erster Stelle im 'data' Ergebnis des API-Calls ist Endedate/time nicht korrekt ! if($isallday && ($bdate ne $edate) && $netime =~ /^00:59:59$/x) { # Bugfix API - wenn is_all_day und an erster Stelle im 'data' Ergebnis des API-Calls ist Endedate/time nicht korrekt !
if($isallday && ($bdate ne $edate) && $netime =~ /^00:59:59$/x) {
($es, $em, $eh, $emday, $emonth, $eyear, undef, undef, undef) = localtime($ets-=3600); ($es, $em, $eh, $emday, $emonth, $eyear, undef, undef, undef) = localtime($ets-=3600);
$eyear = sprintf("%02d", $eyear+=1900); $eyear = sprintf("%02d", $eyear+=1900);
$emonth = sprintf("%02d", $emonth+=1); $emonth = sprintf("%02d", $emonth+=1);
$emday = sprintf("%02d", $emday); $emday = sprintf("%02d", $emday);
@ -1617,11 +1620,13 @@ sub extractEventlist { ## no critic 'complexi
if($ets < $tstart || $bts > $tend) { if($ets < $tstart || $bts > $tend) {
Log3($name, 4, "$name - Ignore single event -> $data->{data}{$key}[$i]{summary} start: $bdate $btime, end: $edate $etime"); Log3($name, 4, "$name - Ignore single event -> $data->{data}{$key}[$i]{summary} start: $bdate $btime, end: $edate $etime");
$ignore = 1; $ignore = 1;
$done = 0; $done = 0;
} }
elsif ($excl) { elsif ($excl) {
Log3($name, 4, "$name - Ignored by Ical compare -> $data->{data}{$key}[$i]{summary} start: $bdate $btime, end: $edate $etime"); Log3($name, 4, "$name - Ignored by Ical compare -> $data->{data}{$key}[$i]{summary} start: $bdate $btime, end: $edate $etime");
$ignore = 1; $ignore = 1;
$done = 0; $done = 0;
} }
@ -1650,10 +1655,11 @@ sub extractEventlist { ## no critic 'complexi
my $rr = $data->{data}{$key}[$i]{evt_repeat_setting}{repeat_rule}; my $rr = $data->{data}{$key}[$i]{evt_repeat_setting}{repeat_rule};
# Format: FREQ=YEARLY;COUNT=1;INTERVAL=2;BYMONTHDAY=15;BYMONTH=10;UNTIL=2020-12-31T00:00:00 # Format: FREQ=YEARLY;COUNT=1;INTERVAL=2;BYMONTHDAY=15;BYMONTH=10;UNTIL=2020-12-31T00:00:00
my @para = split(";", $rr); my @para = split ";", $rr;
for my $par (@para) { for my $par (@para) {
my ($p1,$p2) = split("=", $par); my ($p1,$p2) = split "=", $par;
if ($p1 eq "FREQ") { if ($p1 eq "FREQ") {
$freq = $p2; $freq = $p2;
} }
@ -1791,12 +1797,13 @@ sub extractEventlist { ## no critic 'complexi
if ($byday) { # Wiederholungseigenschaft -> Wochentag z.B. 2WE,-1SU,4FR (kann auch Liste bei WEEKLY sein) if ($byday) { # Wiederholungseigenschaft -> Wochentag z.B. 2WE,-1SU,4FR (kann auch Liste bei WEEKLY sein)
my ($nbhh,$nbmm,$nbss,$nehh,$nemm,$ness,$numOfRatedDay,$rDaysToAddOrSub,$rNewTime); my ($nbhh,$nbmm,$nbss,$nehh,$nemm,$ness,$numOfRatedDay,$rDaysToAddOrSub,$rNewTime);
my @ByDays = split(",", $byday); # Array der Wiederholungstage my @ByDays = split ",", $byday; # Array der Wiederholungstage
for my $rByDay (@ByDays) { for my $rByDay (@ByDays) {
my $rByDayLength = length($rByDay); # die Länge des Strings my $rByDayLength = length($rByDay); # die Länge des Strings
my $rDayStr; # Tag auf den das Datum gesetzt werden soll my $rDayStr; # Tag auf den das Datum gesetzt werden soll
my $rDayInterval; # z.B. 2 = 2nd Tag des Monats oder -1 = letzter Tag des Monats my $rDayInterval; # z.B. 2 = 2nd Tag des Monats oder -1 = letzter Tag des Monats
if ($rByDayLength > 2) { if ($rByDayLength > 2) {
$rDayStr = substr($rByDay, -2); $rDayStr = substr($rByDay, -2);
$rDayInterval = int(substr($rByDay, 0, $rByDayLength - 2)); $rDayInterval = int(substr($rByDay, 0, $rByDayLength - 2));
@ -1806,7 +1813,7 @@ sub extractEventlist { ## no critic 'complexi
$rDayInterval = 1; $rDayInterval = 1;
} }
my $numOfAppointmentDay = _weekdayNumber ($rByDay); # liefert Nr des Wochentages: SU = 0 ... SA = 6 my $numOfAppointmentDay = _weekdayNumber ($rDayStr); # liefert Nr des Wochentages: SU = 0 ... SA = 6
for ($ci=-1; $ci<($count); $ci++) { for ($ci=-1; $ci<($count); $ci++) {
if ($rDayInterval > 0) { # Angabe "jeder x Wochentag" ist positiv (-2 wäre z.B. vom Ende des Monats zu zähelen) if ($rDayInterval > 0) { # Angabe "jeder x Wochentag" ist positiv (-2 wäre z.B. vom Ende des Monats zu zähelen)
@ -1815,8 +1822,9 @@ sub extractEventlist { ## no critic 'complexi
$bmonth %= 12 if($bmonth>12); $bmonth %= 12 if($bmonth>12);
$bmonth = sprintf("%02d", $bmonth); $bmonth = sprintf("%02d", $bmonth);
($nbhh,$nbmm,$nbss) = split(":", $nbtime); ($nbhh,$nbmm,$nbss) = split ":", $nbtime;
my $firstOfNextMonth = fhemTimeLocal($nbss, $nbmm, $nbhh, 1, $bmonth-1, $byear-1900); my $firstOfNextMonth = fhemTimeLocal($nbss, $nbmm, $nbhh, 1, $bmonth-1, $byear-1900);
($nbss, $nbmm, $nbhh, $bmday, $bmonth, $byear, $numOfRatedDay, undef, undef) = localtime($firstOfNextMonth); # den 1. des Monats sowie die dazu gehörige Nr. des Wochentages ($nbss, $nbmm, $nbhh, $bmday, $bmonth, $byear, $numOfRatedDay, undef, undef) = localtime($firstOfNextMonth); # den 1. des Monats sowie die dazu gehörige Nr. des Wochentages
if ($numOfRatedDay <= $numOfAppointmentDay) { # Nr Wochentag des 1. des Monats <= als Wiederholungstag if ($numOfRatedDay <= $numOfAppointmentDay) { # Nr Wochentag des 1. des Monats <= als Wiederholungstag
@ -1825,6 +1833,7 @@ sub extractEventlist { ## no critic 'complexi
else { else {
$rDaysToAddOrSub = 7 - $numOfRatedDay + $numOfAppointmentDay; $rDaysToAddOrSub = 7 - $numOfRatedDay + $numOfAppointmentDay;
} }
$rDaysToAddOrSub += (7 * ($rDayInterval - 1)); # addiere Tagesintervall, z.B. 4th Freitag ... $rDaysToAddOrSub += (7 * ($rDayInterval - 1)); # addiere Tagesintervall, z.B. 4th Freitag ...
$rNewTime = plusNSeconds($firstOfNextMonth, 86400*$rDaysToAddOrSub, 1); $rNewTime = plusNSeconds($firstOfNextMonth, 86400*$rDaysToAddOrSub, 1);
@ -1884,7 +1893,7 @@ sub extractEventlist { ## no critic 'complexi
if ($byday) { # Wiederholungseigenschaft -> Wochentag z.B. 2WE,-1SU,4FR (kann auch Liste bei WEEKLY sein) if ($byday) { # Wiederholungseigenschaft -> Wochentag z.B. 2WE,-1SU,4FR (kann auch Liste bei WEEKLY sein)
my ($nbhh,$nbmm,$nbss,$nehh,$nemm,$ness,$rNewTime); my ($nbhh,$nbmm,$nbss,$nehh,$nemm,$ness,$rNewTime);
my ($numOfRatedDay,$rDaysToAddOrSub); my ($numOfRatedDay,$rDaysToAddOrSub);
my @ByDays = split(",", $byday); # Array der Wiederholungstage my @ByDays = split ",", $byday; # Array der Wiederholungstage
my $btsstart = $bts; my $btsstart = $bts;
$ci = -1; $ci = -1;
@ -1899,7 +1908,7 @@ sub extractEventlist { ## no critic 'complexi
($nbss, $nbmm, $nbhh, $bmday, $bmonth, $byear, $numOfRatedDay, undef, undef) = localtime($rNewTime); ($nbss, $nbmm, $nbhh, $bmday, $bmonth, $byear, $numOfRatedDay, undef, undef) = localtime($rNewTime);
($nbhh,$nbmm,$nbss) = split(":", $nbtime); ($nbhh,$nbmm,$nbss) = split ":", $nbtime;
if ($numOfRatedDay <= $numOfAppointmentDay) { # Nr nächster Wochentag <= Planwochentag if ($numOfRatedDay <= $numOfAppointmentDay) { # Nr nächster Wochentag <= Planwochentag
$rDaysToAddOrSub = $numOfAppointmentDay - $numOfRatedDay; $rDaysToAddOrSub = $numOfAppointmentDay - $numOfRatedDay;