diff --git a/fhem/CHANGED b/fhem/CHANGED index 310f4b32c..dbd1099cc 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,10 @@ # 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. + - change: 88_Timer: Remove line end when importing file of the saved timers + Background color of the table from CSS + Correction log level + Added elevation angle attribute at sunrise / sunset + Supplement documentation - change: 49_SSCam: further optimize memory usage when send recordings by email and/or telegram - feature: 70_ZoneMinder: added support for ZoneMinder 1.32 diff --git a/fhem/FHEM/88_Timer.pm b/fhem/FHEM/88_Timer.pm index 4f41c0d1b..4bcc3f4d8 100644 --- a/fhem/FHEM/88_Timer.pm +++ b/fhem/FHEM/88_Timer.pm @@ -35,7 +35,7 @@ if ($language eq "DE") { } else { @designations = ("Sunrise","Sunset","local time","","SR","SS"); $description_all = "all"; # using in RegEx - @names = ("No.","Year","Month","Day","Hour","Minute","Second","Device or label","Action","Mon","Tue","Wed","Thu","Fri","Sat","SSn","active",""); + @names = ("No.","Year","Month","Day","Hour","Minute","Second","Device or label","Action","Mon","Tue","Wed","Thu","Fri","Sat","Sun","active",""); } ########################## @@ -44,6 +44,7 @@ sub Timer_Initialize($) { $hash->{AttrFn} = "Timer_Attr"; $hash->{AttrList} = "disable:0,1 ". + "Offset_Horizon:REAL,CIVIL,NAUTIC,ASTRONOMIC ". "Show_DeviceInfo:alias,comment ". "Timer_preselection:on,off ". "Table_Border_Cell:on,off ". @@ -372,6 +373,7 @@ sub Timer_Get($$$@) { } for (my $i=0;$i<@attr_values;$i++) { # write new attr value + chomp ($attr_values[$i]); # Zeilenende entfernen CommandAttr($hash,"$name $attr_values_names[$i] $attr_values[$i]"); } @@ -393,7 +395,7 @@ sub Timer_Attr() { my $typ = $hash->{TYPE}; if ($cmd eq "set" && $init_done == 1 ) { - Log3 $name, 3, "$name: Attr | set $attrName to $attrValue"; + Log3 $name, 5, "$name: Attr | set $attrName to $attrValue"; if ($attrName eq "disable") { if ($attrValue eq "1") { readingsSingleUpdate($hash, "internalTimer" , "stop",1); @@ -410,7 +412,7 @@ sub Timer_Attr() { } if ($cmd eq "del") { - Log3 $name, 3, "$name: Attr | Attributes $attrName deleted"; + Log3 $name, 5, "$name: Attr | Attributes $attrName deleted"; if ($attrName eq "disable") { Timer_Check($hash); } @@ -467,10 +469,10 @@ sub Timer_FW_Detail($$$$) { my $Table_Size_TextBox = AttrVal($name,"Table_Size_TextBox",20); my $Table_Style = AttrVal($name,"Table_Style","off"); my $Table_View_in_room = AttrVal($name,"Table_View_in_room","on"); - my $style_background = ""; my $style_code1 = ""; my $style_code2 = ""; my $time = FmtDateTime(time()); + my $horizon = AttrVal($name,"Offset_Horizon","REAL"); my $FW_room_dupl = $FW_room; my @timer_nr; my $cnt_max = scalar(@names); @@ -526,8 +528,8 @@ sub Timer_FW_Detail($$$$) { } $style_code2 = "border:2px solid #00FF00;" if($Table_Border eq "on"); - $html.= "
$designations[0]: ".sunrise_abs("REAL")." $designations[3]  |  $designations[1]: ".sunset_abs("REAL")." $designations[3]  |  $designations[2]: ".TimeNow()." $designations[3]
" if($Table_Header_with_time eq "on"); - $html.= "
"; + $html.= "
$designations[0]: ".sunrise_abs($horizon)." $designations[3]  |  $designations[1]: ".sunset_abs($horizon)." $designations[3]  |  $designations[2]: ".TimeNow()." $designations[3]
" if($Table_Header_with_time eq "on"); + $html.= "
"; # Timer Jahr Monat Tag Stunde Minute Sekunde Gerät Aktion Mo Di Mi Do Fr Sa So aktiv speichern # ------------------------------------------------------------------------------------------------- @@ -537,29 +539,26 @@ sub Timer_FW_Detail($$$$) { # T 1 id: 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ($id = timer_nr * 20 + $Spalte) # T 2 id: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 ($id = timer_nr * 20 + $Spalte) - ## Überschriften - $html.= ""; + ## Ueberschrift + $html.= ""; #### $style_code1 = "border:1px solid #D8D8D8;" if($Table_Border_Cell eq "on"); for(my $spalte = 0; $spalte <= $cnt_max - 1; $spalte++) { - $html.= "" if ($spalte >= 1 && $spalte <= 6); ## definierte Breite bei Auswahllisten - $html.= "" if ($spalte > 6 && $spalte < $cnt_max); ## auto Breite - $html.= "" if ($spalte == 0); ## auto Breite - $html.= "" if ($spalte == $cnt_max - 1); ## auto Breite + $html.= "" if ($spalte == 0); # Timer-Nummer - auto Breite + $html.= "" if ($spalte >= 1 && $spalte <= 6); # Dropdown-Listen - definierte Breite + $html.= "" if ($spalte > 6 && $spalte < $cnt_max - 1); # auto Breite + $html.= "" if ($spalte == $cnt_max - 1); # Button save - auto Breite } $html.= ""; for(my $zeile = 0; $zeile < $Timers_Count; $zeile++) { - $style_background = "background-color:#F0F0D8;" if ($zeile % 2 == 0); - $style_background = "" if ($zeile % 2 != 0); - $html.= ""; + $html.= sprintf("", ($zeile & 1)?"odd":"even"); my $id = $timer_nr[$zeile] * 20; # id 20, 40, 60 ... # Log3 $name, 3, "$name: Zeile $zeile, id $id, Start"; - my @select_Value = split(",", ReadingsVal($name, "Timer_".$timer_nr[$zeile], "$description_all,$description_all,$description_all,$description_all,$description_all,00,Lampe,on,0,0,0,0,0,0,0,0,,")); for(my $spalte = 1; $spalte <= $cnt_max; $spalte++) { - $style_code1 .= "Padding-bottom:5px; " if ($zeile == $Timers_Count - 1); - $html.= "" if ($spalte == 1); # Spalte Timer-Nummer + $style_code1 .= "Padding-bottom:5px; " if ($zeile == $Timers_Count - 1); # letzte Zeile + $html.= "" if ($spalte == 1); # Spalte Timer-Nummer if ($spalte >=2 && $spalte <= 7) { ## DropDown-Listen fuer Jahr, Monat, Tag, Stunde, Minute, Sekunde my $start = 0; # Stunde, Minute, Sekunde my $stop = 12; # Monat @@ -575,7 +574,7 @@ sub Timer_FW_Detail($$$$) { $id++; # Log3 $name, 3, "$name: Zeile $zeile, id $id, select"; - $html.= ""; + $html.= ""; } if ($spalte == 9) { ## DropDown-Liste Aktion $id ++; - $html.= ""; } - - ## Spalte Wochentage + aktiv + + if ($spalte > 9 && $spalte < $cnt_max) { ## Spalte Wochentage + aktiv + $id ++; + $html.= "" if ($select_Value[$spalte-2] eq "0"); + $html.= "" if ($select_Value[$spalte-2] eq "1"); + } + + if ($spalte == $cnt_max) { ## Button Speichern + $id ++; + $html.= ""; # 🖫 💾 + } Log3 $name, 5, "$name: attr2html | Timer=".$timer_nr[$zeile]." ".$names[$spalte-1]."=".$select_Value[$spalte-2]." cnt_max=$cnt_max ($spalte)" if ($spalte > 1 && $spalte < $cnt_max); - - ## existierender Timer - if ($spalte > 9 && $spalte < $cnt_max) { - $id ++; - $html.= "" if ($select_Value[$spalte-2] eq "0"); - $html.= "" if ($select_Value[$spalte-2] eq "1"); - } - ## Button Speichern - if ($spalte == $cnt_max) { - $id ++; - $html.= ""; # 🖫 💾 - } } $html.= ""; ## Zeilenende } @@ -783,7 +779,7 @@ sub Timer_delFromUserattr($$) { if (AttrVal($name, "userattr", undef) =~ /$deleteTimer/) { delFromDevAttrList($name, $deleteTimer); - Log3 $name, 3, "$name: delete $deleteTimer from userattr Attributes"; + Log3 $name, 5, "$name: delete $deleteTimer from userattr Attributes"; } } @@ -797,8 +793,9 @@ sub Timer_Check($) { my $intervall = 60; # Intervall to start new InternalTimer (standard) my $cnt_activ = 0; # counter for activ timers my ($seconds, $microseconds) = gettimeofday(); - my @sunriseValues = split(":" , sunrise_abs("REAL")); # Sonnenaufgang (06:34:24) splitted in array - my @sunsetValues = split(":" , sunset_abs("REAL")); # Sonnenuntergang (19:34:24) splitted in array + my $horizon = AttrVal($name,"Offset_Horizon","REAL"); + my @sunriseValues = split(":" , sunrise_abs($horizon)); # Sonnenaufgang (06:34:24) splitted in array + my @sunsetValues = split(":" , sunset_abs($horizon)); # Sonnenuntergang (19:34:24) splitted in array my $state;; Log3 $name, 5, "$name: Check is running, Sonnenaufgang $sunriseValues[0]:$sunriseValues[1]:$sunriseValues[2], Sonnenuntergang $sunsetValues[0]:$sunsetValues[1]:$sunsetValues[2]"; @@ -919,6 +916,13 @@ the timer uses the calculated sunset time at your location. (For this calc
  • annually, define second + minute + hour + day + month and set the value (year) to all
  • sunrise, define second & define minute + hour with SR and set all other values ​​(day, month, year) to all
  • sunset, define second & define minute + hour with SS and set all other values ​​(day, month, year) to all
  • +
    +Any interval circuits can be defined in which in the associated timer attribute e.g. the following Perl code is inserted:
    +{if ($min % 5 == 0) {fhem("set FS10_6_11 toggle");}}
    +This timer would run every 5 minutes if the timer is configured to run in a minute as described.
    +The following variables for time and date are available:
    +$sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst, $week, $hms, $hm, $md, $ymd, $we, $twe
    +This makes it possible, for example, to have a timer run every Sunday at 15:30:00.

    Define
    @@ -968,11 +972,14 @@ the timer uses the calculated sunset time at your location. (For this calc In the room Unsorted the table UI is always switched off!
    • Timer_preselection
      Sets the input values ​​for a new timer to the current time. (on | off = default)

    +
    • Offset_Horizon
      + Different elevation angles are used to calculate sunrise and sunset times.
      + (REAL = 0°, CIVIL = -6°, NAUTIC = -12°, ASTRONOMIC = -18°, default REAL)

    • Show_DeviceInfo
      Shows the additional information (alias | comment, default off)


    -Generierte Readings
    +Generated readings
    • Timer_xx
      Memory values ​​of the individual timer

    • internalTimer
      @@ -1022,6 +1029,13 @@ stellen, so nutzt der Timer den errechnenten Zeitpunkt Sonnenuntergang an Ihrem
    • jährlich, Sekunde + Minute + Stunde + Tag + Monat definieren und den Wert (Jahr) auf alle setzen
    • Sonnenaufgang, Sekunde definieren & Minute + Stunde definieren mit SA und alle anderen Werte (Tag, Monat, Jahr) auf alle setzen
    • Sonnenuntergang, Sekunde definieren & Minute + Stunde definieren mit SU und alle anderen Werte (Tag, Monat, Jahr) auf alle setzen
    +
    +Beliebige Intervallschaltungen können definiert werden, in dem im zugehörigen Timer-Attribut z.B. folgender Perl-Code eingefügt wird:
    +{if ($min % 5 == 0) {fhem("set FS10_6_11 toggle");}}
    +Dieser Timer würde dann aller 5 Minuten ausgeführt, wenn der Timer wie beschrieben auf minütliches Ausführen konfiguriert ist.
    +Folgende Variablen für Zeit- und Datumsangaben stehen zur Verfügung:
    +$sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst, $week, $hms, $hm, $md, $ymd, $we, $twe
    +Damit ist es möglich, einen Timer beispielsweise nur jeden Sonntag um 15:30:00 Uhr etwas ausführen zu lassen.

    Define
    @@ -1071,6 +1085,9 @@ stellen, so nutzt der Timer den errechnenten Zeitpunkt Sonnenuntergang an Ihrem Im Raum Unsorted ist das Tabellen UI immer abgeschalten!
    • Timer_preselection
      Setzt die Eingabewerte bei einem neuen Timer auf die aktuelle Zeit. (on | off, standard off)

    +
    • Offset_Horizon
      + Für die Berechnung der Zeiten von Sonnenaufgang und Sonnenuntergang werden verschiedene Höhenwinkel verwendet.
      + (REAL = 0°, CIVIL = -6°, NAUTIC = -12°, ASTRONOMIC = -18°, Standard REAL)

    • Show_DeviceInfo
      Blendet die Zusatzinformation ein. (alias | comment, standard off)


    ".$names[$spalte]."".$names[$spalte]."".$names[$spalte]."".$names[$spalte]."".$names[$spalte]."".$names[$spalte]."".$names[$spalte]."".$names[$spalte]."
    ".sprintf("%02s", $timer_nr[$zeile])."".sprintf("%02s", $timer_nr[$zeile])."
    $comment

    $comment