diff --git a/fhem/contrib/DS_Starter/57_SSCal.pm b/fhem/contrib/DS_Starter/57_SSCal.pm index 32dc5d2f7..92984ccd5 100644 --- a/fhem/contrib/DS_Starter/57_SSCal.pm +++ b/fhem/contrib/DS_Starter/57_SSCal.pm @@ -48,6 +48,7 @@ eval "use FHEM::Meta;1" or my $modMetaAbsent = 1; # Versions History intern my %SSCal_vNotesIntern = ( + "1.10.0" => "13.02.2020 new key cellStyle for attribute tableSpecs, avoid FHEM crash when are design failures in tableSpecs ", "1.9.0" => "11.02.2020 new reading Weekday with localization, more field selection for overview table ", "1.8.0" => "09.02.2020 evaluate icons for DaysLeft, Map and State in sub SSCal_evalTableSpecs , fix no table is shown after FHEM restart ", "1.7.0" => "09.02.2020 respect global language setting for some presentation, new attributes tableSpecs & tableColumnMap, days left in overview ". @@ -3275,7 +3276,16 @@ sub SSCal_calAsHtml($;$) { # Auswahl der darzustellenden Tabellenfelder my %seen; my @cof = split(",", AttrVal($name, "tableFields", "Begin,End,Summary,Status,Location")); - grep { !$seen{$_}++ } @cof; + grep { !$seen{$_}++ } @cof; + + # Gestaltung Headerzeile + my $nohead = 0; # Unterdrückung Anzeige Headerzeile: 0 - nein, 1 - Ja + eval { $nohead = SSCal_evalTableSpecs ($hash,$nohead,$hash->{HELPER}{tableSpecs}{cellStyle}{noHeader},"",\@allrds,"string"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"cellStyle\": $@") if($@); + my $headalign = "center"; # Ausrichtung der Headerzeile, default: center + eval { $headalign = SSCal_evalTableSpecs ($hash,$headalign,$hash->{HELPER}{tableSpecs}{cellStyle}{headerAlign},"",\@allrds,"string"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"cellStyle\": $@") if($@); + $headalign = "cal".$headalign; # Tabelle my $out = ""; @@ -3287,33 +3297,35 @@ sub SSCal_calAsHtml($;$) { $out .= ""; $out .= "
".(($de)?'Symbol' :'Symbol')." | " if($seen{Symbol}); - if ($small) { # nur ein Datumfeld umbrechbar - $out .= "".(($de)?'Start' :'Begin')." | " if($seen{Begin}); - $out .= "".(($de)?'Ende' :'End')." | " if($seen{End}); - } else { - $out .= "".(($de)?'Start' :'Begin')." | " if($seen{Begin}); - $out .= "".(($de)?'----' :'----')." | " if($seen{Begin}); - $out .= "".(($de)?'Ende' :'End')." | " if($seen{End}); - $out .= "".(($de)?'----' :'----')." | " if($seen{End}); + if(!$nohead) { + $out .= "|||||||||||||||||||||||||||||||
".(($de)?'Symbol' :'Symbol')." | " if($seen{Symbol}); + if ($small) { # nur ein Datumfeld umbrechbar + $out .= "".(($de)?'Start' :'Begin')." | " if($seen{Begin}); + $out .= "".(($de)?'Ende' :'End')." | " if($seen{End}); + } else { + $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{DaysLeft}); + $out .= "".(($de)?'Terminziel' :'Goal')." | " if($seen{DaysLeftLong}); + $out .= "".(($de)?'Wochentag' :'Weekday')." | " if($seen{Weekday}); + $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)?'ID' :'ID')." | " if($seen{EventId}); + $out .= "".(($de)?'Resttage' :'Days left')." | " if($seen{DaysLeft}); - $out .= "".(($de)?'Terminziel' :'Goal')." | " if($seen{DaysLeftLong}); - $out .= "".(($de)?'Wochentag' :'Weekday')." | " if($seen{Weekday}); - $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)?'ID' :'ID')." | " if($seen{EventId}); - $out .= ""; - my $maxbnr; foreach my $key (keys %{$defs{$name}{READINGS}}) { next if $key !~ /^(\d+)_\d+_EventId$/; @@ -3352,14 +3364,16 @@ sub SSCal_calAsHtml($;$) { my $micon; if ($mi eq "icon") { # Karten-Icon auswählen - $di = "it_i-net"; - $micon = SSCal_evalTableSpecs ($hash,$di,$hash->{HELPER}{tableSpecs}{columnMapIcon},$bnr,\@allrds,"image"); + $di = "it_i-net"; + eval { $micon = SSCal_evalTableSpecs ($hash,$di,$hash->{HELPER}{tableSpecs}{columnMapIcon},$bnr,\@allrds,"image"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"columnMapIcon\": $@") if($@); } elsif ($mi eq "data") { $micon = join(" ", split(",", $gpsc)); } elsif ($mi eq "text") { # Karten-Text auswählen - my $dt = "link"; - $micon = SSCal_evalTableSpecs ($hash,$dt,$hash->{HELPER}{tableSpecs}{columnMapText},$bnr,\@allrds,"string"); + my $dt = "link"; + eval { $micon = SSCal_evalTableSpecs ($hash,$dt,$hash->{HELPER}{tableSpecs}{columnMapText},$bnr,\@allrds,"string"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"columnMapText\": $@") if($@); } else { $micon = ""; } @@ -3369,16 +3383,15 @@ sub SSCal_calAsHtml($;$) { $lng = (split("=", $lng))[1]; # Kartenanbieter auswählen - my $up = SSCal_evalTableSpecs ($hash,"",$hash->{HELPER}{tableSpecs}{columnMapProvider},$bnr,\@allrds,"string"); + my $up = "GoogleMaps"; + eval { $up = SSCal_evalTableSpecs ($hash,$up,$hash->{HELPER}{tableSpecs}{columnMapProvider},$bnr,\@allrds,"string"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"columnMapProvider\": $@") if($@); if ($up eq "GoogleMaps") { # Kartenprovider: Google Maps $gps = " $micon "; } elsif ($up eq "OpenStreetMap") { - $gps = " $micon "; # Kartenprovider: OpenstreetMap - } else { - $gps = " $micon "; # Kartenprovider default: Google Maps - } - - } + $gps = " $micon "; # Kartenprovider: OpenstreetMap + } + } if($begin ne "") { # Datum sprachabhängig konvertieren bzw. heute/morgen setzen my ($ny,$nm,$nd,undef) = split(/[ -]/, TimeNow()); # Jetzt @@ -3420,38 +3433,47 @@ sub SSCal_calAsHtml($;$) { } # Icon für Spalte Resttage spezifizieren - $dleft = SSCal_evalTableSpecs ($hash,$dleft,$hash->{HELPER}{tableSpecs}{columnDaysLeftIcon},$bnr,\@allrds,"image"); + eval { $dleft = SSCal_evalTableSpecs ($hash,$dleft,$hash->{HELPER}{tableSpecs}{columnDaysLeftIcon},$bnr,\@allrds,"image"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"columnDaysLeftIcon\": $@") if($@); # Icon für Spalte Status spezifizieren - $status = SSCal_evalTableSpecs ($hash,$status,$hash->{HELPER}{tableSpecs}{columnStateIcon},$bnr,\@allrds,"image"); + eval { $status = SSCal_evalTableSpecs ($hash,$status,$hash->{HELPER}{tableSpecs}{columnStateIcon},$bnr,\@allrds,"image"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"columnStateIcon\": $@") if($@); # Icon für Spalte "Symbol" bestimmen - $di = ($hash->{MODEL} eq "Diary") ? "time_calendar" : "time_note"; - $symbol = SSCal_evalTableSpecs ($hash,$di,$hash->{HELPER}{tableSpecs}{columnSymbolIcon},$bnr,\@allrds,"image"); + $di = ($hash->{MODEL} eq "Diary") ? "time_calendar" : "time_note"; + eval { $symbol = SSCal_evalTableSpecs ($hash,$di,$hash->{HELPER}{tableSpecs}{columnSymbolIcon},$bnr,\@allrds,"image"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"columnSymbolIcon\": $@") if($@); + + # Gestaltung Spaltentext + my $colalign = "center"; # Ausrichtung der Spalte, default: center + eval { $colalign = SSCal_evalTableSpecs ($hash,$colalign,$hash->{HELPER}{tableSpecs}{cellStyle}{columnAlign},"",\@allrds,"string"); }; + Log3($name, 1, "$name - Syntax error in attribute \"tableSpecs\" near \"cellStyle\": $@") if($@); + $colalign = "cal".$colalign; $out .= "|||||||
$symbol | " if($seen{Symbol}); + $out .= "$symbol | " if($seen{Symbol}); if($small) { - $out .= "".$begind." ".$begint. " | " if($seen{Begin}); - $out .= "".$endd ." ".$endt. " | " if($seen{End}); + $out .= "".$begind." ".$begint. " | " if($seen{Begin}); + $out .= "".$endd ." ".$endt. " | " if($seen{End}); } else { - $out .= "$begind | " if($seen{Begin}); - $out .= "$begint | " if($seen{Begin}); - $out .= "$endd | " if($seen{End}); - $out .= "$endt | " if($seen{End}); + $out .= "$begind | " if($seen{Begin}); + $out .= "$begint | " if($seen{Begin}); + $out .= "$endd | " if($seen{End}); + $out .= "$endt | " if($seen{End}); } - $out .= "$dleft | " if($seen{DaysLeft}); - $out .= "$dleftlong | " if($seen{DaysLeftLong}); - $out .= "$weekday | " if($seen{Weekday}); - $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 .= "$id | " if($seen{EventId}); + $out .= "$dleft | " if($seen{DaysLeft}); + $out .= "$dleftlong | " if($seen{DaysLeftLong}); + $out .= "$weekday | " if($seen{Weekday}); + $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 .= "$id | " if($seen{EventId}); $out .= "