95_FLOORPLAN.pm 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. ################################################################################
  2. # 95 FLOORPLAN
  3. # $Id: 95_FLOORPLAN.pm 11443 2016-05-15 14:17:21Z ulimaass $
  4. # Feedback: http://groups.google.com/group/fhem-users
  5. # Define Custom Floorplans
  6. # Released : 26.02.2012
  7. # Version : 2.1
  8. # Revisions:
  9. # 0001: Released to testers
  10. # 0002: use local FP_select and FP_submit after clash with FHEMWEB update
  11. # 0003: FP_arrange_default repaired
  12. # 0004: WebApp-enabled links in floorplanlist, fixed message 'use of uninitialized value' (FW_pO - $FP_name)
  13. # 0005: Change arrange-mode: When selected, display device-name instead of selection
  14. # 0006: kicked out various routines previously copied from FHEMWEB - now using FW_*-versions thanks to addtl. global variables $FW_RET, $FW_wname, $FW_subdir, %FW_pos
  15. # 0007: Added fp_default
  16. # 0008: Changed name of background-picture from <floorplan-name> to fp_<floorplan-name> to avoid display of picture in device-list at fhem-menu 'Everything'
  17. # -> general release
  18. # 0009: updated selection of add-device-list: suppress CUL$ only (instead of CUL.*)
  19. # 0010: Added Style3, fp_stylesheetPrefix, fp_noMenu (Mar 13, 2012)
  20. # 0011: Added Style4, code beautification, css review, minor $text2-fix (SVN 1342)
  21. # 0012: Added startscreen-text when no floorplans defined, fixed startscreen-stylesheet, added div for bg-img, added arrangeByMouse (1368)
  22. # 0013: implemented redirectCmd, fixed minor </td></tr>-error in html-output, fp_arrange for single web-devices, fp_arrange detail (Mar 23, 2012)
  23. # 0014: deleted $data{FWEXT}{$fhem_url}{STYLESHEET} , added attr-values for FHEMWEB-detail-screen, adapted FHT-representation to FHT.pm updates (Apr 19, 2012)
  24. # 0015: implemented Tobias' icon subfolder solution, fp_arrange detail always (fp_arrange detail deprecated, fp_arrange 1 shows all detail),
  25. # changed backimg-size to 99% to avoid scrollbars , adopted slider & new FHT representation (May 1, 2012)
  26. # 0016: Minor repair of html-output, allowed devices with dot in name (May 2, 2012)
  27. # 0017: updating for changes in fhemweb: css-path, bgimg-path, deactivating rereadicons (July 30, 2012)
  28. # 0018: Changes by Boris (icon-paths, fp_stylesheetPrefix -> stylesheet
  29. # 0019: added fp_backgroundimg (October 15, 2012)
  30. # 0020: moved creation of userattr to define, added slider and timepicker and setList, added style5 icon+commands, added style 6 readingstimestamp,
  31. # added style-descriptions in fp-arrange (October 22, 2012)
  32. # 0021: fixed http-header, unsetting FF-autocomplete, added attribute fp_setbutton (fixes by Matthias) (November 23, 2012)
  33. # 0022: longpoll by Matthias Gehre (November 27, 2012)
  34. # 0023: longpoll updates readings also - by Matthias Gehre; FW_longpoll is now a global variable (January 21, 2013)
  35. # 0024: fix for readings longpoll, added js-extension from Dirk (February 16, 2013)
  36. # 0025: Added fp_viewport-attribute from Jens (March 03, 2013)
  37. # 0026: Adapted to FHEMWEB-changes re webCmdFn - fp_setbutton not functional (May 23, 2013)
  38. # 0027: Added FP_detailFn(), added delete-button in arrange-menu, fixed link for pdf-docu, minor code cleanup, added get config (July 08, 2013)
  39. # 0028: Implemented informid for longpoll, usage of @FW_fhemwebjs (July 19, 2013)
  40. # 0029: Fixed floorplan-specific icons and eliminated FHT-text "desired-temp" - both due to changes in fhemweb (Sep 29, 2013)
  41. # 0030: Style4 (S300TH) now works with longpoll without loosing its formatting (Dec 24, 2013)
  42. # 0031: Text "desiredTemperature" will also be eliminated - for MAX devices (Dec 25, 2013)
  43. # 0032: Ensure URL always contains floorplan-name (redirect if !htmlarg[0]) as basis for fp-specific icon-folder (Jan 06, 2014)
  44. # 0033: Updated loglevel -> verbose, added fp_roomIcons (Feb 2, 2014)
  45. # 0034: iOS fullscreen app - navigating to other floorplan doesn't open safari anymore (Feb 15, 2014)
  46. # 0035: added allowedCommands-Attribute based on FHEMWEB (Feb 20, 2014)
  47. # 0036: added style "commands only", changed html-method "get" to "$FW_formmethod" (June 19, 2014)
  48. # 0037: updated to match fhemweb.js developments (Rudi, Jan 17, 2015)
  49. # 0038: added arrange by drag&drop provided by Markus (mluckey), added longpollfilter (nesges),
  50. # added processing of global userattr fp_<name> and their value per device for rename, copy, delete (Jan 31, 2015)
  51. # 0039: added style 8 for commands-popup provided by André (justme68) (Feb 17, 2015)
  52. # 0040: fixed "no commands for IT devices", drag&drop won't switch device-status anymore (June 15, 2015)
  53. # 0041: fixed eventmap, excess "delete"-messages during rereadconfig (Sept 24, 2015)
  54. # 0042: fixed log-errors, for commandref changed link to german installation guide in fhemwiki (Nov 21, 2015)
  55. # 0043: fixed erroneous replacement of own devicename by actual devicename upon drag&drop (May 15,2016)
  56. #
  57. ################################################################
  58. #
  59. # Copyright notice
  60. #
  61. # (c) 2012-2016 Copyright: Ulrich Maass
  62. #
  63. # This file is part of fhem.
  64. #
  65. # Fhem is free software: you can redistribute it and/or modify
  66. # it under the terms of the GNU General Public License as published by
  67. # the Free Software Foundation, either version 2 of the License, or
  68. # (at your option) any later version.
  69. #
  70. # Fhem is distributed in the hope that it will be useful,
  71. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  72. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  73. # GNU General Public License for more details.
  74. #
  75. # You should have received a copy of the GNU General Public License
  76. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
  77. #
  78. ################################################################################
  79. # Usage
  80. # define <NAME> FLOORPLAN
  81. #
  82. # Step-by-Step HowTo - mind all is case sensitive:
  83. # Step 1:
  84. # define <name> FLOORPLAN
  85. # Example: define Groundfloor FLOORPLAN
  86. #
  87. # Step 2:
  88. # store picture fp_<name>.png in your imagepath. This will be used as background-picture.
  89. # Example: fhem/www/images/default/Groundfloor.png
  90. #
  91. # Step 3:
  92. # Activate 'Arrange-Mode' to have user-friendly fields to move items:
  93. # attr <floorplanname> fp_arrange 1
  94. # Example: attr Groundfloor fp_arrange 1
  95. # Delete this attribute when you're done with setup
  96. # Arrange-Mode displays a popup to add and edit how devices will be shown. Arrange devices using drag&drop.
  97. # When adding objects to your floorplan, they will thereby get assigned
  98. # attr <device> fp_<name> <top>,<left>,<style>,<text>
  99. # displays <device> on floorplan <name> at position top:<top>,left:<left> with style <style> and description <text>
  100. # Example: attr lamp fp_Groundfloor 100,100,1,TableLamp #displays lamp at position 100px,100px
  101. #
  102. # Repeat step 3 to add further devices. Delete attr fp_arrange when all devices are arranged on your screen. Enjoy.
  103. #
  104. # Check the colorful pdf-docu in http://sourceforge.net/p/fhem/code/HEAD/tree/trunk/fhem/docs/fhem-floorplan-installation-guide_de.pdf
  105. #
  106. ################################################################################
  107. package main;
  108. use strict;
  109. use warnings;
  110. use vars qw(%data);
  111. use vars qw($FW_longpoll);
  112. use vars qw(@FW_fhemwebjs); # List of fhemweb*js scripts to load - from FHEMWEB
  113. #########################
  114. # Forward declaration
  115. sub FLOORPLAN_Initialize($); # Initialize
  116. sub FP_define(); # define <name> FLOORPLAN
  117. sub FP_undefine($$); # delete <name>
  118. sub FP_rename($$); # rename <old> <new>
  119. sub FP_copy($$); # copy <old> <new>
  120. sub FP_copy_rename_delete($$$); # exec for copy, rename, delete
  121. sub FP_Get($@); # get-command
  122. sub FP_CGI(); # analyze URL
  123. sub FP_digestCgi($); # digest CGI
  124. sub FP_htmlHeader($); # html page - header
  125. sub FP_menu(); # html page - menu left - floorplan-list
  126. sub FP_menuArrange(); # html page - menu bottom - arrange-mode
  127. sub FP_showstart(); # html page - startscreen
  128. sub FP_show(); # produce floorplan
  129. sub FP_input(@); # prepare selection list for forms
  130. sub FP_detailFn($$$$); # floorplan-specific detail-screen in fhemweb
  131. sub FP_getConfig($); # display floorplan configuration
  132. sub FP_pOfill($@); # print line filled up with hash-signs
  133. #########################
  134. # Global variables
  135. # $ret_html; # from FHEMWEB: Returned data (html)
  136. my $FP_name; # current floorplan-name
  137. my $FP_arrange; # arrange-mode
  138. my $FP_arrange_selected; # device selected to be arranged
  139. my $FP_arrange_default; # device selected in previous round
  140. my %FP_webArgs = (); # sections of analyzed URL
  141. my $FP_fwdetail; # set when floorplan is called from fhemweb-detailscreen
  142. my $FP_viewport; # Define width for touchpad device
  143. # $FW_ME # from FHEMWEB: fhem URL
  144. # $FW_tp # from FHEMWEB: is touchpad
  145. # $FW_ss # from FHEMWEB: is smallscreen
  146. # $FW_longpoll; # from FHEMWEB: longpoll
  147. # $FW_wname; # from FHEMWEB: name of web-instance
  148. # %FW_pos=(); # from FHEMWEB: scroll position
  149. # $FW_subdir # from FHEMWEB: path of floorplan-subdir - enables reusability of FHEMWEB-routines for sub-URLS like floorplan
  150. # $FW_cname # from FHEMWEB: Current connection name
  151. my $FW_encoding="UTF-8"; # like in FHEMWEB: encoding hardcoded
  152. my $FW_plotmode=""; # like in FHEMWEB: SVG
  153. my $FW_plotsize; # like in FHEMWEB: like in fhemweb dependent on regular/smallscreen/touchpad
  154. my %FW_zoom; # copied from FHEMWEB - using local version to avoid global variable
  155. my @FW_zoom; # copied from FHEMWEB - using local version to avoid global variable
  156. my @styles = ("0 (Icon only)","1 (Name+Icon)","2 (Name+Icon+Commands)","3 (Device-Reading)","4 (S300TH-specific)","5 (Icon+Commands)",
  157. "6 (Reading+Timestamp)","7 (Commands only)","8 (Icon+Commands popup)");
  158. #-------------------------------------------------------------------------------
  159. ##################
  160. # method 'initialize'
  161. sub
  162. FLOORPLAN_Initialize($)
  163. {
  164. my ($hash) = @_;
  165. $hash->{DefFn} = "FP_define";
  166. $hash->{UndefFn} = "FP_undefine";
  167. $hash->{RenameFn} = "FP_rename";
  168. $hash->{CopyFn} = "FP_copy";
  169. $hash->{GetFn} = "FP_Get";
  170. $hash->{FW_detailFn} = "FP_detailFn"; #floorplan-specific detail-screen
  171. $hash->{AttrList} = "refresh fp_arrange:1,detail,WEB,0 commandfield:1,0 fp_default:1,0 ".
  172. "stylesheet fp_noMenu:1,0 fp_backgroundimg fp_setbutton:1,0 fp_viewport ".
  173. "CssFiles JavaScripts fp_roomIcons ";
  174. # CGI
  175. my $name = "floorplan";
  176. my $fhem_url = "/" . $name ;
  177. $data{FWEXT}{$fhem_url}{FUNC} = "FP_CGI";
  178. $data{FWEXT}{$fhem_url}{LINK} = $name;
  179. $data{FWEXT}{$fhem_url}{NAME} = "Floorplans";
  180. $modules{_internal_}{AttrList} .= " VIEW_CSS"; # Global-Config for CSS
  181. my $n = 0;
  182. @FW_zoom = ("qday", "day","week","month","year"); #copied from FHEMWEB - using local version to avoid global variable
  183. %FW_zoom = map { $_, $n++ } @FW_zoom; #copied from FHEMWEB - using local version to avoid global variable
  184. return undef;
  185. }
  186. #-------------------------------------------------------------------------------
  187. ##################
  188. # method 'define'
  189. sub
  190. FP_define(){
  191. my ($hash, $def) = @_;
  192. $hash->{STATE} = 'Defined';
  193. my $name = $hash->{NAME};
  194. if (AttrVal("global","userattr","") !~ m/fp_$name/) {
  195. addToAttrList("fp_$name"); # create userattr fp_<name> if it doesn't exist yet
  196. Log3 $name, 3, "Floorplan - added global userattr fp_$name";
  197. }
  198. return undef;
  199. }
  200. #-------------------------------------------------------------------------------
  201. ##################
  202. # method 'undefine'
  203. sub
  204. FP_undefine($$) {
  205. my ($hash,$arg) = @_;
  206. FP_copy_rename_delete('delete',$hash->{NAME},undef) if ($reread_active != 1); # do not execute during rereadcfg
  207. return undef;
  208. }
  209. #-------------------------------------------------------------------------------
  210. ##################
  211. # FLOORPLAN rename
  212. sub
  213. FP_rename($$) {
  214. my ($new,$old) = @_;
  215. FP_copy_rename_delete('rename',$old,$new);
  216. return undef;
  217. }
  218. #-------------------------------------------------------------------------------
  219. ##################
  220. # FLOORPLAN copy
  221. sub
  222. FP_copy($$) {
  223. my ($old,$new) = @_;
  224. FP_copy_rename_delete('copy',$old,$new);
  225. return undef;
  226. }
  227. #-------------------------------------------------------------------------------
  228. ##################
  229. # FLOORPLAN copy_rename_delete
  230. sub
  231. FP_copy_rename_delete($$$) {
  232. my ($cmd,$old,$new) = @_;
  233. my $aold = "fp_$old";
  234. my $anew = $new ? "fp_$new" : '';
  235. Log3 $old, 3, "Floorplan - $cmd $old - processing...";
  236. if ( ($cmd =~ m/(copy|rename)/) && (AttrVal("global","userattr","") !~ m/$anew/) ) {
  237. addToAttrList("$anew"); # create userattr fp_<name> if it doesn't exist yet for $new
  238. Log3 $old, 3, "Floorplan - added global userattr $anew";
  239. }
  240. foreach my $d (sort keys %defs) {
  241. next if (!$attr{$d}{"$aold"} && !$attr{$d}{"$anew"});
  242. if ($cmd =~ m/(copy|rename)/) {
  243. AnalyzeCommand(undef, "attr $d $anew ".AttrVal($d,$aold,""),AttrVal($FW_wname,"allowedCommands",undef));
  244. Log3 $new, 3, "Floorplan - added attr $d $anew ".AttrVal($d,$anew,"");
  245. }
  246. if ($cmd =~ m/(rename|delete)/) {
  247. Log3 $old, 3, "Floorplan - deleted attr $d $aold ".AttrVal($d,$aold,"");
  248. AnalyzeCommand(undef, "deleteattr $d $aold",AttrVal($FW_wname,"allowedCommands",undef));
  249. }
  250. }
  251. if ($cmd =~ m/(rename|delete)/) {
  252. my $ua = $attr{global}{userattr};
  253. $ua =~ s/ $aold//;
  254. AnalyzeCommand(undef, "attr global userattr $ua",AttrVal($FW_wname,"allowedCommands",undef));
  255. Log3 $old, 3, "Floorplan - deleted global userattr $aold"; # delete the global userattr if $old gets deleted
  256. }
  257. Log3 $old, 3, "Floorplan - $cmd $old - complete.";
  258. return undef;
  259. }
  260. #-------------------------------------------------------------------------------
  261. ##################
  262. # FLOORPLAN get
  263. sub
  264. FP_Get($@) {
  265. my ($hash, @a) = @_;
  266. my $arg = (defined($a[1]) ? $a[1] : ""); #command
  267. my $name = $hash->{NAME};
  268. return "use command: get <dev> getConfig" if ($#a != 1 || $arg ne "config");
  269. return FP_getConfig( $name ) if ($arg eq "config");
  270. }
  271. #-------------------------------------------------------------------------------
  272. ##################
  273. # FP MAIN: Answer URL call
  274. sub
  275. FP_CGI(){
  276. my ($htmlarg) = @_; #URL
  277. ## reset parameters
  278. $FP_name = undef;
  279. my ($p,$v) = ("",""); #parameter and value of analyzed URL
  280. $FW_RET = ""; # blank out any html-code written so far by fhemweb
  281. $FW_subdir = "";
  282. $FW_longpoll = AttrVal($FW_wname, "longpoll", undef); # longpoll
  283. $FW_plotmode = AttrVal($FW_wname, "plotmode", "SVG");
  284. $FW_plotsize = AttrVal($FW_wname, "plotsize", $FW_ss ? "480,160" :
  285. $FW_tp ? "640,160" : "800,160");
  286. $htmlarg =~ s/^\///; # eliminate leading /
  287. ## derive floorplan-name
  288. my @params = split(/\//,$htmlarg); # split URL by /
  289. if ($params[2]) { # URL with CGI-parameters has addtl / -> use $FP_name
  290. $FP_name = $params[1];
  291. $params[1] = $params[2];
  292. }
  293. my @htmlpart = split("\\?", $params[1]) if ($params[1]); # split URL by ? -> htmlpart[0] = FP_name, htmlpart[1] = commandstring
  294. if (!$htmlpart[1] && $htmlpart[0] && $htmlpart[0] !~ "\\?") { # in case of 'post' URL does not contain ?
  295. $htmlpart[0] =~ /([a-z0-9.:_]+)&(.*)/i;
  296. $htmlpart[1] = $2 if ($2);
  297. $htmlpart[1] =~ s/\\+/&/g if ($htmlpart[1]);
  298. $htmlpart[0] = $1 if ($1);
  299. }
  300. $FP_name = $htmlpart[0] if (!$FP_name);
  301. ### set global parameters, check floorplan-name
  302. if ($FP_name) { # floorplan-name is part of URL
  303. if(!defined($defs{$FP_name}) && $FP_name ne "floorplanstartpage"){
  304. $FW_RET = "ERROR: Floorplan $FP_name not defined \n"; # check for typo in URL
  305. return ("text/plain; charset=$FW_encoding", $FW_RET);
  306. }
  307. $FP_arrange = AttrVal($FP_name, "fp_arrange", 0); # set arrange mode
  308. $FP_viewport = AttrVal($FP_name, "fp_viewport", "width=768") if ($FP_name); # viewport definition
  309. $FW_subdir = "/floorplan/$FP_name";
  310. } else { # no floorplan-name in URL....
  311. $FP_arrange_default = undef;
  312. $FP_arrange_selected = undef;
  313. my $dev = undef;
  314. my $tmpname = undef;
  315. my $cnt = 0;
  316. foreach my $fp (keys %defs) {
  317. next if ($defs{$fp}{TYPE} ne "FLOORPLAN");
  318. if (AttrVal($fp, "fp_default", undef)) { # use floorplan with attr fp_default
  319. $FP_name = $fp;
  320. last;
  321. } else {
  322. $tmpname=$fp;
  323. $cnt++;
  324. }
  325. }
  326. $FP_name = $tmpname if (!$FP_name && $cnt==1); # otherwise, if only one floorplan, use that one
  327. $FP_name = "floorplanstartpage" if (!$FP_name); # otherwise go to startpage
  328. $FW_subdir = "/floorplan/$FP_name";
  329. $FP_arrange = AttrVal($FP_name, "fp_arrange", 0);
  330. }
  331. ### process cgi
  332. my $commands = FP_digestCgi($htmlpart[1]) if $htmlpart[1]; # analyze URL-commands
  333. my $FP_ret = AnalyzeCommand(undef, $commands,
  334. AttrVal($FW_wname,"allowedCommands",undef)) ; # Execute commands
  335. Log3 "FLOORPLAN", 1, "FLOORPLAN: regex-error. commands: $commands, FP_name: $FP_name, FP_ret: $FP_ret" if($FP_ret && ($FP_ret =~ m/regex/ )); #errormessage
  336. ### redirect URL - either back to fhemweb-detailscreen, or for redirectCmds to suppress repeated execution of commands upon browser refresh
  337. my $me = $defs{$FW_cname}; # from FHEMWEB: Current connection name
  338. my $tgt = undef;
  339. if( !$htmlpart[0] || (AttrVal($FW_wname, "redirectCmds", 1) && $me && $commands && !$FP_ret)) {
  340. if($FP_name) {
  341. $tgt = "/floorplan/$FP_name"
  342. } else {
  343. $FW_RET = 'ERROR: floorplan-name could not be derived from URL, fp_default or single floorplanname.';
  344. return ("text/plain; charset=$FW_encoding", $FW_RET);
  345. }
  346. }
  347. $tgt = "?detail=$FP_fwdetail" if ($FP_fwdetail); #return to fhemweb-detail-screen if coming from there
  348. if ($tgt) {
  349. my $tgt = $FW_ME.$tgt;
  350. my $c = $me->{CD};
  351. print $c "HTTP/1.1 302 Found\r\n",
  352. "Content-Length: 0\r\n",
  353. "Location: $tgt\r\n",
  354. "\r\n";
  355. return;
  356. }
  357. ### output html-pages
  358. if($FP_name eq "floorplanstartpage") {
  359. FP_showStart(); # show Startscreen if zero or more than one floorplan, and none with fp_default assigned
  360. } else {
  361. FP_show(); # show floorplan
  362. }
  363. # finish HTML & leave back to FHEMWEB
  364. FW_pO "</html>\n";
  365. $FW_subdir = "";
  366. return ("text/html; charset=$FW_encoding", $FW_RET); # $FW_RET composed by FW_pO, FP_pH etc
  367. }
  368. #-------------------------------------------------------------------------------
  369. ###########################
  370. # Digest CGI parameters - portion after '?' in URL
  371. sub
  372. FP_digestCgi($) {
  373. my ($arg) = @_;
  374. my (%arg, %val, %dev, %deva, %attr, %top, %left, %style, %text);
  375. my ($cmd, $c) = ("","","");
  376. %FW_pos = ();
  377. %FP_webArgs = ();
  378. $FP_fwdetail = undef;
  379. $arg =~ s,^[?/],,;
  380. foreach my $pv (split("&", $arg)) { # per each URL-section devided by &
  381. next if($pv eq ""); # happens when post forgot to set FW_ME
  382. $pv =~ s/\+/ /g;
  383. $pv =~ s/%([\dA-F][\dA-F])/chr(hex($1))/ige;
  384. my ($p,$v) = split("=",$pv, 2); # $p = parameter, $v = value
  385. $v =~ s/[\r]\n/\\\n/g if($v && $p && $p ne "data"); # Multiline: escape the NL for fhem
  386. $FP_webArgs{$p} = $v;
  387. if($p eq "arr.dev") { $v =~ m,^([\.\w]*)\s\(,; $v = $1 if ($1); $FP_arrange_selected = $v; $FP_arrange_default = $v; }
  388. if($p eq "add.dev") { $v =~ m,^([\.\w]*)\s\(,; $v = $1 if ($1); $cmd = "attr $v fp_$FP_name 50,200,1"; }
  389. if($p eq "cmd") { $cmd = $v; }
  390. if($p =~ m/^cmd\.(.*)$/) { $cmd = $v; $c = $1; }
  391. if($p =~ m/^detl\.(.*)$/) { $FP_fwdetail = $1; }
  392. if($p =~ m/^dev\.(.*)$/) { $dev{$1} = $v; }
  393. if($p =~ m/^arg\.(.*)$/) { $arg{$1} = $v; }
  394. if($p =~ m/^val\.(.*)$/) { $val{$1} = $v; }
  395. if($p =~ m/^deva\.(.*)$/) { $deva{$1} = $v; $FP_arrange_selected = undef; }
  396. if($p =~ m/^attr\.(.*)$/) { $attr{$1} = $v; }
  397. if($p =~ m/^top\.(.*)$/) { $top{$1} = $v; }
  398. if($p =~ m/^left\.(.*)$/) { $left{$1} = $v; }
  399. if($p =~ m/^style\.(.*)$/) { $style{$1} = int(substr($v,0,2)); }
  400. if($p =~ m/^text\.(.*)$/) { $text{$1} = $v; }
  401. if($p eq "pos") { %FW_pos = split(/[=;]/, $v); }
  402. }
  403. my $dele = ($cmd =~ m/^deleteattr/);
  404. $cmd.=" $dev{$c}" if(defined($dev{$c})); # FHT device
  405. $cmd.=" $arg{$c}" if(defined($arg{$c})&&
  406. ($arg{$c} ne "state" || $cmd !~ m/^set/)); # FHT argument (e.g. desired-temp)
  407. $cmd.=" $val{$c}" if(defined($val{$c})); # FHT value
  408. $cmd.=" $deva{$c}" if(defined($deva{$c})); # arrange device
  409. $cmd.=" $attr{$c}" if(defined($attr{$c})); # arrange attr
  410. $cmd.=" $top{$c}" if(defined($top{$c}) && !$dele); # arrange top
  411. $cmd.=",$left{$c}" if(defined($left{$c}) && !$dele); # arrange left
  412. $cmd.=",$style{$c}" if(defined($style{$c})&& !$dele); # arrange style
  413. $cmd.=",$text{$c}" if(defined($text{$c}) && !$dele); # arrange text
  414. return $cmd;
  415. }
  416. #-------------------------------------------------------------------------------
  417. ##################
  418. # Page header, set webapp & css
  419. sub
  420. FP_htmlHeader($) {
  421. my $title = shift;
  422. $title = "FHEM floorplan" if (!$title);
  423. ### Page start
  424. $FW_RET = "";
  425. $FW_RET .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n";
  426. $FW_RET .= '<html xmlns="http://www.w3.org/1999/xhtml">'."\n";
  427. FW_pO "<head root=\"$FW_ME\">\n<title>$title</title>";
  428. FW_pO "<meta charset=\"$FW_encoding\">"; # Forum 28666
  429. # Enable WebApp
  430. if($FW_tp || $FW_ss) {
  431. FW_pO "<link rel=\"apple-touch-icon-precomposed\" href=\"" . FW_IconURL("fhemicon") . "\"/>";
  432. FW_pO "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\"/>";
  433. if($FW_ss) {
  434. FW_pO "<meta name=\"viewport\" content=\"width=320\"/>";
  435. } elsif($FW_tp) {
  436. FW_pO "<meta name=\"viewport\" content=\"".$FP_viewport."\"/>";
  437. }
  438. }
  439. # refresh-value
  440. my $rf = AttrVal($FW_wname, "refresh", "");
  441. FW_pO "<meta http-equiv=\"refresh\" content=\"$rf\">" if($rf); # use refresh-value from Web-Instance
  442. ########################
  443. # CSS
  444. my $cssTemplate = "<link href=\"$FW_ME/%s\" rel=\"stylesheet\"/>";
  445. #FW_pO sprintf($cssTemplate, "pgm2/style.css");
  446. FW_pO sprintf($cssTemplate, "pgm2/jquery-ui.min.css");
  447. map { FW_pO sprintf($cssTemplate, $_); }
  448. split(" ", AttrVal($FP_name, "CssFiles", ""));
  449. my $defaultcss = AttrVal($FW_wname, "stylesheetPrefix", "") . "floorplanstyle.css";
  450. my $css= AttrVal($FP_name, "stylesheet", $defaultcss);
  451. FW_pO "<link href=\"$FW_ME/css/$css\" rel=\"stylesheet\"/>";
  452. ########################
  453. # JavaScripts
  454. my $jsTemplate = '<script type="text/javascript" src="%s"></script>';
  455. FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/jquery.min.js");
  456. FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/jquery-ui.min.js");
  457. # FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/floorplan_click.js"); #enlarge clickable area per widget
  458. if ($FP_arrange && ($FP_arrange eq "1" || ($FP_arrange eq $FW_wname) || $FP_arrange eq "detail")) {
  459. FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/floorplan_drag.js") ; #arrange-mode drag&drop
  460. }
  461. #######################
  462. # Other JavaScripts + their Attributes
  463. map { FW_pO sprintf($jsTemplate, "$FW_ME/pgm2/$_") } @FW_fhemwebjs;
  464. $jsTemplate = '<script attr=\'%s\' type="text/javascript" src="%s"></script>'."\n";
  465. map {
  466. my $n = $_; $n =~ s+.*/++; $n =~ s/.js$//; $n =~ s/fhem_//; $n .= "Param";
  467. FW_pO sprintf($jsTemplate, AttrVal($FP_name, $n, ""), "$FW_ME/$_");
  468. } split(" ", AttrVal($FP_name, "JavaScripts", ""));
  469. ########################
  470. # FW Extensions
  471. if(defined($data{FWEXT})) {
  472. foreach my $k (sort keys %{$data{FWEXT}}) {
  473. my $h = $data{FWEXT}{$k};
  474. next if($h !~ m/HASH/ || !$h->{SCRIPT} || $h->{SCRIPT} =~ m+pgm2/jquery+);
  475. my $script = $h->{SCRIPT};
  476. $script = ($script =~ m,^/,) ? "$FW_ME$script" : "$FW_ME/pgm2/$script";
  477. FW_pO sprintf($jsTemplate, "", $script) if ($script);
  478. }
  479. }
  480. my $csrf= ($FW_CSRF ? "fwcsrf='$defs{$FW_wname}{CSRFTOKEN}'" : "");
  481. my $gen = 'generated="'.(time()-1).'"';
  482. my $lp = 'longpoll="'.AttrVal($FW_wname,"longpoll",1).'"';
  483. my $lpf = 'longpollfilter="fp_'.$FP_name.'=.%2B"'; #longpollfilter - only devices present on this floorplan shall be notified
  484. $lpf =~ s/:/%3/g;
  485. FW_pO "</head>\n<body name=\"$title\" $gen $lp $lpf $csrf>";
  486. }
  487. #-------------------------------------------------------------------------------
  488. ##################
  489. # show startscreen
  490. sub
  491. FP_showStart() {
  492. FP_htmlHeader("Floorplans"); # incl. body-tag
  493. FW_pO "<div id=\"logo\"></div>";
  494. FP_menu();
  495. FW_pO "<div class=\"screen\" id=\"hdr\">";
  496. FW_pO "<form method=\"$FW_formmethod\" action=\"" . $FW_ME . "\">";
  497. FW_pO "<table WIDTH=\"100%\"><tr>";
  498. FW_pO "<td><input type=\"text\" name=\"cmd\" size=\"30\"/></td>"; #input-field
  499. FW_pO "</tr></table>";
  500. FW_pO "</form></div>";
  501. # no floorplans defined? -> show message
  502. my $count=0;
  503. foreach my $f (sort keys %defs) {
  504. next if ($defs{$f}{TYPE} ne "FLOORPLAN");
  505. $count++;
  506. }
  507. if ($count == 0) {
  508. FW_pO '<div id="startcontent">';
  509. FW_pO "<br><br><br><br>No floorplans have been defined yet. For definition, enter<br>";
  510. FW_pO "<ul><code>define &lt;name&gt; FLOORPLAN</code></ul>";
  511. FW_pO "Also check the <a href=\"$FW_ME/docs/commandref.html#FLOORPLAN\">commandref</a><br>";
  512. FW_pO "</div>";
  513. }
  514. FW_pO "</body>";
  515. }
  516. #-------------------------------------------------------------------------------
  517. ##################
  518. # show floorplan
  519. sub
  520. FP_show(){
  521. ### Page start
  522. FP_htmlHeader("$FP_name"); ## incl. body-tag
  523. my $onload = $FW_longpoll ? "onload=\"FW_delayedStart()\"" : "";
  524. FW_pO "<div id=\"backimg\" style=\"width: 99%; height: 99%;\">";
  525. FW_pO FW_makeImage(AttrVal($FP_name, "fp_backgroundimg", "fp_$FP_name"));
  526. FW_pO "</div>\n";
  527. ## menus
  528. FP_menu();
  529. FP_menuArrange() if ($FP_arrange && ($FP_arrange eq "1" || ($FP_arrange eq $FW_wname) || $FP_arrange eq "detail")); #shows the arrange-menu
  530. ## start floorplan
  531. FW_pO "<div class=\"screen\" id=\"floorplan\">";
  532. FW_pO "<div id=\"logo\"></div>";
  533. ## commandfield in floorplan
  534. if (AttrVal("$FP_name", "commandfield", undef)) {
  535. FW_pO "<div id=\"hdr\">\n";
  536. FW_pO " <form>";
  537. FW_pO " <input type=\"text\" name=\"cmd\" size=\"30\"/>\n"; #fhem-commandfield
  538. FW_pO " </form>";
  539. FW_pO "</div>\n";
  540. }
  541. ## let's go
  542. foreach my $d (sort keys %defs) { # loop all devices
  543. my $type = $defs{$d}{TYPE};
  544. my $attr = AttrVal("$d","fp_$FP_name", undef);
  545. next if(!$attr || $type eq "weblink"); # skip if device-attribute not set for current floorplan-name
  546. my ($top, $left, $style, $text, $text2) = split(/,/ , $attr);
  547. # $top = position in px, top
  548. # $left = position in px, left
  549. # $style = style (0=icon only, 1=name+icon, 2=name+icon+commands, 3=device-Reading + name from $text2, 4=S300TH, 5=icon+commands, 6 device-Reading+timestamp, 7 command only, 8 icon+commands popup)
  550. # $text = alternativeCaption
  551. # $text2 = special for style3+6: $text = ReadingID, $text2=alternativeCaption
  552. $top = 0 if (!$top);
  553. $left = 0 if (!$left);
  554. $style = 0 if (!$style);
  555. # start device-specific table
  556. my $t1 = $text ? $text : InternalVal($d,'NAME',' ');
  557. my $t2 = $text2 ? $text2 : " ";
  558. # wrapper-div needed for floorplan_drag.js and for positioning
  559. FW_pO "\n<div fp_style=\"$style\" fp_text=\"$t1\" fp_text2=\"$t2\" fp_name=\"$FP_name\" class=\"fp_device_div\" style=\"position:absolute; top:".$top."px; left:".$left."px;\" id=\"div-$d\">";
  560. FW_pO "<form method=\"$FW_formmethod\" action=\"$FW_ME/floorplan/$FP_name/$d\" autocomplete=\"off\">";
  561. FW_pO " <table class=\"$type fp_$FP_name\" id=\"table-$d\" align=\"center\">"; # Main table per device
  562. my ($allSets, $cmdlist, $txt) = FW_devState($d, '');
  563. $allSets = FW_widgetOverride($d, $allSets);
  564. $txt = ReadingsVal($d, $text, "Undefined Reading $d-<b>$text</b>") if ($style == 3 || $style == 6); # Style3+6 = DeviceReading given in $text
  565. my $cols = ($cmdlist ? (split(":", $cmdlist)) : 0); # Need command-count for colspan of devicename+state
  566. ########################
  567. # Device-name per device
  568. if ($style gt 0 && $style ne 5 && $style ne 7) {
  569. FW_pO " <tr class=\"devicename fp_$FP_name\" id=\"$d-devicename\">"; # For css: class=devicename, id=<devicename>-devicename
  570. my $devName = "";
  571. if ($style == 3 || $style == 6) {
  572. $devName = $text2 ? $text2 : ""; # Style 3 = Reading - use last part of comma-separated description
  573. } else {
  574. $devName = ($text ? $text : AttrVal($d, "alias", $d));
  575. }
  576. if ($style == 4 && $txt =~ /T: ([\-0-9\.]+)[ ]+H: ([\-0-9\.]+).*/) { # S300TH-specific
  577. $txt = "<span class='fp_tempvalue' display=inline><span informId=$d-temperature>".$1."</span>&deg;C</span><BR><span class='fp_humvalue'><span informId=$d-humidity>".$2."</span>%</span>";
  578. }
  579. FW_pO "<td colspan=\"$cols\">";
  580. FW_pO "$devName" ;
  581. FW_pO "</td></tr>";
  582. }
  583. ########################
  584. # Device-state per device
  585. if ($style != 7) {
  586. if ($style == 3 || $style == 6) {
  587. FW_pO "<tr class=\"devicereading fp_$FP_name\" id=\"$d"."-$text\">"; # For css: class=devicereading, id=<devicename>-<reading>
  588. } else {
  589. FW_pO "<tr class=\"devicestate fp_$FP_name\" id=\"$d\">"; # For css: class=devicestate, id=<devicename>
  590. }
  591. $txt =~ s/measured-temp: ([\.\d]*) \(Celsius\)/$1/; # format FHT-temperature
  592. ### use device-specific icons according to userattr fp_image or fp_<floorplan>.image
  593. my $fp_image = AttrVal("$d", "fp_image", undef); # floorplan-independent icon
  594. my $fp_fpimage = AttrVal("$d","fp_$FP_name".".image", undef); # floorplan-dependent icon
  595. if ($fp_image) {
  596. my $state = ReadingsVal($d, "state", undef);
  597. $fp_image =~ s/\{state\}/$state/; # replace {state} by actual device-status
  598. $txt =~ s/\<img\ src\=\"(.*)\"/\<img\ src\=\"\/fhem\/icons\/$fp_image\"/; # replace icon-link in html
  599. $txt =~ s/\<img\ (.*) src\=\"(.*)\"/\<img\ $1 src\=\"\/fhem\/images\/default\/$fp_image\"/; # replace icon-link in html (new)
  600. }
  601. if ($fp_fpimage) {
  602. my $state = ReadingsVal($d, "state", undef);
  603. $fp_fpimage =~ s/\{state\}/$state/; # replace {state} by actual device-status
  604. $txt =~ s/\<img\ src\=\"(.*)\"/\<img\ src\=\"\/fhem\/icons\/$fp_fpimage\"/; # replace icon-link in html
  605. $txt =~ s/\<img\ (.*) src\=\"(.*)\"/\<img\ $1 src\=\"\/fhem\/images\/default\/$fp_fpimage\"/; # replace icon-link in html (new)
  606. }
  607. if ($style == 3 || $style == 6) {
  608. FW_pO "<td><div informId=\"$d-$text\">$txt</div>"; # reading
  609. } elsif ($style == 4) {
  610. FW_pO "<td>$txt"; # state style4
  611. } elsif ($cmdlist && $style == 8) {
  612. # first collect the popup data
  613. } else {
  614. FW_pO "<td informId=\"$d\" colspan=\"$cols\">$txt"; # state
  615. }
  616. FW_pO "</td></tr>";
  617. }
  618. if ($style == 6) { # add ReadingsTimeStamp for style 6
  619. $txt="";
  620. FW_pO "<tr class=\"devicetimestamp fp_$FP_name\" id=\"$d-devicetimestamp\">"; # For css: class=devicetimestamp, id=<devicename>-devicetimestamp
  621. $txt = ReadingsTimestamp($d, $text, "Undefined Reading $d-<b>$text</b>"); # Style3+6 = DeviceReading given in $text
  622. FW_pO "<td><div colspan=\"$cols\" informId=\"$d-$text-ts\">$txt</div>";
  623. FW_pO "</td></tr>";
  624. }
  625. ########################
  626. # Commands per device
  627. if($cmdlist && ( $style == 2 || $style == 5 || $style == 7 || $style == 8) ) {
  628. my @a = split("[: ]", AttrVal($d, "cmdIcon", "")); #new
  629. Log 1, "ERROR: bad cmdIcon definition for $d" if(@a % 2); #new
  630. my %cmdIcon = @a; #new
  631. my $firstIdx = 0;
  632. FW_pO " <tr class=\"devicecommands\" id=\"$d-devicecommands\">";
  633. my $oldMe = $FW_ME;
  634. my $h = "";
  635. foreach my $cmd (split(":", $cmdlist)) {
  636. # Special handling (slider, dropdown, timepicker, ...)
  637. my $htmlTxt;
  638. my @c = split(' ', $cmd);
  639. if(int(@c) && $allSets && $allSets =~ m/\b$c[0]:([^ ]*)/) {
  640. my $values = $1;
  641. $FW_ME = "$FW_ME/floorplan/$FP_name";
  642. foreach my $fn (sort keys %{$data{webCmdFn}}) {
  643. my $FW_room = ''; ##needed to be able to reuse code from FHEMWEB
  644. no strict "refs";
  645. if ($data{webCmdFn}{$fn}) {
  646. $htmlTxt = &{$data{webCmdFn}{$fn}}($FW_ME,
  647. $d, $FW_room, $cmd, $values);
  648. }
  649. $FW_ME = $oldMe if (defined($htmlTxt) && $htmlTxt eq '');
  650. use strict "refs";
  651. last if(defined($htmlTxt));
  652. }
  653. }
  654. if( $style == 8 ) {
  655. if( $htmlTxt ) {
  656. $h .= "<p>$htmlTxt</p>";
  657. } elsif($cmd) {
  658. my $link = "cmd.$d=set $d $cmd";
  659. $h .= "<p><a href='$FW_ME$FW_subdir?$link$FW_CSRF'>$cmd</a></p>";
  660. }
  661. } else {
  662. if (defined($htmlTxt) && $htmlTxt ne '') {
  663. $htmlTxt =~ s/>desired-temp/>/; #for FHT
  664. $htmlTxt =~ s/>desiredTemperature/>/; #for MAX!
  665. FW_pO $htmlTxt;
  666. } else {
  667. my $nCmd = $cmdIcon{$cmd} ?
  668. FW_makeImage($cmdIcon{$cmd},$cmd,"webCmd") : $cmd;
  669. FW_pH "cmd.$d=set $d $cmd", $nCmd, 1, "col3";
  670. }
  671. # END # Special handling (slider, dropdown, timepicker, ...)
  672. }
  673. }
  674. $FW_ME = $oldMe;
  675. if( $style == 8 ) {
  676. $h =~ s/'/\\"/g;
  677. if( $txt =~ m/<div([^>]*)><a[^>]*>(.*)<\/a>/ ) {
  678. $txt = "<div $1><a onClick='FW_okDialog(\"$h\",this.children[0]);\$(\"a[href]\").each(function() { FW_replaceLink(this); })'\><div informId=\"$d\">$2</div></a></div>";
  679. } else {
  680. FW_pO "<td><div informId=\"$d-$text\">$txt</div>"; # reading
  681. }
  682. FW_pO "<td><div informId=\"$d-$text\">$txt</div>"; # reading
  683. }
  684. FW_pO "</tr>";
  685. } elsif($type eq "FileLog") {
  686. # $row = FW_dumpFileLog($d, 1, $row);
  687. }
  688. FW_pO "</table></form>";
  689. FW_pO "</div>\n";
  690. } #end loop all decives
  691. ########################
  692. # Finally the weblinks
  693. my $buttons = 1;
  694. my @list = (keys %defs);
  695. foreach my $d (sort @list) {
  696. my $attr = AttrVal("$d","fp_$FP_name", undef);
  697. next if(IsIgnored($d) || !$attr);
  698. my $type = $defs{$d}{TYPE};
  699. next if(!$type);
  700. next if($type ne "weblink");
  701. # set position per weblink
  702. my ($top, $left, $style, $text, $text2) = split(/,/ , AttrVal("$d", "fp_$FP_name", undef));
  703. $text = "" if (!$text);
  704. $text2 = "" if (!$text2);
  705. $left = 0 if (!$left);
  706. $style = 0 if (!$style);
  707. FW_pO "\n<div fp_style=\"$style\" fp_text=\"$text\" fp_text2=\"$text2\" fp_name=\"$FP_name\" class=\"fp_weblink_div style_$style\" style=\"position:absolute; top:".
  708. $top."px; left:".$left."px\" id = \"div-$d\">"; # div to position the weblink
  709. FW_pO "<div class = \"fp_$type fp_$FP_name weblink\" id = \"$d\">"; # div to make it accessible to arrangeByMouse
  710. # print weblink
  711. $buttons = FW_showWeblink($d, $defs{$d}{LINK}, $defs{$d}{WLTYPE}, $buttons);
  712. FW_pO "</div></div>";
  713. }
  714. FW_pO "</div>";
  715. FW_pO "</body>\n";
  716. }
  717. #-------------------------------------------------------------------------------
  718. ##################
  719. # Floorplan menu left
  720. sub
  721. FP_menu() {
  722. return if ($FP_name && AttrVal($FP_name, "fp_noMenu", 0)); # fp_noMenu suppresses menu
  723. FW_pO "<div class=\"floorplan\" id=\"menu\">";
  724. # List FPs
  725. FW_pO "<table class=\"start\" id=\"floorplans\">";
  726. FW_pO "<tr>";
  727. FW_pH "$FW_ME", "fhem", 1;
  728. FW_pO "</tr>";
  729. foreach my $f (sort keys %defs) {
  730. next if (!$defs{$f}{TYPE} || $defs{$f}{TYPE} ne "FLOORPLAN");
  731. FW_pO "<tr>";
  732. my $icoName = "ico$f";
  733. map { my ($n,$v) = split(":",$_); $icoName=$v if($f =~ m/$n/); }
  734. split(" ", AttrVal($FP_name, "fp_roomIcons", ""));
  735. my $icon = FW_iconName($icoName) ? FW_makeImage($icoName,$icoName,"icon")."&nbsp;" : "";
  736. FW_pH "$FW_ME/floorplan/$f", "$icon$f", 1;
  737. FW_pO "</tr>";
  738. }
  739. FW_pO "</table><br>";
  740. FW_pO "</div>\n";
  741. }
  742. #-------------------------------------------------------------------------------
  743. ##################
  744. # Arrange-menu
  745. sub
  746. FP_menuArrange() {
  747. my %desc=();
  748. ## collect data
  749. $FP_arrange_default = "" if (!$FP_arrange_default);
  750. my @fpl; # devices assigned to floorplan
  751. my @nfpl; # devices not assigned to floorplan
  752. foreach my $d (sort keys %defs) { # loop all devices
  753. my $type = $defs{$d}{TYPE};
  754. $type = '?' if (!$type);
  755. # exclude these types from list of available devices
  756. next if ($type =~ m/^(WEB|CUL$|FHEM2FHEM|FHEMWEB|FileLog|PachLog|PID|SUNRISE.*|FLOORPLAN|holiday|Global|notify|autocreate)/ );
  757. my $disp = $d;
  758. $disp .= ' (' . AttrVal($d,"room","Unsorted").") $type";
  759. my $alias = AttrVal($d, "alias", undef);
  760. $disp .= ' (' . $alias . ')' if ($alias);
  761. $desc{$d} = $disp;
  762. if (AttrVal("$d","fp_$FP_name", undef)) {
  763. push(@fpl, $disp); # all devices on floorplan
  764. } else {
  765. push(@nfpl, $disp); # all devices not on floorplan
  766. }
  767. }
  768. my $d = $FP_arrange_selected;
  769. my $attrd = AttrVal($d, "fp_$FP_name", undef) if ($d);
  770. if ( $FP_arrange_selected && !$attrd) { # arrange-selected, but device is not part of fp now chosen -> reset arrange-selected
  771. $FP_arrange_selected = undef;
  772. }
  773. FW_pO "<div style=\"z-index:999\" class=\"fp_arrange\" id=\"fpmenu\">";
  774. # add device to floorplan
  775. if (!defined($FP_arrange_selected)) {
  776. FW_pO "<form method=\"$FW_formmethod\" action=\"$FW_ME/floorplan/$FP_name\">"; #form1
  777. FW_pO "<div class=\"menu-add\" id=\"fpmenu\">\n" .
  778. ($FP_fwdetail?FP_input("detl.$FP_fwdetail", $FP_fwdetail, "hidden") . "\n" :"") .
  779. FW_select("","add.dev", \@nfpl, "", "menu-add") .
  780. FW_submit("ccc.one", "add");
  781. FW_pO "</div></form>\n"; #form1
  782. }
  783. # select device to be arranged
  784. if (!defined($FP_arrange_selected)) {
  785. my $dv = $FP_arrange_default;
  786. $dv = $desc{$dv} if ($dv);
  787. FW_pO "<form method=\"$FW_formmethod\" action=\"$FW_ME/floorplan/$FP_name\">"; #form2
  788. FW_pO "<div class=\"menu-select\" id=\"fpmenu\">\n" .
  789. ($FP_fwdetail?FP_input("detl.$FP_fwdetail", $FP_fwdetail, "hidden") . "\n" :"") .
  790. FW_select("","arr.dev", \@fpl, $dv, "menu-select") .
  791. FW_submit("ccc.one", "select");
  792. FW_pO "</div></form>"; #form2
  793. }
  794. # fields for top,left,style,text
  795. if ($attrd) {
  796. ### build the form
  797. my $disp = $FP_arrange eq "detail" ? $desc{$d} : $d;
  798. FW_pO "<form method=\"$FW_formmethod\" action=\"$FW_ME/floorplan/$FP_name\">"; #form3
  799. my ($top, $left, $style, $text, $text2) = split(",", $attrd);
  800. $text .= ','.$text2 if ($text2); # re-append Description after reading-ID for style3
  801. $style = $styles[$style];
  802. FW_pO "<div class=\"menu-arrange\" id=\"fpmenu\">\n" .
  803. ($FP_fwdetail?FP_input("detl.$FP_fwdetail", $FP_fwdetail, "hidden") . "\n" :"") .
  804. FP_input("deva.$d", $d, "hidden") . "\n" .
  805. FP_input("dscr.$d", $disp, "text", "Selected device", 45, "", "disabled") . "\n<br>\n" .
  806. FP_input("attr.$d", "fp_$FP_name", "hidden") . "\n" .
  807. FP_input("top.$d", $top ? $top : 10, "text", "Top", 4, 4, 'onkeydown="increment(event, this)" class="'.$d.'" id="fp_ar_input_top"') . "\n" .
  808. FP_input("left.$d", $left ? $left : 10, "text", "Left", 4, 4, 'onkeydown="increment(event, this)" class="'.$d.'" id="fp_ar_input_left"' ) . "\n" .
  809. FW_select("","style.$d", \@styles, $style ? $style : 0, "menu-arrange") . "\n" .
  810. FP_input("text.$d", $text ? $text : "", "text", "Description", 15) . "\n" .
  811. FW_submit("cmd.$d", "attr") . "\n" .
  812. FW_submit("cmd.$d", "deleteattr");
  813. FW_pO "</div></form>"; # form3
  814. }
  815. FW_pO "</div>";
  816. }
  817. #-------------------------------------------------------------------------------
  818. ##################
  819. # input-fields for html-forms
  820. sub
  821. FP_input(@)
  822. {
  823. my ($n, $v, $type, $title, $size, $maxlength, $addition) = @_;
  824. $title = $title ? " title=\"$title\"" : "";
  825. $size = $size ? " size=\"$size\"" : "";
  826. $maxlength = $maxlength ? " maxlength=\"$maxlength\"" : "";
  827. $addition = "" if (!defined($addition));
  828. return "<input type=\"$type\"$title$size$maxlength $addition name=\"$n\" value=\"$v\"/>\n";
  829. }
  830. #-------------------------------------------------------------------------------
  831. ##################
  832. #floorplan-specific fhemweb detail-screen
  833. sub
  834. FP_detailFn($$$$) {
  835. my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn.
  836. my $hash = $defs{$d};
  837. my $link = $hash->{LINK};
  838. my $wltype = $hash->{WLTYPE};
  839. ## Arrange-menu at top of fhemweb-detail-screen
  840. FW_pO '<table class="block wide"><tr><td>';
  841. $FP_name = $d;
  842. $FP_fwdetail = $d;
  843. FP_menuArrange();
  844. $FP_fwdetail = undef;
  845. FW_pO '</td></tr></table>';
  846. ## list of assigned devices
  847. my $row = 0;
  848. FW_pO "<br>Devices assigned to floorplan \"$d\"<br>";
  849. FW_pO '<table class="block wide">';
  850. FW_pO '<thead><tr><th><b>Device</b></th><th><b>X</b></th><th><b>Y</b></th><th><b>Style</b></th><th><b>Text</b></th></tr></thead>';
  851. foreach my $fpd (sort keys %defs) {
  852. my $val = AttrVal($fpd,"fp_$d",undef);
  853. next if (!$val);
  854. my ($x,$y,$style,$txt,$txt2) = split(",",$val);
  855. $txt = "" if (!$txt);
  856. $txt2 = "" if (!$txt2);
  857. $row++;
  858. my $ret = '<tr class = "';
  859. $ret .= ($row/2==int($row/2))?"even":"odd";
  860. $ret .= '">';
  861. $ret .= "<td><div class=\"dname\"><a href=\"$FW_ME?detail=$fpd\">$fpd</a></div></td>";
  862. $ret .= "<td><div class=\"dval\">$x</div></td>";
  863. $ret .= "<td><div class=\"dval\">$y</div></td>";
  864. $ret .= "<td><div class=\"dval\">";
  865. $ret .= $styles[$style] if (defined($style)&& defined($styles[$style]));
  866. $ret .= "</div></td>";
  867. $ret .= "<td><div class=\"dval\">$txt".($txt2?",$txt2":"")."</div></td>";
  868. $ret .= "</tr>";
  869. FW_pO $ret;
  870. }
  871. FW_pO '</table><br>';
  872. ## Arrange-mode on/off
  873. FW_pO "Arrange-mode<br>";
  874. FW_pO '<table class="block wide">';
  875. my $armon = "<div class=\"dval\"><a href=\"$FW_ME?cmd.$d=attr $d fp_arrange 1&detail=$d\"><div class=\"col2\">on</div></a></div>";
  876. my $armoff= "<div class=\"dval\"><a href=\"$FW_ME?cmd.$d=attr $d fp_arrange 0&detail=$d\"><div class=\"col2\">off</div></a></div>";
  877. FW_pO "<tr><td><div class=\"dname\">fp_arrange</div></td><td>$armon</td><td>$armoff</td></tr>";
  878. FW_pO '</table><br>';
  879. return;
  880. }
  881. #-------------------------------------------------------------------------------
  882. ##################
  883. # FLOORPLAN getConfig - can be copied into an include-file
  884. sub
  885. FP_getConfig($) {
  886. my $dev = shift;
  887. my $html="";
  888. if (!defined($defs{$dev})) {
  889. return "get: Device $dev not defined.";
  890. }
  891. my ($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime;
  892. $year += 1900;
  893. $html .= FP_pOfill(80, ("Config for FLOORPLAN $dev","$mday.$month.$year $hour:$min","get $dev config"));
  894. $html .= FP_pOfill(80, "Definition and attributes for $dev");
  895. $html .= "define $dev FLOORPLAN\n";
  896. ## attributes of floorplan-device
  897. foreach my $a (sort keys %{$attr{$dev}}) {
  898. my $val = AttrVal($dev,$a,undef);
  899. next if (!$val);
  900. $html .= "attr $dev $a $val\n";
  901. }
  902. $html .= "\n\n";
  903. $html .= FP_pOfill(80,"Attributes for devices assigned to $dev");
  904. ## attributes of assigned devices
  905. foreach my $d (sort keys %defs) {
  906. my $val = AttrVal($d,"fp_$dev",undef);
  907. next if (!$val);
  908. $html .= "attr $d fp_$dev $val\n";
  909. }
  910. $html .= "\n\n".FP_pOfill(80, "End of config for FLOORPLAN $dev");
  911. return $html;
  912. }
  913. #-------------------------------------------------------------------------------
  914. ##################
  915. # FLOORPLAN FP_pOfill - FW_pO with filling up with #
  916. sub
  917. FP_pOfill($@) {
  918. my ($digits,@lines,) = @_;
  919. my $ret = "#" x $digits . "\n";
  920. $ret .= ("#"." " x ($digits-2))."#\n";
  921. foreach my $line (@lines) {
  922. $ret .= "# ".$line;
  923. my $len = length($line);
  924. $ret .= (" " x ($digits-$len-3))."#\n" if ( $digits-$len-3 > 0);
  925. }
  926. $ret .= ("#"." " x ($digits-2))."#\n";
  927. $ret .= "#" x $digits . "\n\n";
  928. return $ret;
  929. }
  930. 1;
  931. =pod
  932. =begin html
  933. <a name="FLOORPLAN"></a>
  934. <h3>FLOORPLAN</h3>
  935. <ul>
  936. Implements an additional entry "Floorplans" to your fhem menu, leading to a userinterface without fhem-menu, rooms or devicelists.
  937. Devices can be displayed at a defined coordinate on the screen, usually with a clickable icon allowing to switch
  938. the device on or off by clicking on it. A background-picture can be used - use e.g. a floorplan of your house, or any picture.
  939. Use floorplanstyle.css to adapt the representation.<br>
  940. Step-by-step setup guides are available in
  941. <a href="http://sourceforge.net/p/fhem/code/HEAD/tree/trunk/fhem/docs/fhem-floorplan-installation-guide.pdf?format=raw">english</a> and
  942. <a href="http://www.fhemwiki.de/wiki/Floorplan_Installations-Leitfaden" target="_blank">german</a>. <br>
  943. <br>
  944. <a name="FLOORPLANdefine"></a>
  945. <b>Define</b>
  946. <ul>
  947. <code>define &lt;name&gt; FLOORPLAN </code>
  948. <br><br>
  949. <b>Hint:</b> Store fp_&lt;name&gt;.png in your image folder (www/images/default , www/pgm2 or FHEM) to use it as background picture.<br><br>
  950. Example:
  951. <ul>
  952. <code>
  953. define Groundfloor FLOORPLAN<br>
  954. fp_Groundfloor.png
  955. </code><br>
  956. </ul>
  957. </ul>
  958. <br>
  959. <a name="FLOORPLANset"></a>
  960. <b>Set </b>
  961. <ul>
  962. <li>N/A</li>
  963. </ul>
  964. <br>
  965. <a name="FLOORPLANget"></a>
  966. <b>Get</b>
  967. <ul>
  968. <code>get &lt;name&gt; config</code>
  969. <br>
  970. Displays the configuration of the floorplan <name> with all attributes. Can be used in an include-file.
  971. </ul>
  972. <br>
  973. <a name="FLOORPLANattr"></a>
  974. <b>Attributes</b>
  975. <ul>
  976. <li><a name="fp_fpname">userattr fp_&lt;name&gt; &lt;top&gt;,&lt;left&gt;[,&lt;style&gt;[,&lt;description&gt;]]</a><br><br>
  977. A <a href="#userattr">userattr</a> fp_&lt;name&gt; will be created automatically if it does not exist yet.<br>
  978. <ul>
  979. <li>top = screen-position, pixels from top of screen</li>
  980. <li>left = screen-position, pixels from left of screen</li>
  981. <li>style =
  982. <ul>
  983. <li>0 icon/state only</li>
  984. <li>1 devicename and icon/state</li>
  985. <li>2 devicename, icon/state and commands</li>
  986. <li>3 device-reading and optional description</li>
  987. <li>4 S300TH-specific, displays temperature above humidity</li>
  988. <li>5 icon/state and commands</li>
  989. <li>6 device-reading, reading-timestamp and optional description</li>
  990. <li>7 commands only</li>
  991. <li>8 commands popup</li>
  992. </ul>
  993. </li>
  994. <li>description will be displayed instead of the original devicename</li>
  995. </ul></li><br>
  996. Examples:<br>
  997. <ul>
  998. <table>
  999. <tr><td><code>attr lamp1 fp_Groundfloor 100,100</code></td><td><code>#display lamp1 with icon only at screenposition 100,100</code></td></tr>
  1000. <tr><td><code>attr lamp2 fp_Groundfloor 100,140,1,Art-Deco</code></td><td><code>#display lamp2 with description 'Art-Deco-Light' at 100,140</code></td></tr>
  1001. <tr><td><code>attr lamp2 fp_FirstFloor 130,100,1</code></td><td><code>#display the same device at different positions on other floorplans</code></td></tr>
  1002. <tr><td><code>attr myFHT fp_Groundfloor 300,20,10,Temperature</code></td><td><code>#display given Text + FHT-temperature</code></td></tr>
  1003. </table>
  1004. </ul>
  1005. <b>Hint:</b> no blanks between parameters<br><br>
  1006. <li><a name="fp_arrange">fp_arrange</a><br>
  1007. Activates the "arrange mode" which shows an additional menu on the screen to choose style and description.<br>
  1008. When the arrange-mode is activated, devices can be placed freely on the screen by drag&amp;drop.
  1009. allowing to place devices easily on the screen.<br>
  1010. Example:
  1011. <ul>
  1012. <code>attr Groundfloor fp_arrange 1</code><br>
  1013. <code>attr Groundfloor fp_arrange WEB #activates arrange mode for frontend-device WEB only</code><br><br>
  1014. </ul>
  1015. </li>
  1016. <li><a name="stylesheet">stylesheet</a><br>
  1017. Explicitely sets your personal stylesheet for the floorplan. This overrides the standard stylesheet.
  1018. The standard stylesheet for floorplans is <code>floorplanstyle.css</code>. If the <a href="#stylesheetPrefix">stylesheetPrefix</a> is set for the corresponding FHEMWEB instance, this same
  1019. <code>stylesheetPrefix</code> is also prepended to the stylesheet for floorplans.<br>
  1020. All stylesheets must be stored in the stylesheet subfolder of the fhem filesystem hierarchy. Store your personal
  1021. stylesheet along with <code>floorplanstyle.css</code> in the same folder.<br>
  1022. Example:
  1023. <ul>
  1024. <code>attr Groundfloor stylesheet myfloorplanstyle.css</code><br><br>
  1025. </ul>
  1026. </li>
  1027. <li><a name="fp_default">fp_default</a><br>
  1028. The floorplan startscreen is skipped if this attribute is assigned to one of the floorplans in your installation.
  1029. </li>
  1030. Example:
  1031. <ul>
  1032. <code>attr Groundfloor fp_default 1</code><br><br>
  1033. </ul>
  1034. <li><a name="fp_noMenu">fp_noMenu</a><br>
  1035. Suppresses the menu which usually shows the links to all your floorplans.
  1036. </li>
  1037. Example:
  1038. <ul>
  1039. <code>attr Groundfloor fp_noMenu 1</code><br><br>
  1040. </ul>
  1041. <li><a name="commandfield">commandfield</a><br>
  1042. Adds a fhem-commandfield to the floorplan screen.
  1043. </li>
  1044. Example:
  1045. <ul>
  1046. <code>attr Groundfloor commandfield 1</code><br><br>
  1047. </ul>
  1048. <li><a name="fp_backgroundimg">fp_backgroundimg</a><br>
  1049. Allows to choose a background-picture independent of the floorplan-name.
  1050. </li>
  1051. Example:
  1052. <ul>
  1053. <code>attr Groundfloor fp_backgroundimg foobar.png</code><br><br>
  1054. </ul>
  1055. <li><a name="fp_viewport">fp_viewport</a><br>
  1056. Allows usage of a user-defined viewport-value for touchpad.<br>
  1057. Default-viewport-value is "width=768".
  1058. </li>
  1059. <a name="fp_roomIcons"></a>
  1060. <li>fp_roomIcons<br>
  1061. Space separated list of floorplan:icon pairs, to assign icons
  1062. to the floorplan-menu, just like the functionality for rooms
  1063. in FHEMWEB. Example:<br>
  1064. attr Grundriss fp_roomIcons Grundriss:control_building_empty Media:audio_eq
  1065. </li>
  1066. <li><a name="fp_inherited">Inherited from FHEMWEB</a><br>
  1067. The following attributes are inherited from the underlying <a href="#FHEMWEB">FHEMWEB</a> instance:<br>
  1068. <ul>
  1069. <a href="#smallscreen">smallscreen</a><br>
  1070. <a href="#touchpad">touchpad</a><br>
  1071. <a href="#refresh">refresh</a><br>
  1072. <a href="#plotmode">plotmode</a><br>
  1073. <a href="#plotsize">plotsize</a><br>
  1074. <a href="#webname">webname</a><br>
  1075. <a href="#redirectCmds">redirectCmds</a><br>
  1076. <a href="#longpoll">longpoll</a><br>
  1077. <a href="#allowedCommands">allowedCommands</a><br>
  1078. </ul>
  1079. </li><br>
  1080. </ul>
  1081. <br>
  1082. </ul>
  1083. =end html
  1084. =begin html_DE
  1085. <a name="FLOORPLAN"></a>
  1086. <h3>FLOORPLAN</h3>
  1087. <ul>
  1088. Fügt dem fhem-Menü einen zusätzlichen Menüpunkt "Floorplans" hinzu, der zu einer Anzeige ohne fhem-Menü, Räume oder device-Listen führt.
  1089. Geräte können an einer festlegbaren Koordinate auf dem Bildschirm angezeigt werden, üblicherweise mit einem anklickbaren icon, das das Ein- oder Aus-Schalten
  1090. des Geräts durch klicken erlaubt. Ein Hintergrundbild kann verwendet werden - z.B. ein Grundriss oder jegliches andere Bild.
  1091. Mit floorplanstyle.css kann die Formatierung angepasst werden.<br>
  1092. Eine Schritt-für-Schritt-Anleitung zur Einrichtung ist verfügbar in
  1093. <a href="http://sourceforge.net/p/fhem/code/HEAD/tree/trunk/fhem/docs/fhem-floorplan-installation-guide.pdf?format=raw">Englisch</a> und
  1094. <a href="http://www.fhemwiki.de/wiki/Floorplan_Installations-Leitfaden" target="_blank">Deutsch</a>. <br>
  1095. <br>
  1096. <a name="FLOORPLANdefine"></a>
  1097. <b>Define</b>
  1098. <ul>
  1099. <code>define &lt;name&gt; FLOORPLAN </code>
  1100. <br><br>
  1101. <b>Hinweis:</b> Speichern Sie Ihr Hintergrundbild mit dem Dateinamen fp_&lt;name&gt;.png in Ihrem icon_ordner (www/images/default , www/pgm2 or FHEM) .<br><br>
  1102. Beispiel:
  1103. <ul>
  1104. <code>
  1105. define Grundriss FLOORPLAN<br>
  1106. fp_Grundriss.png
  1107. </code><br>
  1108. </ul>
  1109. </ul>
  1110. <br>
  1111. <a name="FLOORPLANset"></a>
  1112. <b>Set</b>
  1113. <ul>
  1114. <li>N/A</li>
  1115. </ul>
  1116. <br>
  1117. <a name="FLOORPLANget"></a>
  1118. <b>Get</b>
  1119. <ul>
  1120. <code>get &lt;name&gt; config</code>
  1121. <br>
  1122. Zeigt die Konfiguration des FLOORPLAN <name> incl. allen Attributen an. Kann fuer ein include-file verwendet werden.<br>
  1123. </ul>
  1124. <br>
  1125. <a name="FLOORPLANattr"></a>
  1126. <b>Attribute</b>
  1127. <ul>
  1128. <li><a name="fp_fpname">userattr fp_&lt;name&gt; &lt;top&gt;,&lt;left&gt;[,&lt;style&gt;[,&lt;description&gt;]]</a><br><br>
  1129. A <a href="#userattr">userattr</a> fp_&lt;name&gt; wird automatisch angelegt, sofern es noch nicht existiert.<br>
  1130. <ul>
  1131. <li>top = Bildschirmposition, pixel vom oberen Bildschirmrand</li>
  1132. <li>left = Bildschirmposition, pixel vom linken Bildschirmrand</li>
  1133. <li>style =
  1134. <ul>
  1135. <li>0 nur icon/Status</li>
  1136. <li>1 Gerätename und icon/Status</li>
  1137. <li>2 Gerätename, icon/Status und Kommandos</li>
  1138. <li>3 Geräte-reading und optionale Beschreibung</li>
  1139. <li>4 S300TH-spezifisch, zeigt Temperatur und Luftfeuchtigkeit an</li>
  1140. <li>5 icon/Status und Kommandos (ohne Gerätename)</li>
  1141. <li>6 Geräte-reading, Zeitstempel und optionale Beschreibung</li>
  1142. <li>7 nur Kommandos</li>
  1143. <li>8 popup für kommandos</li>
  1144. </ul>
  1145. </li>
  1146. <li>Eine ggf. angegebene Bschreibung wird anstelle des original-Gerätenamens angezeigt.</li>
  1147. </ul></li><br>
  1148. Beispiele:<br>
  1149. <ul>
  1150. <table>
  1151. <tr><td><code>attr lamp1 fp_Erdgeschoss 100,100</code></td><td><code>#display lamp1 with icon only at screenposition 100,100</code></td></tr>
  1152. <tr><td><code>attr lamp2 fp_Erdgeschoss 100,140,1,Art-Deco</code></td><td><code>#display lamp2 with description 'Art-Deco-Light' at 100,140</code></td></tr>
  1153. <tr><td><code>attr lamp2 fp_ErsteEtage 130,100,1</code></td><td><code>#display the same device at different positions on other floorplans</code></td></tr>
  1154. <tr><td><code>attr myFHT fp_Erdgeschoss 300,20,10,Temperature</code></td><td><code>#display given Text + FHT-temperature</code></td></tr>
  1155. </table>
  1156. </ul>
  1157. <b>Hinweis:</b> Die Parameter müssen ohne Leerstellen aneinandergereiht werden.<br><br>
  1158. <li><a name="fp_arrange">fp_arrange</a><br>
  1159. Aktiviert den "arrange-Modus" der ein zusätzliches Menü anzeigt,
  1160. mit dem Geräte auf dem Bildschirm angeordnet werden können. Bei aktiviertem arrange-mode können alle devices per drag&amp;drop platziert werden.<br>
  1161. Beispiel:
  1162. <ul>
  1163. <code>attr Erdgeschoss fp_arrange 1</code><br>
  1164. <code>attr Erdgeschoss fp_arrange WEB #Aktiviert den arrange-Modus nur für die Webinstanz WEB</code><br><br>
  1165. </ul>
  1166. </li>
  1167. <li><a name="stylesheet">stylesheet</a><br>
  1168. Ermöglicht die Verwendung eines eigenen css-stylesheet für Ihren floorplan. Dieses Attribut hat Vorrang vor dem Standard-stylesheet.
  1169. Das Standard-stylesheet für floorplans ist <code>floorplanstyle.css</code>. Falls <a href="#stylesheetPrefix">stylesheetPrefix</a> in der korrespondierenden FHEMWEB-Instanz gesetzt ist, wird dieser
  1170. <code>stylesheetPrefix</code> auch dem stylesheet für floorplans vorangestellt (prepend).<br>
  1171. Alle stylesheets werden im stylesheet-Ordner des fhem-Dateisystems abgelegt. Legen Sie dort
  1172. Ihr eigenes stylesheet neben <code>floorplanstyle.css</code> in demselben Ordner ab.<br>
  1173. Beispiel:
  1174. <ul>
  1175. <code>attr Erdgeschoss stylesheet myfloorplanstyle.css</code><br><br>
  1176. </ul>
  1177. </li>
  1178. <li><a name="fp_default">fp_default</a><br>
  1179. Der floorplan-Startbildschirm wird übersprungen wenn dieses Attribut einem der von Ihnen definierten floorplans zugeordnet ist.
  1180. </li>
  1181. Beispiel:
  1182. <ul>
  1183. <code>attr Erdgeschoss fp_default 1</code><br><br>
  1184. </ul>
  1185. <li><a name="fp_noMenu">fp_noMenu</a><br>
  1186. Blendet das floorplans-Menü aus, das normalerweise am linken Bildschirmrand angezeigt wird.
  1187. </li>
  1188. Beispiel:
  1189. <ul>
  1190. <code>attr Erdgeschoss fp_noMenu 1</code><br><br>
  1191. </ul>
  1192. <li><a name="commandfield">commandfield</a><br>
  1193. Fügt Ihrem floorplan ein fhem-Kommandofeld hinzu.
  1194. </li>
  1195. Beispiel:
  1196. <ul>
  1197. <code>attr Erdgeschoss commandfield 1</code><br><br>
  1198. </ul>
  1199. <li><a name="fp_backgroundimg">fp_backgroundimg</a><br>
  1200. Gestattet die Bennung eine Hintergundbilds unabhängig vom floorplan-Namen.<br>
  1201. <b>Hinweis:</b> Das Attribut kann mittels notify geändert werden, um z.B. unterschiedliche Hintergundbidlder am Tag oder in der Nacht anzuzeigen.<br>
  1202. Beispiel:
  1203. <ul>
  1204. <code>attr Erdgeschoss fp_backgroundimg foobar.png</code><br><br>
  1205. </ul>
  1206. </li>
  1207. <li><a name="fp_viewport">fp_viewport</a><br>
  1208. Gestattet die Verwendung eines abweichenden viewport-Wertes für die touchpad-Ausgabe.<br>
  1209. Die Default-viewport-Angbe ist "width=768".
  1210. </li>
  1211. <a name="fp_roomIcons"></a>
  1212. <li>fp_roomIcons<br>
  1213. Mit Leerstellen getrennte Liste von floorplan:icon -Paaren, um
  1214. einem Eintrag des floorplan-Menues icons zuzuordnen, genau wie
  1215. die entsprechende Funktionalitaet in FHEMWEB. Beispiel:<br>
  1216. attr Grundriss fp_roomIcons Grundriss:control_building_empty Media:audio_eq
  1217. </li>
  1218. <li><a name="fp_inherited">Vererbt von FHEMWEB</a><br>
  1219. Die folgenden Attribute werden von der zugrundliegenden <a href="#FHEMWEB">FHEMWEB</a>-Instanz vererbt:<br>
  1220. <ul>
  1221. <a href="#smallscreen">smallscreen</a><br>
  1222. <a href="#touchpad">touchpad</a><br>
  1223. <a href="#refresh">refresh</a><br>
  1224. <a href="#plotmode">plotmode</a><br>
  1225. <a href="#plotsize">plotsize</a><br>
  1226. <a href="#webname">webname</a><br>
  1227. <a href="#redirectCmds">redirectCmds</a><br>
  1228. <a href="#longpoll">longpoll</a><br>
  1229. <a href="#allowedCommands">allowedCommands</a><br>
  1230. </ul>
  1231. </li><br>
  1232. </ul>
  1233. <br>
  1234. </ul>
  1235. =end html_DE
  1236. =cut