From f9461e8b7c09425c0f05f8536231dcadd52544c1 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Wed, 5 Feb 2020 23:12:14 +0000 Subject: [PATCH] 57_SSCal: contrib 1.7.0 git-svn-id: https://svn.fhem.de/fhem/trunk@21128 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/57_SSCal.pm | 106 ++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 31 deletions(-) diff --git a/fhem/contrib/DS_Starter/57_SSCal.pm b/fhem/contrib/DS_Starter/57_SSCal.pm index 6c69976da..034d64c15 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.7.0" => "05.02.2020 respect global language setting for some presentation, new attribute eventIcon ", "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 ", @@ -163,6 +164,7 @@ sub SSCal_Initialize($) { "cutOlderDays ". "cutLaterDays ". "disable:1,0 ". + "eventIcon:textField-long ". "filterCompleteTask:1,2,3 ". "filterDueTask:1,2,3 ". "interval ". @@ -321,6 +323,8 @@ sub SSCal_Attr($$$$) { # aName and aVal are Attribute name and value if ($cmd eq "set") { + my $attrVal = $aVal; + if ($aName =~ /filterCompleteTask|filterDueTask/ && $model ne "Tasks") { return " The attribute \"$aName\" is only valid for devices of MODEL \"Tasks\"! Please set this attribute in a device of this model."; } @@ -328,7 +332,20 @@ sub SSCal_Attr($$$$) { if ($aName =~ /showRepeatEvent/ && $model ne "Diary") { return " The attribute \"$aName\" is only valid for devices of MODEL \"Diary\"! Please set this attribute in a device of this model."; } - } + + if ($attrVal =~ m/^\{.*\}$/s && $attrVal =~ m/=>/ && $attrVal !~ m/\$/) { + my $av = eval $attrVal; + # Log3($name, 1, "$name - av: ".$av); + if($@) { + Log3($name, 2, "$name - Error while evaluate: ".$@); + } else { + $attrVal = $av if(ref($av) eq "HASH"); + } + } + $hash->{HELPER}{$aName} = $attrVal; + } else { + delete $hash->{HELPER}{$aName}; + } if ($aName eq "disable") { if($cmd eq "set") { @@ -3189,32 +3206,37 @@ return $bool; # Kalenderliste als HTML-Tabelle zurückgeben ############################################################################################# sub SSCal_calAsHtml($) { - my ($name)= @_; - my $hash = $defs{$name}; + 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 ($begin,$end,$summary,$location,$status,$desc,$gps,$gpsa,$gpsc,$cal,$completion,$tz); + my $de = 0; + if($lang eq "DE") {$de = 1}; my %seen; my @cof = split(",", AttrVal($name, "calOverviewFields", "Begin,End,Summary,Status,Location")); grep { !$seen{$_}++ } @cof; my $out = ""; - $out .= ""; - $out .= ""; - $out .= ""; - $out .= ""; + $out .= ""; + $out .= ""; + $out .= ""; + $out .= ""; + $out .= ""; + $out .= "
"; $out .= ""; - $out .= "" if($seen{Begin}); - $out .= "" if($seen{End}); - $out .= "" if($seen{Timezone}); - $out .= "" if($seen{Summary}); - $out .= "" if($seen{Description}); - $out .= "" if($seen{Status}); - $out .= "" if($seen{Completion}); - $out .= "" if($seen{Location}); - $out .= "" if($seen{Map}); - $out .= "" if($seen{Calendar}); + $out .= "" if($seen{Begin}); + $out .= "" if($seen{End}); + $out .= "" if($seen{Timezone}); + $out .= "" if($seen{Summary}); + $out .= "" if($seen{Description}); + $out .= "" if($seen{Status}); + $out .= "" if($seen{Completion}); + $out .= "" if($seen{Location}); + $out .= "" if($seen{Map}); + $out .= "" if($seen{Calendar}); $out .= ""; $out .= ""; @@ -3235,8 +3257,8 @@ sub SSCal_calAsHtml($) { last if(!ReadingsVal($name, $prestr."_05_EventId", "")); # keine Ausgabe wenn es keine EventId mit Blocknummer 0 gibt -> kein Event/Aufage vorhanden $summary = ReadingsVal($name, $prestr."_01_Summary", ""); - $begin = ReadingsVal($name, $prestr."_02_Begin", "not set"); - $end = ReadingsVal($name, $prestr."_03_End", "not set"); + $begin = ReadingsVal($name, $prestr."_02_Begin", ""); + $end = ReadingsVal($name, $prestr."_03_End", ""); $desc = ReadingsVal($name, $prestr."_04_Description", ""); $location = ReadingsVal($name, $prestr."_07_Location", ""); $gpsa = ReadingsVal($name, $prestr."_08_gpsAddress", ""); @@ -3256,18 +3278,40 @@ sub SSCal_calAsHtml($) { $gps = " $img "; # Google Maps } - #$out .= ""; + if($begin ne "") { # Datum sprachabhängig konvertieren bzw. heute/morgen setzen + my ($ny,$nm,$nd,undef) = split(/[ -]/, TimeNow()); # Jetzt + my ($by,$bm,$bd,$bt) = split(/[ -]/, $begin); + my ($ey,$em,$ed,$et) = split(/[ -]/, $end); + my $ntimes = fhemTimeLocal(00, 00, 00, $nd, $nm-1, $ny-1900); + 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"; + } + + $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)); + } + + $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 .= ""; - $out .= "" if($seen{Begin}); - $out .= "" if($seen{End}); - $out .= "" if($seen{Timezone}); - $out .= "" if($seen{Summary}); - $out .= "" if($seen{Description}); - $out .= "" if($seen{Status}); - $out .= "" if($seen{Completion}); - $out .= "" if($seen{Location}); - $out .= "" if($seen{Map}); - $out .= "" if($seen{Calendar}); + $out .= "" if($seen{Begin}); + $out .= "" if($seen{End}); + $out .= "" if($seen{Timezone}); + $out .= "" if($seen{Summary}); + $out .= "" if($seen{Description}); + $out .= "" if($seen{Status}); + $out .= "" if($seen{Completion}); + $out .= "" if($seen{Location}); + $out .= "" if($seen{Map}); + $out .= "" if($seen{Calendar}); $out .= ""; }
Begin End Timezone Summary Description Status Completion
(%)
Location Map Calendar ".(($de)?'Start' :'Begin')." ".(($de)?'Ende' :'End')." ".(($de)?'Zeitzone' :'Timezone')." ".(($de)?'Zusammenfassung' :'Summary')." ".(($de)?'Beschreibung' :'Description')." ".(($de)?'Status' :'State')." ".(($de)?'Erfüllung
(%)' :'Completion
(%)')."
".(($de)?'Ort' :'Location')." ".(($de)?'Karte' :'Map')." ".(($de)?'Kalender' :'Calendar')."
$begin $end $tz $summary $desc $status $completion $location $gps $cal $begin $end $tz $summary $desc $status $completion $location $gps $cal