From b01e0909032aa7bfc53a1115ea5991e393b6e4a3 Mon Sep 17 00:00:00 2001 From: ulimaass <> Date: Thu, 19 Jun 2014 07:14:56 +0000 Subject: [PATCH] added style "commands only", changed html-method "get" to "$FW_formmethod" git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@6139 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/95_FLOORPLAN.pm | 45 ++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/FHEM/95_FLOORPLAN.pm b/FHEM/95_FLOORPLAN.pm index cf547cbc4..54517ee6c 100644 --- a/FHEM/95_FLOORPLAN.pm +++ b/FHEM/95_FLOORPLAN.pm @@ -4,7 +4,7 @@ # Feedback: http://groups.google.com/group/fhem-users # Define Custom Floorplans # Released : 26.02.2012 -# Version : 2.0 +# Version : 2.1 # Revisions: # 0001: Released to testers # 0002: use local FP_select and FP_submit after clash with FHEMWEB update @@ -44,12 +44,13 @@ # 0033: Updated loglevel -> verbose, added fp_roomIcons (Feb 2, 2014) # 0034: iOS fullscreen app - navigating to other floorplan doesn't open safari anymore (Feb 15, 2014) # 0035: added allowedCommands-Attribute based on FHEMWEB (Feb 20, 2014) +# 0036: added style "commands only", changed html-method "get" to "$FW_formmethod" (June 19, 2014) # ################################################################ # # Copyright notice # -# (c) 2012-2013 Copyright: Ulrich Maass +# (c) 2012-2014 Copyright: Ulrich Maass # # This file is part of fhem. # @@ -142,7 +143,7 @@ my $FW_plotmode=""; # like in FHEMWEB: SVG my $FW_plotsize; # like in FHEMWEB: like in fhemweb dependent on regular/smallscreen/touchpad my %FW_zoom; # copied from FHEMWEB - using local version to avoid global variable my @FW_zoom; # copied from FHEMWEB - using local version to avoid global variable -my @styles = ("0 (Icon only)","1 (Name+Icon)","2 (Name+Icon+Commands)","3 (Device-Reading)","4 (S300TH-specific)","5 (Icon+Commands)","6 (Reading+Timestamp)"); +my @styles = ("0 (Icon only)","1 (Name+Icon)","2 (Name+Icon+Commands)","3 (Device-Reading)","4 (S300TH-specific)","5 (Icon+Commands)","6 (Reading+Timestamp)","7 (Commands only)"); #------------------------------------------------------------------------------- @@ -227,6 +228,12 @@ FP_CGI(){ $params[1] = $params[2]; } my @htmlpart = split("\\?", $params[1]) if ($params[1]); # split URL by ? -> htmlpart[0] = FP_name, htmlpart[1] = commandstring + if (!$htmlpart[1] && $htmlpart[0] !~ "\\?") { # in case of 'post' URL does not contain ? + $htmlpart[0] =~ /([a-z0-9.:_]+)&(.*)/i; + $htmlpart[1] = $2 if ($2); + $htmlpart[1] =~ s/\\+/&/g if ($htmlpart[1]); + $htmlpart[0] = $1 if ($1); + } $FP_name = $htmlpart[0] if (!$FP_name); ### set global parameters, check floorplan-name if ($FP_name) { # floorplan-name is part of URL @@ -258,6 +265,7 @@ FP_CGI(){ $FW_subdir = "/floorplan/$FP_name"; $FP_arrange = AttrVal($FP_name, "fp_arrange", 0); } + ## process cgi my $commands = FP_digestCgi($htmlpart[1]) if $htmlpart[1]; # analyze URL-commands my $FP_ret = AnalyzeCommand(undef, $commands, @@ -310,8 +318,9 @@ FP_digestCgi($) { $FP_fwdetail = undef; $arg =~ s,^[?/],,; foreach my $pv (split("&", $arg)) { #per each URL-section devided by & + next if($pv eq ""); # happens when post forgot to set FW_ME $pv =~ s/\+/ /g; - $pv =~ s/%(..)/chr(hex($1))/ge; + $pv =~ s/%([\dA-F][\dA-F])/chr(hex($1))/ige; my ($p,$v) = split("=",$pv, 2); #$p = parameter, $v = value $v =~ s/[\r]\n/\\\n/g if($v && $p && $p ne "data"); # Multiline: escape the NL for fhem $FP_webArgs{$p} = $v; @@ -408,7 +417,7 @@ FP_showStart() { FW_pO "
"; FP_menu(); FW_pO "
"; - FW_pO "
"; + FW_pO ""; FW_pO ""; FW_pO ""; #input-field FW_pO "
"; @@ -474,7 +483,7 @@ FP_show(){ $style = 0 if (!$style); # start device-specific table FW_pO "\n
"; - FW_pO ""; + FW_pO ""; FW_pO " "; # Main table per device my ($allSets, $cmdlist, $txt) = FW_devState($d, ""); $txt = ReadingsVal($d, $text, "Undefined Reading $d-$text") if ($style == 3 || $style == 6); # Style3+6 = DeviceReading given in $text @@ -482,7 +491,7 @@ FP_show(){ ######################## # Device-name per device - if ($style gt 0 && $style ne 5) { + if ($style gt 0 && $style ne 5 && $style ne 7) { FW_pO " "; # For css: class=devicename, id=-devicename my $devName = ""; if ($style == 3 || $style == 6) { @@ -501,10 +510,11 @@ FP_show(){ ######################## # Device-state per device # FW_pO ""; # For css: class=devicestate, id=devicename + if ($style != 7) { if ($style == 3 || $style == 6) { FW_pO ""; # For css: class=devicereading, id=- - } else { - FW_pO ""; # For css: class=devicestate, id= + } else { + FW_pO ""; # For css: class=devicestate, id= } $txt =~ s/measured-temp: ([\.\d]*) \(Celsius\)/$1/; # format FHT-temperature ### use device-specific icons according to userattr fp_image or fp_.image @@ -530,7 +540,7 @@ FP_show(){ FW_pO ""; - + } if ($style == 6) { # add ReadingsTimeStamp for style 6 $txt=""; FW_pO ""; # For css: class=devicetimestamp, id=-devicetimestamp @@ -542,7 +552,7 @@ FP_show(){ ######################## # Commands per device - if($cmdlist && ( $style == 2 || $style == 5) ) { + if($cmdlist && ( $style == 2 || $style == 5 || $style == 7) ) { my @cList = split(":", $cmdlist); my @rList = map { ReplaceEventMap($d,$_,1) } @cList; my $firstIdx = 0; @@ -623,7 +633,7 @@ FP_menu() { FW_pH "$FW_ME", "fhem", 1; FW_pO ""; foreach my $f (sort keys %defs) { - next if ($defs{$f}{TYPE} ne "FLOORPLAN"); + next if (!$defs{$f}{TYPE} || $defs{$f}{TYPE} ne "FLOORPLAN"); FW_pO ""; my $icoName = "ico$f"; map { my ($n,$v) = split(":",$_); $icoName=$v if($f =~ m/$n/); } @@ -649,8 +659,9 @@ FP_menuArrange() { my @nfpl; # devices not assigned to floorplan foreach my $d (sort keys %defs) { # loop all devices my $type = $defs{$d}{TYPE}; + $type = '?' if (!$type); # exclude these types from list of available devices - next if($type =~ m/^(WEB|CUL$|FHEM.*|FileLog|PachLog|PID|SUNRISE.*|FLOORPLAN|holiday|Global|notify|autocreate)/ ); + next if ($type =~ m/^(WEB|CUL$|FHEM.*|FileLog|PachLog|PID|SUNRISE.*|FLOORPLAN|holiday|Global|notify|autocreate)/ ); my $disp = $d; $disp .= ' (' . AttrVal($d,"room","Unsorted").") $type"; my $alias = AttrVal($d, "alias", undef); @@ -671,7 +682,7 @@ FP_menuArrange() { # add device to floorplan if (!defined($FP_arrange_selected)) { - FW_pO ""; #form1 + FW_pO ""; #form1 FW_pO "
\n" . ($FP_fwdetail?FP_input("detl.$FP_fwdetail", $FP_fwdetail, "hidden") . "\n" :"") . FW_select("","add.dev", \@nfpl, "", "menu-add") . @@ -683,7 +694,7 @@ FP_menuArrange() { if (!defined($FP_arrange_selected)) { my $dv = $FP_arrange_default; $dv = $desc{$dv} if ($dv); - FW_pO ""; #form2 + FW_pO ""; #form2 FW_pO "
\n" . ($FP_fwdetail?FP_input("detl.$FP_fwdetail", $FP_fwdetail, "hidden") . "\n" :"") . FW_select("","arr.dev", \@fpl, $dv, "menu-select") . @@ -710,7 +721,7 @@ FP_menuArrange() { } ### build the form my $disp = $FP_arrange eq "detail" ? $desc{$d} : $d; - FW_pO ""; #form3 + FW_pO ""; #form3 my ($top, $left, $style, $text, $text2) = split(",", $attrd); $text .= ','.$text2 if ($text2); # re-append Description after reading-ID for style3 $style = $styles[$style]; @@ -921,6 +932,7 @@ FP_pOfill($@) {
  • 4 S300TH-specific, displays temperature above humidity
  • 5 icon/state and commands
  • 6 device-reading, reading-timestamp and optional description
  • +
  • 7 commands only
  • description will be displayed instead of the original devicename
  • @@ -1089,6 +1101,7 @@ FP_pOfill($@) {
  • 4 S300TH-spezifisch, zeigt Temperatur und Luftfeuchtigkeit an
  • 5 icon/Status und Kommandos (ohne Gerätename)
  • 6 Geräte-reading, Zeitstempel und optionale Beschreibung
  • +
  • 7 nur Kommandos
  • Eine ggf. angegebene Bschreibung wird anstelle des original-Gerätenamens angezeigt.
  • $txt"; # state } FW_pO "