From 63beba44640dd678981bfbca082c1fc029d1d391 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Sun, 6 Aug 2017 13:50:43 +0000 Subject: [PATCH] 01_FHEMWEB.pm: add webCmdLabel (Forum #72581) git-svn-id: https://svn.fhem.de/fhem/trunk@14856 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/01_FHEMWEB.pm | 52 +++++++++++++++++++++++++++++++++++------ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index c61a9653f..c8f6f0bca 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # 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. + - feature: 01_FHEMWEB.pm: add webCmdLabel (Forum #72581) - changed: fhem.pl: search cmds via lowercase/abbrev in modules (Forum #75007) - changed: 14_CUL_TCM97001: Add rain/wind Sensor - changed: 10_IT: Add FreeTec update documentation diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index b6129aa0b..161e3aca6 100755 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -199,8 +199,8 @@ FHEMWEB_Initialize($) ############### # Initialize internal structures - map { addToAttrList($_) } ( "webCmd", "icon", "cmdIcon", "devStateIcon", - "widgetOverride", "sortby", "devStateStyle"); + map { addToAttrList($_) } ( "webCmd", "webCmdLabel:textField-long", "icon", + "cmdIcon", "devStateIcon", "widgetOverride", "sortby", "devStateStyle"); InternalTimer(time()+60, "FW_closeInactiveClients", 0, 0); $FW_dir = "$attr{global}{modpath}/www"; @@ -1701,7 +1701,14 @@ FW_makeDeviceLine($$$$$) Log 1, "ERROR: bad cmdIcon definition for $d" if(@a % 2); my %cmdIcon = @a; - foreach my $cmd (split(":", $cmdlist)) { + my @cl = split(":", $cmdlist); + my @wcl = split(":", AttrVal($d, "webCmdLabel", "")); + my $nRows; + $nRows = split("\n", AttrVal($d, "webCmdLabel", "")) if(@wcl); + @wcl = () if(@wcl != @cl); # some safety + + for(my $i1=0; $i1<@cl; $i1++) { + my $cmd = $cl[$i1]; my $htmlTxt; my @c = split(' ', $cmd); # @c==0 if $cmd==" "; if(int(@c) && $allSets && $allSets =~ m/\b$c[0]:([^ ]*)/) { @@ -1720,7 +1727,23 @@ FW_makeDeviceLine($$$$$) } else { my $nCmd = $cmdIcon{$cmd} ? FW_makeImage($cmdIcon{$cmd},$cmd,"webCmd") : $cmd; - FW_pH "cmd.$d=set $d $cmd$rf", $nCmd, 1, "col3"; + if(@wcl > $i1) { + if($nRows > 1) { + FW_pO "" if($i1 == 0); + FW_pO ""; + FW_pO "" if($wcl[$i1] =~ m/\n/); + FW_pO "
$wcl[$i1]"; + FW_pH "cmd.$d=set $d $cmd$rf", $nCmd, 0, "col3"; + FW_pO "
" if($i1 == @cl-1); + } else { + FW_pO "
$wcl[$i1] "; + FW_pH "cmd.$d=set $d $cmd$rf", $nCmd, 0, "", 0, 1; + FW_pO "
"; + } + + } else { + FW_pH "cmd.$d=set $d $cmd$rf", $nCmd, 1, "col3"; + } } } } @@ -3857,7 +3880,7 @@ FW_widgetOverride($$) attr lamp webCmd on:off:on-for-timer 10

- + The first specified command is looked up in the "set device ?" list (see the setList attribute for dummy devices). If there it contains some known modifiers (colon, followed @@ -3868,12 +3891,12 @@ FW_widgetOverride($$) attr d1 webCmd state
attr d1 readingList state
attr d1 setList state:on,off

- + define d2 dummy
attr d2 webCmd state
attr d2 readingList state
attr d2 setList state:slider,0,1,10

- + define d3 dummy
attr d3 webCmd state
attr d3 readingList state
@@ -3885,6 +3908,13 @@ FW_widgetOverride($$)
+ +
  • webCmdLabel
    + Colon separated list of labels, used to prefix each webCmd. The number + of labels must exactly match the number of webCmds. To implement + multiple rows, insert a return character after the text and before the + colon.

  • +
  • webname
    Path after the http://hostname:port/ specification. Defaults to fhem, @@ -4665,6 +4695,14 @@ FW_widgetOverride($$) nicht für die FHEMWEBInstanz.

  • + +
  • webCmdLabel
    + Durch Doppelpunkte getrennte Auflistung von Texten, die vor dem + jeweiligen webCmd angezeigt werden. Der Anzahl der Texte muss exakt den + Anzahl der webCmds entsprechen. Um mehrzeilige Anzeige zu realisieren, + kann ein Return nach dem Text und vor dem Doppelpunkt eingefuehrt + werden.

  • +
  • webname
    Der Pfad nach http://hostname:port/ . Standard ist fhem,