mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
FLOORPLAN: longpoll by Matthias Gehre
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@2209 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c67736c84c
commit
f82a9cccb4
@ -4,7 +4,7 @@
|
|||||||
# Feedback: http://groups.google.com/group/fhem-users
|
# Feedback: http://groups.google.com/group/fhem-users
|
||||||
# Define Custom Floorplans
|
# Define Custom Floorplans
|
||||||
# Released : 26.02.2012
|
# Released : 26.02.2012
|
||||||
# Version : 1.01
|
# Version : 2.0
|
||||||
# Revisions:
|
# Revisions:
|
||||||
# 0001: Released to testers
|
# 0001: Released to testers
|
||||||
# 0002: use local FP_select and FP_submit after clash with FHEMWEB update
|
# 0002: use local FP_select and FP_submit after clash with FHEMWEB update
|
||||||
@ -30,27 +30,29 @@
|
|||||||
# 0020: moved creation of userattr to define, added slider and timepicker and setList, added style5 icon+commands, added style 6 readingstimestamp,
|
# 0020: moved creation of userattr to define, added slider and timepicker and setList, added style5 icon+commands, added style 6 readingstimestamp,
|
||||||
# added style-descriptions in fp-arrange (October 22, 2012)
|
# added style-descriptions in fp-arrange (October 22, 2012)
|
||||||
# 0021: fixed http-header, unsetting FF-autocomplete, added attribute fp_setbutton (fixes by Matthias) (November 23, 2012)
|
# 0021: fixed http-header, unsetting FF-autocomplete, added attribute fp_setbutton (fixes by Matthias) (November 23, 2012)
|
||||||
|
# 0022: longpoll by Matthias Gehre (November 27, 2012)
|
||||||
#
|
#
|
||||||
################################################################
|
################################################################
|
||||||
#
|
#
|
||||||
# Copyright notice
|
# Copyright notice
|
||||||
#
|
#
|
||||||
# (c) 2012 Copyright: Ulrich Maass
|
# (c) 2012 Copyright: Ulrich Maass
|
||||||
# All rights reserved
|
|
||||||
#
|
#
|
||||||
# This script is free software; you can redistribute it and/or modify
|
# This file is part of fhem.
|
||||||
|
#
|
||||||
|
# Fhem is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# The GNU General Public License can be found at
|
# Fhem is distributed in the hope that it will be useful,
|
||||||
# http://www.gnu.org/copyleft/gpl.html.
|
|
||||||
#
|
|
||||||
# This script is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with fhem. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
# Usage
|
# Usage
|
||||||
# define <NAME> FLOORPLAN
|
# define <NAME> FLOORPLAN
|
||||||
@ -71,7 +73,7 @@
|
|||||||
# To make objects display, they will thereby get assigned
|
# To make objects display, they will thereby get assigned
|
||||||
# attr <device> fp_<name> <top>,<left>,<style>,<text>
|
# attr <device> fp_<name> <top>,<left>,<style>,<text>
|
||||||
# displays device <device> on floorplan <name> at position top:<top>,left:<left> with style <style> and description <text>
|
# displays device <device> on floorplan <name> at position top:<top>,left:<left> with style <style> and description <text>
|
||||||
# styles: 0: icon/state only, 1: name+icon, 2: name+icon+commands 3:Device-Readings(+name) 3:S300TH
|
# styles: 0: icon/state only, 1: name+icon, 2: name+icon+commands 3:Device-Readings(+name) 4:S300TH
|
||||||
# Example: attr lamp fp_Groundfloor 100,100,1,TableLamp #displays lamp at position 100px,100px
|
# Example: attr lamp fp_Groundfloor 100,100,1,TableLamp #displays lamp at position 100px,100px
|
||||||
#
|
#
|
||||||
# Repeat step 3 to add further devices. Delete attr fp_<name> when all devices are arranged on your screen. Enjoy.
|
# Repeat step 3 to add further devices. Delete attr fp_<name> when all devices are arranged on your screen. Enjoy.
|
||||||
@ -175,7 +177,7 @@ FP_CGI(){
|
|||||||
$FP_name = undef;
|
$FP_name = undef;
|
||||||
my ($p,$v) = ("",""); #parameter and value of analyzed URL
|
my ($p,$v) = ("",""); #parameter and value of analyzed URL
|
||||||
$FW_RET = ""; # blank out any html-code written so far by fhemweb
|
$FW_RET = ""; # blank out any html-code written so far by fhemweb
|
||||||
# $FW_longpoll = (AttrVal($FW_wname, "longpoll", undef)); # longpoll doesn't work (yet) for floorplans
|
$FW_longpoll = (AttrVal($FW_wname, "longpoll", undef)); # longpoll
|
||||||
$FW_detail = 0;
|
$FW_detail = 0;
|
||||||
$FW_plotmode = AttrVal($FW_wname, "plotmode", "SVG");
|
$FW_plotmode = AttrVal($FW_wname, "plotmode", "SVG");
|
||||||
$FW_plotsize = AttrVal($FW_wname, "plotsize", $FW_ss ? "480,160" :
|
$FW_plotsize = AttrVal($FW_wname, "plotsize", $FW_ss ? "480,160" :
|
||||||
@ -334,8 +336,6 @@ FP_htmlHeader($) {
|
|||||||
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/js/svg.js\"></script>"
|
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/js/svg.js\"></script>"
|
||||||
if($FW_plotmode eq "SVG");
|
if($FW_plotmode eq "SVG");
|
||||||
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/js/fhemweb.js\"></script>";
|
FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/js/fhemweb.js\"></script>";
|
||||||
# FW_pO "<script type=\"text/javascript\" src=\"$FW_ME/longpoll.js\"></script>"
|
|
||||||
# if($FW_longpoll); # longpoll not yet implemented for floorplans
|
|
||||||
FW_pO "</head>\n";
|
FW_pO "</head>\n";
|
||||||
}
|
}
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@ -377,7 +377,8 @@ FP_show(){
|
|||||||
### Page start
|
### Page start
|
||||||
FP_htmlHeader("$FP_name");
|
FP_htmlHeader("$FP_name");
|
||||||
## body
|
## body
|
||||||
FW_pO "<body id=\"$FP_name-body\">\n";
|
my $onload = $FW_longpoll ? "onload=\"FW_delayedStart()\"" : "";
|
||||||
|
FW_pO "<body id=\"$FP_name-body\" $onload>\n";
|
||||||
FW_pO "<div id=\"backimg\" style=\"width: 99%; height: 99%;\">";
|
FW_pO "<div id=\"backimg\" style=\"width: 99%; height: 99%;\">";
|
||||||
FW_pO FW_makeImage(AttrVal($FP_name, "fp_backgroundimg", "fp_$FP_name"));
|
FW_pO FW_makeImage(AttrVal($FP_name, "fp_backgroundimg", "fp_$FP_name"));
|
||||||
FW_pO "</div>\n";
|
FW_pO "</div>\n";
|
||||||
@ -413,7 +414,7 @@ FP_show(){
|
|||||||
|
|
||||||
FW_pO "\n<div style=\"position:absolute; top:".$top."px; left:".$left."px;\" id=\"div-$d\">";
|
FW_pO "\n<div style=\"position:absolute; top:".$top."px; left:".$left."px;\" id=\"div-$d\">";
|
||||||
FW_pO "<form method=\"get\" action=\"$FW_ME/floorplan/$FP_name/$d\" autocomplete=\"off\">";
|
FW_pO "<form method=\"get\" action=\"$FW_ME/floorplan/$FP_name/$d\" autocomplete=\"off\">";
|
||||||
FW_pO " <table class=\"$type fp_$FP_name\" id=\"$d\" align=\"center\">"; # Main table per device
|
FW_pO " <table class=\"$type fp_$FP_name\" id=\"table-$d\" align=\"center\">"; # Main table per device
|
||||||
my ($allSets, $cmdlist, $txt) = FW_devState($d, "");
|
my ($allSets, $cmdlist, $txt) = FW_devState($d, "");
|
||||||
#Debug "txt is \"$txt\"";
|
#Debug "txt is \"$txt\"";
|
||||||
$txt = ReadingsVal($d, $text, "Undefined Reading $d-<b>$text</b>") if ($style == 3 || $style == 6); # Style3+6 = DeviceReading given in $text
|
$txt = ReadingsVal($d, $text, "Undefined Reading $d-<b>$text</b>") if ($style == 3 || $style == 6); # Style3+6 = DeviceReading given in $text
|
||||||
@ -422,7 +423,7 @@ FP_show(){
|
|||||||
########################
|
########################
|
||||||
# Device-name per device
|
# Device-name per device
|
||||||
if ($style gt 0 && $style ne 5) {
|
if ($style gt 0 && $style ne 5) {
|
||||||
FW_pO " <tr class=\"devicename fp_$FP_name\" id=\"$d\">"; # For css: class=devicename, id=devicename
|
FW_pO " <tr class=\"devicename fp_$FP_name\" id=\"$d-devicename\">"; # For css: class=devicename, id=<devicename>-devicename
|
||||||
my $devName = "";
|
my $devName = "";
|
||||||
if ($style == 3 || $style == 6) {
|
if ($style == 3 || $style == 6) {
|
||||||
$devName = $text2 ? $text2 : ""; # Style 3 = Reading - use last part of comma-separated description
|
$devName = $text2 ? $text2 : ""; # Style 3 = Reading - use last part of comma-separated description
|
||||||
@ -459,7 +460,7 @@ FP_show(){
|
|||||||
|
|
||||||
if ($style == 6) { # add ReadingsTimeStamp for style 6
|
if ($style == 6) { # add ReadingsTimeStamp for style 6
|
||||||
$txt="";
|
$txt="";
|
||||||
FW_pO "<tr class=\"devicetimestamp fp_$FP_name\" id=\"$d\">"; # For css: class=devicetimestamp, id=devicename
|
FW_pO "<tr class=\"devicetimestamp fp_$FP_name\" id=\"$d-devicetimestamp\">"; # For css: class=devicetimestamp, id=<devicename>-devicetimestamp
|
||||||
$txt = ReadingsTimestamp($d, $text, "Undefined Reading $d-<b>$text</b>") if ($style == 3 || $style == 6); # Style3+6 = DeviceReading given in $text
|
$txt = ReadingsTimestamp($d, $text, "Undefined Reading $d-<b>$text</b>") if ($style == 3 || $style == 6); # Style3+6 = DeviceReading given in $text
|
||||||
FW_pO "<td colspan=\"$cols\">$txt";
|
FW_pO "<td colspan=\"$cols\">$txt";
|
||||||
FW_pO "</td></tr>";
|
FW_pO "</td></tr>";
|
||||||
@ -473,7 +474,7 @@ FP_show(){
|
|||||||
my @cList = split(":", $cmdlist);
|
my @cList = split(":", $cmdlist);
|
||||||
my @rList = map { ReplaceEventMap($d,$_,1) } @cList;
|
my @rList = map { ReplaceEventMap($d,$_,1) } @cList;
|
||||||
my $firstIdx = 0;
|
my $firstIdx = 0;
|
||||||
FW_pO " <tr class=\"devicecommands\" id=\"$d\">";
|
FW_pO " <tr class=\"devicecommands\" id=\"$d-devicecommands\">";
|
||||||
# Special handling (slider, dropdown)
|
# Special handling (slider, dropdown)
|
||||||
my $FW_room = undef; ##needed to be able to reuse code from FHEMWEB
|
my $FW_room = undef; ##needed to be able to reuse code from FHEMWEB
|
||||||
my $cmd = $cList[0];
|
my $cmd = $cList[0];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user