diff --git a/fhem/FHEM/98_DOIF.pm b/fhem/FHEM/98_DOIF.pm index 1e4b9910d..c5fee04fe 100644 --- a/fhem/FHEM/98_DOIF.pm +++ b/fhem/FHEM/98_DOIF.pm @@ -104,7 +104,7 @@ sub DOIF_Initialize($) $hash->{FW_deviceOverview} = 1; $hash->{FW_addDetailToSummary} = 1; $hash->{FW_detailFn} = "DOIF_detailFn"; - #hash->{FW_summaryFn} = "DOIF_summaryFn"; + $hash->{FW_summaryFn} = "DOIF_summaryFn"; #$hash->{FW_atPageEnd} = 1; $data{FWEXT}{DOIF}{SCRIPT} = "doif.js"; @@ -412,21 +412,18 @@ sub parse_tpl my ($hash,$wcmd,$table) = @_; my $d=$hash->{NAME}; my $err=""; -## while ($wcmd =~ /(?:^|\n)\s*IMPORT\s*(.*)(\n|$)/g) { + $hash->{$table}{header}=""; + while ($wcmd =~ /\s*IMPORT\s*(.*)(\n|$)/g) { $err=import_tpl($hash,$1,$table); return ($err,"") if ($err); } - - #$wcmd =~ s/(^|\n)\s*\#.*(\n|$)/\n/g; - #$wcmd =~ s/(#.*\n)|(#.*$)|\n/ /g; + $wcmd =~ s/(##.*\n)|(##.*$)/\n/g; - ##$wcmd =~ s/(^|\n)\s*IMPORT.*(\n|$)//g; + $wcmd =~ s/\s*IMPORT.*(\n|$)//g; $wcmd =~ s/\$TPL\{/\$hash->\{$table\}\{template\}\{/g; - #$wcmd =~ s/\$TD{/\$hash->{$table}{td}{/g; - #$wcmd =~ s/\$TC{/\$hash->{$table}{tc}{/g; $wcmd =~ s/\$ATTRIBUTESFIRST/\$hash->{$table}{attributesfirst}/; $wcmd =~ s/\$TC\{/\$hash->{$table}{tc}\{/g; @@ -665,23 +662,27 @@ sub DOIF_RegisterEvalAll my $ret = ""; my $reg=1; return undef if (!defined $hash->{$table}{table}); - #$ret =~ s/class\=\'block\'/$hash->{$table}{table}/ if($hash->{$table}{table}); + if ($table eq "uiTable") { - $ret.= "\n"; + $ret.= "\n
{$table}{shownostate} ? $hash->{$table}{shownostate} : "")."'"; + $ret.=" doifnodevline='".($hash->{$table}{shownodeviceline} ? $hash->{$table}{shownodeviceline} : "")."'"; + $ret.=" doifattrfirst='".($hash->{$table}{attributesfirst} ? $hash->{$table}{attributesfirst} : "")."'"; + $ret.= ">"; $hash->{$table}{header}= "\n
"; - #$ret .= "\n
"; } else { - $ret .= "\n
"; + $ret.= "\n
{$table}{attributesfirst} ? $hash->{$table}{attributesfirst} : "")."'"; + $ret.= ">"; + $hash->{$table}{header}= "\n
"; } + + my $class=""; my $lasttr =scalar keys %{$hash->{$table}{table}}; for (my $i=0;$i < $lasttr;$i++){ - my $class = ($i&1)?"class='odd'":"class='even'"; + if ($table eq "uiTable") { + $class = ($i&1)?"class='odd'":"class='even'"; + } $ret .="{$table}{tr}{$i}) ? $hash->{$table}{tr}{$i}:""); $ret .=" ".(($i&1) ? $hash->{$table}{tr}{odd}:"") if (defined $hash->{$table}{tr}{odd}); @@ -3707,7 +3708,7 @@ DOIF_Define($$$) } else { $hash->{MODEL}="Perl"; #$defs{$hash->{NAME}}{".AttrList"} = "disable:0,1 loglevel:0,1,2,3,4,5,6 startup state initialize notexist checkReadingEvent:1,0 addStateEvent:1,0 weekdays setList:textField-long readingList DOIF_Readings:textField-long uiTable:textField-long ".$readingFnAttributes; - setDevAttrList($hash->{NAME},"disable:0,1 loglevel:0,1,2,3,4,5,6 notexist checkReadingEvent:0,1 addStateEvent:1,0 weekdays setList:textField-long readingList DOIF_Readings:textField-long event_Readings:textField-long uiTable:textField-long ".$readingFnAttributes); + setDevAttrList($hash->{NAME},"disable:0,1 loglevel:0,1,2,3,4,5,6 notexist checkReadingEvent:0,1 addStateEvent:1,0 weekdays setList:textField-long readingList DOIF_Readings:textField-long event_Readings:textField-long uiState:textField-long uiTable:textField-long ".$readingFnAttributes); ($msg,$err)=CmdDoIfPerl($hash,$cmd); } if ($err ne "") { @@ -4354,18 +4355,19 @@ sub widget { } sub shutter { - my ($value,$color,$type)=@_; + my ($value,$color,$type,$coloroff)=@_; $color="\@darkorange" if (!defined ($color) or $color eq ""); + $coloroff="" if (!defined ($coloroff)); if (!defined ($type) or $type == 3) { - return ($value,"","iconRadio,$color,100,fts_shutter_10,30,fts_shutter_70,0,fts_shutter_100","set"); + return ($value,"","iconRadio,$color,100,fts_shutter_10$coloroff,30,fts_shutter_70$coloroff,0,fts_shutter_100$coloroff","set"); } elsif ($type == 4) { - return ($value,"","iconRadio,$color,100,fts_shutter_10,50,fts_shutter_50,30,fts_shutter_70,0,fts_shutter_100","set"); + return ($value,"","iconRadio,$color,100,fts_shutter_10$coloroff,50,fts_shutter_50$coloroff,30,fts_shutter_70$coloroff,0,fts_shutter_100$coloroff","set"); } elsif ($type == 5) { - return ($value,"","iconRadio,$color,100,fts_shutter_10,70,fts_shutter_30,50,fts_shutter_50,30,fts_shutter_70,0,fts_shutter_100","set"); + return ($value,"","iconRadio,$color,100,fts_shutter_10$coloroff,70,fts_shutter_30$coloroff,50,fts_shutter_50$coloroff,30,fts_shutter_70,0,fts_shutter_100$coloroff","set"); } elsif ($type >= 6) { - return ($value,"","iconRadio,$color,100,fts_shutter_10,70,fts_shutter_30,50,fts_shutter_50,30,fts_shutter_70,20,fts_shutter_80,0,fts_shutter_100","set"); + return ($value,"","iconRadio,$color,100,fts_shutter_10$coloroff,70,fts_shutter_30$coloroff,50,fts_shutter_50$coloroff,30,fts_shutter_70$coloroff,20,fts_shutter_80$coloroff,0,fts_shutter_100$coloroff","set"); } elsif ($type == 2) { - return ($value,"","iconRadio,$color,100,fts_shutter_10,0,fts_shutter_100","set"); + return ($value,"","iconRadio,$color,100,fts_shutter_10$coloroff,0,fts_shutter_100$coloroff","set"); } } @@ -7264,10 +7266,20 @@ attr di_web setList myInput:first,second
Mit dem Attribut uiTable kann innerhalb eines DOIF-Moduls ein Web-Interface zur Visualisierung und Steuerung von Geräten in Form einer Tabelle erstellt werden.

-Die Dokumentation zu diesem Attribut wurde mit bebilderten Beispielen im FHEM-Wiki erstellt: uiTable Dokumentation
+Die Dokumentation zu diesem Attribut wurde mit bebilderten Beispielen im FHEM-Wiki erstellt: uiTable/uiState Dokumentation

Anwendungsbeispiele für Fortgeschrittene: uiTable für Fortgeschrittene im FHEM-Wiki

+
  • +uiState   back
    +
    + +Die Syntax des uiState-Attributes entspicht der des uiTable-Attributes. Die definierte Tabelle wird jedoch in der Statuszeile des DOIF-Devices dargestellt.
    +
    +Dieses Attribut ist nur im Perl-Modus verfügbar.
    +
    +Siehe Dokumentation: uiTable/uiState Dokumentation
    +
  • Status des Moduls   back

    @@ -8267,6 +8279,7 @@ Wenn <blocking function>, <finish function> und < readingList   setList   uiTable   + uiState   weekdays  
    readingFnAttributes   @@ -8288,11 +8301,11 @@ Wenn <blocking function>, <finish function> und <
    Treppenhauslicht mit Bewegungsmelder

    -define di_light DOIF {
    -  if (["FS:motion"]) {                          # bei Bewegung
    -    fhem_set("lamp on") if ([?lamp] ne "on");   # Lampe einschalten, wenn sie nicht an ist
    -    set_Exec("off",30,'fhem_set("lamp off")');  # Timer namens "off" für das Ausschalten der Lampe auf 30 Sekunden setzen bzw. verlängern
    -  }
    +defmod di_light DOIF {\
    +  if (["FS:motion"]) {                          # bei Bewegung\
    +    fhem_set("lamp on") if ([?lamp] ne "on");;  # Lampe einschalten, wenn sie nicht an ist\
    +    set_Exec("off",30,'fhem_set("lamp off")');; # Timer namens "off" für das Ausschalten der Lampe auf 30 Sekunden setzen bzw. verlängern\
    +  }\
    }

    @@ -8301,13 +8314,13 @@ define di_light DOIF {
    Anforderung: Wenn eine Taste innerhalb von zwei Sekunden zwei mal betätig wird, soll der Rollladen nach oben, bei einem Tastendruck nach unten.

    -define di_shutter DOIF {
    -  if (["FS:^on$"] and !get_Exec("shutter")){          # wenn Taste betätigt wird und kein Timer läuft
    -    set_Exec("shutter",2,'fhem_set("shutter down")'); # Timer zum shutter down auf zwei Sekunden setzen
    -  } else {                                            # wenn Timer läuft, d.h. ein weitere Tastendruck innerhalb von zwei Sekunden
    -    del_Exec("shutter");                              # Timer löschen
    -    fhem_set("shutter up");                           # Rollladen hoch
    -  }
    +defmod di_shutter DOIF {\
    +  if (["FS:^on$"] and !get_Exec("shutter")){          # wenn Taste betätigt wird und kein Timer läuft\
    +    set_Exec("shutter",2,'fhem_set("shutter down")');;#Timer zum shutter down auf zwei Sekunden setzen\
    +  } else {                                            # wenn Timer läuft, d.h. ein weitere Tastendruck innerhalb von zwei Sekunden\
    +    del_Exec("shutter");;                             # Timer löschen\
    +    fhem_set("shutter up");;                          # Rollladen hoch\
    +  }\
    }

    @@ -8316,13 +8329,13 @@ define di_shutter DOIF {
    Im folgenden Beispiel wird die Nutzung von Device-Variablen demonstriert.

    -define di_count DOIF {
    -  if (["FS:on"] and !get_Exec("counter")) {                                        # wenn Ereignis (hier "FS:on") eintritt und kein Timer läuft
    -    $_count=1;                                                                     # setze count-Variable auf 1
    -    set_Exec("counter",3600,'Log (3,"count: $_count action") if ($_count > 10)');  # setze Timer auf eine Stunde zum Protokollieren der Anzahl der Ereignisse, wenn sie über 10 ist
    -  } else {
    -    $_count++;                                                                     # wenn Timer bereits läuft zähle Ereignis
    -  }
    +defmod di_count DOIF {\
    +  if (["FS:on"] and !get_Exec("counter")) {                                        # wenn Ereignis (hier "FS:on") eintritt und kein Timer läuft\
    +    $_count=1;;                                                                    # setze count-Variable auf 1\
    +    set_Exec("counter",3600,'Log (3,"count: $_count action") if ($_count > 10)');; # setze Timer auf eine Stunde zum Protokollieren der Anzahl der Ereignisse, wenn sie über 10 ist\
    +  } else {\
    +    $_count++;;                                                                    # wenn Timer bereits läuft zähle Ereignis\
    +  }\
    }