diff --git a/fhem/contrib/DS_Starter/57_SSCal.pm b/fhem/contrib/DS_Starter/57_SSCal.pm index 034d64c15..3342008f9 100644 --- a/fhem/contrib/DS_Starter/57_SSCal.pm +++ b/fhem/contrib/DS_Starter/57_SSCal.pm @@ -48,7 +48,8 @@ eval "use FHEM::Meta;1" or my $modMetaAbsent = 1; # Versions History intern my %SSCal_vNotesIntern = ( - "1.7.0" => "05.02.2020 respect global language setting for some presentation, new attribute eventIcon ", + "1.7.0" => "07.02.2020 respect global language setting for some presentation, new attributes tableSpecs & tableColumnMap, days left in overview ". + "formatting overview table ", "1.6.1" => "03.02.2020 rename attributes to \"calOverviewInDetail\",\"calOverviewInRoom\", bugfix of gps extraction ", "1.6.0" => "03.02.2020 new attribute \"calOverviewFields\" to show specified fields in calendar overview in detail/room view, ". "Model Diary/Tasks defined, periodic call of ToDo-Liists now possible ", @@ -160,15 +161,16 @@ sub SSCal_Initialize($) { $hash->{AttrList} = "asyncMode:1,0 ". "calOverviewInDetail:0,1 ". "calOverviewInRoom:0,1 ". - "calOverviewFields:multiple-strict,Begin,End,Summary,Status,Location,Description,Map,Calendar,Completion,Timezone ". + "calOverviewFields:multiple-strict,Begin,End,Summary,Status,Location,Description,Map,Calendar,Completion,Timezone,Days ". "cutOlderDays ". "cutLaterDays ". "disable:1,0 ". - "eventIcon:textField-long ". + "tableSpecs:textField-long ". "filterCompleteTask:1,2,3 ". "filterDueTask:1,2,3 ". "interval ". - "loginRetries:1,2,3,4,5,6,7,8,9,10 ". + "loginRetries:1,2,3,4,5,6,7,8,9,10 ". + "tableColumnMap:icon,data,text ". "showRepeatEvent:true,false ". "showPassInLog:1,0 ". "timeout ". @@ -2207,7 +2209,7 @@ sub SSCal_writeValuesToArray ($$$$$$$$$$$) { my $ts = time(); # Istzeit Timestamp my $om = $hash->{OPMODE}; # aktuelle Operation Mode my $status = "initialized"; - my ($val,$uts,$td); + my ($val,$uts,$td,$dleft); my ($upcoming,$alarmed,$started,$ended) = (0,0,0,0); @@ -2215,10 +2217,20 @@ sub SSCal_writeValuesToArray ($$$$$$$$$$$) { $started = SSCal_isStarted ($ts,$bts,$ets); $ended = SSCal_isEnded ($ts,$ets); - push(@row_array, $bts+$n." 02_Begin " .$bdate." ".$btime."\n") if($bdate && $btime); + if($bdate && $btime) { + push(@row_array, $bts+$n." 02_Begin " .$bdate." ".$btime."\n"); + my ($ny,$nm,$nd,undef) = split(/[ -]/, TimeNow()); # Datum Jetzt + my ($by,$bm,$bd) = split("-", $bdate); # Beginn Datum + my $ntimes = fhemTimeLocal(00, 00, 00, $nd, $nm-1, $ny-1900); + my $btimes = fhemTimeLocal(00, 00, 00, $bd, $bm-1, $by-1900); + if($btimes >= $ntimes) { + $dleft = int(($btimes - $ntimes)/86400); + } + } push(@row_array, $bts+$n." 03_End " .$edate." ".$etime."\n") if($edate && $etime); push(@row_array, $bts+$n." 02_bTimestamp " .$bts."\n") if($bts); push(@row_array, $bts+$n." 03_eTimestamp " .$ets."\n") if($ets); + push(@row_array, $bts+$n." 04_daysLeft " .$dleft."\n") if(defined $dleft); push(@row_array, $bts+$n." 09_Timezone " .$tz."\n") if($tz); foreach my $p (keys %{$vh}) { @@ -3209,7 +3221,8 @@ sub SSCal_calAsHtml($) { my ($name) = @_; my $hash = $defs{$name}; my $lang = AttrVal("global","language","EN"); - my ($begin,$end,$summary,$location,$status,$desc,$gps,$gpsa,$gpsc,$cal,$completion,$tz); + my $mi = AttrVal($name,"tableColumnMap","icon"); + my ($begin,$begind,$begint,$end,$endd,$endt,$summary,$location,$status,$desc,$gps,$gpsa,$gpsc,$cal,$completion,$tz,$dleft,$edleft); my $de = 0; if($lang eq "DE") {$de = 1}; @@ -3222,24 +3235,25 @@ sub SSCal_calAsHtml($) { $out .= ""; $out .= ""; $out .= ""; + $out .= ""; $out .= ""; $out .= ""; $out .= "
| ".(($de)?'Start' :'Begin')." | " if($seen{Begin}); - $out .= "".(($de)?'Ende' :'End')." | " if($seen{End}); - $out .= "".(($de)?'Zeitzone' :'Timezone')." | " if($seen{Timezone}); - $out .= "".(($de)?'Zusammenfassung' :'Summary')." | " if($seen{Summary}); - $out .= "".(($de)?'Beschreibung' :'Description')." | " if($seen{Description}); - $out .= "".(($de)?'Status' :'State')." | " if($seen{Status}); - $out .= " ".(($de)?'Erfüllung (%)' :'Completion (%)')." | " if($seen{Completion});
- $out .= "".(($de)?'Ort' :'Location')." | " if($seen{Location}); - $out .= "".(($de)?'Karte' :'Map')." | " if($seen{Map}); - $out .= "".(($de)?'Kalender' :'Calendar')." | " if($seen{Calendar}); - - $out .= "|||||||||||||
| ".(($de)?'Start' :'Begin')." | " if($seen{Begin}); + $out .= "".(($de)?'----' :'----')." | " if($seen{Begin}); + $out .= "".(($de)?'Ende' :'End')." | " if($seen{End}); + $out .= "".(($de)?'----' :'----')." | " if($seen{End}); + $out .= "".(($de)?'Resttage' :'Days left')." | " if($seen{Days}); + $out .= "".(($de)?'Zeitzone' :'Timezone')." | " if($seen{Timezone}); + $out .= "".(($de)?'Zusammenfassung' :'Summary')." | " if($seen{Summary}); + $out .= "".(($de)?'Beschreibung' :'Description')." | " if($seen{Description}); + $out .= "".(($de)?'Status' :'State')." | " if($seen{Status}); + $out .= "".(($de)?'Erfüllung (%)' :'Completion (%)')." | " if($seen{Completion}); + $out .= "".(($de)?'Ort' :'Location')." | " if($seen{Location}); + $out .= "".(($de)?'Karte' :'Map')." | " if($seen{Map}); + $out .= "".(($de)?'Kalender' :'Calendar')." | " if($seen{Calendar}); my $l = length(keys %{$data{SSCal}{$name}{eventlist}}); @@ -3256,9 +3270,12 @@ sub SSCal_calAsHtml($) { my $prestr = sprintf("%0$l.0f", $k); # Prestring erstellen last if(!ReadingsVal($name, $prestr."_05_EventId", "")); # keine Ausgabe wenn es keine EventId mit Blocknummer 0 gibt -> kein Event/Aufage vorhanden + ($begind,$begint,$endd,$endt,$gps) = ("","","","",""); + $summary = ReadingsVal($name, $prestr."_01_Summary", ""); $begin = ReadingsVal($name, $prestr."_02_Begin", ""); $end = ReadingsVal($name, $prestr."_03_End", ""); + $dleft = ReadingsVal($name, $prestr."_04_daysLeft", ""); $desc = ReadingsVal($name, $prestr."_04_Description", ""); $location = ReadingsVal($name, $prestr."_07_Location", ""); $gpsa = ReadingsVal($name, $prestr."_08_gpsAddress", ""); @@ -3268,14 +3285,36 @@ sub SSCal_calAsHtml($) { $completion = ReadingsVal($name, $prestr."_16_percentComplete", ""); $cal = ReadingsVal($name, $prestr."_90_calName", ""); - $gps = ""; if($gpsc) { - my $img = FW_makeImage("it_i-net"); + my $micon; + if ($mi eq "icon") { + my $di = "it_i-net"; + my $ui = $hash->{HELPER}{tableSpecs}{columnMapIcon}; + $di = $ui ? $ui : $di; + $micon = FW_makeImage($di); + } elsif ($mi eq "data") { + $micon = join(" ", split(",", $gpsc)); + } elsif ($mi eq "text") { + my $dt = "link"; + my $ut = $hash->{HELPER}{tableSpecs}{columnMapText}; + $micon = $ut ? $ut : $dt; + } else { + $micon = ""; + } + my ($lat,$lng) = split(",", $gpsc); $lat = (split("=", $lat))[1]; $lng = (split("=", $lng))[1]; - # $gps = " $img "; # OpenstreetMap - $gps = " $img "; # Google Maps + + my $up = $hash->{HELPER}{tableSpecs}{columnMapProvider} || ""; + if ($up eq "GoogleMaps") { # Kartenprovider: Google Maps + $gps = " $micon "; + } elsif ($up eq "OpenStreetMap") { + $gps = " $micon "; # Kartenprovider: OpenstreetMap + } else { + $gps = " $micon "; # Kartenprovider default: Google Maps + } + } if($begin ne "") { # Datum sprachabhängig konvertieren bzw. heute/morgen setzen @@ -3286,32 +3325,43 @@ sub SSCal_calAsHtml($) { my $btimes = fhemTimeLocal(00, 00, 00, $bd, $bm-1, $by-1900); my $etimes = fhemTimeLocal(00, 00, 00, $ed, $em-1, $ey-1900); - if($de && $begin =~ m/(\d{4})-(\d{2})-(\d{2})\s(.*)/) { - $begin = "$3.$2.$1 $4"; - $end =~ m/(\d{4})-(\d{2})-(\d{2})\s(.*)/; - $end = "$3.$2.$1 $4"; - } + if($de) { + $begind = "$bd.$bm.$by"; + $endd = "$ed.$em.$ey"; + } else { + $begind = "$by-$bm-$bd"; + $endd = "$ey-$em-$ed"; + } + $begint = $bt; + $endt = $et; + + $edleft = ""; + if($etimes >= $ntimes) { + $edleft = int(($etimes - $ntimes)/86400); + } - $begin = (($de)?'heute ':'today ').$bt if(($btimes >= $ntimes) && ($btimes < $ntimes+86400)); - $end = (($de)?'heute ':'today ').$et if(($etimes >= $ntimes) && ($etimes < $ntimes+86400)); - - $begin = (($de)?'morgen ':'tomorrow ').$bt if(($btimes >= $ntimes+86400) && ($btimes < $ntimes+172800)); - $end = (($de)?'morgen ':'tomorrow ').$et if(($etimes >= $ntimes+86400) && ($etimes < $ntimes+172800)); + $begind = (($de)?'heute ':'today ') if($dleft eq "0"); + $endd = (($de)?'heute ':'today ') if($edleft eq "0"); + $begind = (($de)?'morgen ':'tomorrow ') if($dleft eq "1"); + $endd = (($de)?'morgen ':'tomorrow ') if($edleft eq "1"); + + $endd = "" if($begind eq $endd); # bei Ende nur Uhrzeit angeben wenn Termin am gleichen Tag beginnt/endet } - - $end = substr($end,11,8) if(substr($begin,0,10) eq substr($end,0,10) && $end !~ /heute|today|morgen|tomorrow/); # bei Ende nur Uhrzeit angeben wenn Termin am gleichen Tag beginnt/endet $out .= "||||||||||
| $begin | " if($seen{Begin}); - $out .= "$end | " if($seen{End}); - $out .= "$tz | " if($seen{Timezone}); - $out .= "$summary | " if($seen{Summary}); - $out .= "$desc | " if($seen{Description}); - $out .= "$status | " if($seen{Status}); - $out .= "$completion | " if($seen{Completion}); - $out .= "$location | " if($seen{Location}); - $out .= "$gps | " if($seen{Map}); - $out .= "$cal | " if($seen{Calendar}); + $out .= "$begind | " if($seen{Begin}); + $out .= "$begint | " if($seen{Begin}); + $out .= "$endd | " if($seen{End}); + $out .= "$endt | " if($seen{End}); + $out .= "$dleft | " if($seen{Days}); + $out .= "$tz | " if($seen{Timezone}); + $out .= "$summary | " if($seen{Summary}); + $out .= "$desc | " if($seen{Description}); + $out .= "$status | " if($seen{Status}); + $out .= "$completion | " if($seen{Completion}); + $out .= "$location | " if($seen{Location}); + $out .= "$gps | " if($seen{Map}); + $out .= "$cal | " if($seen{Calendar}); $out .= "