From 4173691eef6a0f672502861f578c2af0489d8f2b Mon Sep 17 00:00:00 2001 From: martinhaas <> Date: Mon, 19 Mar 2007 13:26:11 +0000 Subject: [PATCH] Adjusted to new structure of FHEM >v3.3 git-svn-id: https://svn.fhem.de/fhem/trunk@28 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/99_ALARM.pm | 55 ++++++------- fhem/webfrontend/pgm3/CHANGED | 5 ++ fhem/webfrontend/pgm3/HISTORY | 4 + fhem/webfrontend/pgm3/config.php | 6 +- fhem/webfrontend/pgm3/include/ks300.php | 72 ++++++++++++++-- fhem/webfrontend/pgm3/index.php | 105 ++++++++++++++++-------- 6 files changed, 175 insertions(+), 72 deletions(-) diff --git a/fhem/contrib/99_ALARM.pm b/fhem/contrib/99_ALARM.pm index 3fbb3470f..f7a310e5f 100755 --- a/fhem/contrib/99_ALARM.pm +++ b/fhem/contrib/99_ALARM.pm @@ -1,23 +1,24 @@ -############################################## +############################################# # Low Budget ALARM System ############################################## -# ATTENTION! This is more a toy than a real alarm system! You must know what you do! +# ATTENTION! This is more a toy than a professional alarm system! +# You must know what you do! ############################################## # # Concept: # 1x Signal Light (FS20 allight) to show the status (activated/deactivated) -# 1x Sirene (FS20 alsir1) +# 2x Sirene (in/out) (FS20 alsir1 alsir2 ) # 2x PIRI-2 (FS20 piriu pirio) # 1x Sender (FS20 alsw) to activate/deactivate the system. -# Tip: use the KeyMatic CAC with pin code -# optional a normal sender (not a Keymatic CAC) FS20 alsw2 +# Tip: use the KeyMatic CAC with pin code or +# optional a normal sender (FS20 alsw2) # # Add something like the following lines to the configuration file : # notifyon alsw {MyAlsw()} # notifyon alsw2 {MyAlswNoPin()} # notifyon piriu {MyAlarm()} # notifyon pirio {MyAlarm()} -# and put this file in the /FHEM directory. +# and put this file in the /FHZ1000 directory. # # Martin Haas ############################################## @@ -28,11 +29,10 @@ use strict; use warnings; sub -ALARM_Initialize($) +ALARM_Initialize($$) { - my ($hash) = @_; - - $hash->{Category} = "none"; + my ($hash, $init) = @_; + $hash->{Type} = "none"; } @@ -42,25 +42,23 @@ sub MyAlsw() { my $ON="set allight on; setstate alsw on"; - my $OFF1="set allight off"; - my $OFF2="set alsir1 off"; - my $OFF3="setstate alsw off"; + my $OFF="set allight off; set alsir1 off; set alsir2 off; setstate alsw off"; if ( -e "/var/tmp/alertsystem") { unlink "/var/tmp/alertsystem"; + #Paranoia for (my $i = 0; $i < 2; $i++ ) { - fhz "$OFF1"; - fhz "$OFF2"; - fhz "$OFF3"; + fhem "$OFF"; }; Log 2, "alarm system is OFF"; } else { system "touch /var/tmp/alertsystem"; + #Paranoia for (my $i = 0; $i < 2; $i++ ) { - fhz "$ON" + fhem "$ON" } Log 2, "alarm system is ON"; }; @@ -81,7 +79,6 @@ my $timedout=5; { for (my $i = 1; $i < 4; $i++ ) { - system "touch /var/tmp/alontest$i"; system "touch -t 200601010101 /var/tmp/alontest$i"; } } @@ -97,15 +94,14 @@ my $timedout=5; if ( $testx > $timedout ) { system "touch /var/tmp/alontest$i"; - Log 2, "test$i: more than $timedout sec\n"; - die; + die "test$i: more than $timedout sec"; } } system "touch -t 200601010101 /var/tmp/alontest*"; Log 2, "ok, let's switch the alarm system..."; #if you only allow to activate (and not deactivate) with this script: -# if ( -e "/var/tmp/alertsystem") { die; }; + # if ( -e "/var/tmp/alertsystem") { die "deactivating alarm system not allowed"}; MyAlsw(); } @@ -123,29 +119,30 @@ MyAlarm() if ( -e "/var/tmp/alertsystem") { - - my $timer=180; # time until the sirene will be quit + my $timer=180; # time until the sirene will be quiet my $ON1="set alsir1 on-for-timer $timer"; + my $ON2="set alsir2 on-for-timer $timer"; #Paranoia - for (my $i = 1; $i < 3; $i++ ) + for (my $i = 0; $i < 2; $i++ ) { - fhz "$ON1"; + fhem "$ON1"; + fhem "$ON2"; } - Log 2, "ALARM! $ON1" ; + Log 2, "ALARM! #################" ; # have fun - my @lights=("stuwz1", "stuwz2", "stunacht", "stonacht", "stoliba"); + my @lights=("stuwz1", "stuwz2", "nachto", "nachtu", "stoliba" ,"stlileo"); my @rollos=("rolu4", "rolu5", "roloadi", "rololeo", "roloco", "rolowz", "rolunik1", "rolunik2"); foreach my $light (@lights) { - fhz "set $light on" + fhem "set $light on" } foreach my $rollo (@rollos) { - fhz "set $rollo on" + fhem "set $rollo on" } } } diff --git a/fhem/webfrontend/pgm3/CHANGED b/fhem/webfrontend/pgm3/CHANGED index 6448330d5..b85390189 100644 --- a/fhem/webfrontend/pgm3/CHANGED +++ b/fhem/webfrontend/pgm3/CHANGED @@ -104,3 +104,8 @@ Changelog -- Bugfix: DEL Button for at-Jobs now works -- Now you can use php4 OR php5 (php5 is recommended) -- Feature: php-Pictures of FHT now inclusive "desired-temp" + +2007-03-19 (0.8.0) +-- Feature: Now you can adjust the range of the Gnuplot-pictures of FHT in the config.php +-- Feature: WS300 is now supported +-- Internal: Adjusted to the new internal structure of FHEM. YOU MUST HAVE FHEM >=3.4. diff --git a/fhem/webfrontend/pgm3/HISTORY b/fhem/webfrontend/pgm3/HISTORY index 9655c143d..3241177ec 100644 --- a/fhem/webfrontend/pgm3/HISTORY +++ b/fhem/webfrontend/pgm3/HISTORY @@ -1,2 +1,6 @@ - Martin 2007-02-22 - Now you can adjust the range of the Gnuplot-pictures of FHT in the config.php + +- Martin 2007-03-19 + - Feature: WS300 ist now supported + - Adjusted to new structure of FHEM (IT NEEDS now FHZ1000/FHEM >= v3.4!) diff --git a/fhem/webfrontend/pgm3/config.php b/fhem/webfrontend/pgm3/config.php index 61d885ce5..e22af767f 100644 --- a/fhem/webfrontend/pgm3/config.php +++ b/fhem/webfrontend/pgm3/config.php @@ -1,7 +1,7 @@ global" $fhz1000port="7072"; # port of fhz1000.pl $logpath="/var/tmp"; # where are your logs? - $fhz1000_pl="/home/FHZ/fhz1000/fhz1000.pl"; #only required if you are using PHP4 + $fhz1000_pl="/home/FHEM/fhem/fhem.pl"; #only required if you are using PHP4 ################################################################################## ###### nice to have @@ -113,7 +113,7 @@ ############################################################################################## ## misc $taillog=1; #make shure to have the correct rights. Values: 0/1 - $taillogorder="/usr/bin/tail -20 $logpath/fhz1000.log"; + $taillogorder="/usr/bin/tail -20 $logpath/fhem.log"; diff --git a/fhem/webfrontend/pgm3/include/ks300.php b/fhem/webfrontend/pgm3/include/ks300.php index bbd2b083f..b4bc3a26a 100755 --- a/fhem/webfrontend/pgm3/include/ks300.php +++ b/fhem/webfrontend/pgm3/include/ks300.php @@ -67,6 +67,8 @@ $avgmonth=$_GET['avgmonth']; } } + #WS300 has Willi instead other things + if ($r=="Willi:") {$willi=1;}; $resultreverse = array_reverse($arraydata); $xold=$imgmaxxks; @@ -181,13 +183,13 @@ $avgmonth=$_GET['avgmonth']; $imh=$im; -#wind +#wind/Air Pressure $im = ImageCreateTrueColor($imgmaxxks,$imgmaxyks); ImageFill($im, 0, 0, $bg2p); ImageRectangle($im, 0, 0, $imgmaxxks-1, $imgmaxyks-1, $white); $oldmin=0; //only the data from every 10min - $min=120; + $min=120000; $max=-100; for ($x = 0; $x <= $maxdata; $x++) @@ -219,16 +221,16 @@ $avgmonth=$_GET['avgmonth']; }; }; ImageLine($im, $imgmaxxks-$x, 0,$imgmaxxks-$x , $imgmaxyks, $yellow); - $text="Wind"; + if (isset($willi)) $text="Air Pressure"; else $text="Wind"; $fontsize=7; $txtcolor=$bg3p; ImageTTFText ($im, $fontsize, 0, 5, 12, $txtcolor, $fontttf, $text); $fontsize=9; - $text=$temp." km/h"; + if (isset($willi)) $text=$temp." hPa"; else $text=$temp." km/h"; ImageTTFText ($im, $fontsize, 0, 80, 35, $txtcolor, $fontttfb, $text); $fontsize=7; - if ($showbft==1) + if (($showbft==1) and (! isset($willi))) { $text="( ".bft($temp)." Bft)"; ImageTTFText ($im, $fontsize, 0, 150, 35, $txtcolor, $fontttfb, $text); @@ -242,7 +244,10 @@ $avgmonth=$_GET['avgmonth']; $imw=$im; -#rain +#rain/willi + +if (! isset($willi)) +{ $im = ImageCreateTrueColor($imgmaxxks,$imgmaxyks); ImageFill($im, 0, 0, $bg2p); ImageRectangle($im, 0, 0, $imgmaxxks-1, $imgmaxyks-1, $white); @@ -315,7 +320,62 @@ $avgmonth=$_GET['avgmonth']; $text=$room; ImageTTFText ($im, $fontsize, 0, 7, 47, $txtcolor, $fontttf, $text); $imr=$im; +} +else # Willi: +{ + $im = ImageCreateTrueColor($imgmaxxks,$imgmaxyks); + ImageFill($im, 0, 0, $bg2p); + ImageRectangle($im, 0, 0, $imgmaxxks-1, $imgmaxyks-1, $white); + $oldmin=0; //only the data from every 10min + $min=120000; + $max=-100; + + for ($x = 0; $x <= $maxdata; $x++) + { + $temp=$resultreverse[$x][4]; + if ( $temp > $max ) $max=$temp; + if ( $temp < $min and ($temp != '')) $min=$temp; + } + $temp=$resultreverse[0][4]; + $tempdiff=$max-$min; + if ($tempdiff==0) $tempdiff=1; + $fac=$imgmaxyks/$tempdiff; + + + $xold=$imgmaxxks; + $yold=round($imgmaxyks-(($resultreverse[0][4]-$min)*$fac)); + + for ($x = 0; $x < count($resultreverse); $x++) + { + $y = round($imgmaxyks-(($resultreverse[$x][4]-$min)*$fac)); + ImageLine($im, $imgmaxxks-$x, $y, $xold, $yold, $red); + $xold=$imgmaxxks-$x; + $yold=$y; + $parts = explode("_", $resultreverse[$x][0]); + if ( ($parts[0] != $olddate) ) + { + $olddate=$parts[0]; + ImageLine($im, $imgmaxxks-$x, 0,$imgmaxxks-$x , $imgmaxyks, $bg1p); + }; + }; + ImageLine($im, $imgmaxxks-$x, 0,$imgmaxxks-$x , $imgmaxyks, $yellow); + $text="Willi"; + $fontsize=7; + $txtcolor=$bg3p; + ImageTTFText ($im, $fontsize, 0, 5, 12, $txtcolor, $fontttf, $text); + $fontsize=9; + $text=$temp; + ImageTTFText ($im, $fontsize, 0, 80, 35, $txtcolor, $fontttfb, $text); + $fontsize=7; + + $text2="min= $min max= $max"; + ImageTTFText ($im, $fontsize, 0, 60, 47, $txtcolor, $fontttf, $text2); + $text=$resultreverse[0][0]; + ImageTTFText ($im, $fontsize, 0, $imgmaxxks-130, 15, $txtcolor, $fontttf, $text); + + $imr=$im; +} diff --git a/fhem/webfrontend/pgm3/index.php b/fhem/webfrontend/pgm3/index.php index 512733ffb..8c9b5c722 100644 --- a/fhem/webfrontend/pgm3/index.php +++ b/fhem/webfrontend/pgm3/index.php @@ -1,6 +1,6 @@ \n"; } else { fwrite($fp, "xmllist\r\n;quit\r\n"); +# $fp=str_replace("DEVICES","LIST",$fp); while (!feof($fp)) { $outputvar = fgets($fp, 1024); array_push($output,$outputvar); @@ -243,6 +244,10 @@ else } } +#workaround for older fhz1000-Versions + + + # start_element_handler ( resource parser, string name, array attribs ) @@ -302,7 +307,7 @@ xml_parser_free($xml_parser); if ($showroombuttons==1) for($i=0; $i < count($stack[0][children]); $i++) { - if ($stack[0][children][$i][name]=='FS20_DEVICES') + if (substr($stack[0][children][$i][name],0,5)=='FS20_') { for($j=0; $j < count($stack[0][children][$i][children]); $j++) { @@ -322,7 +327,7 @@ xml_parser_free($xml_parser); if ((! in_array($fs20devxml,$fs20devs)) AND ( $room != 'hidden')) array_push($fs20devs,$fs20devxml); } }#FS20 - elseif ($stack[0][children][$i][name]=='FHT_DEVICES') + elseif (substr($stack[0][children][$i][name],0,4)=='FHT_') { for($j=0; $j < count($stack[0][children][$i][children]); $j++) { @@ -339,7 +344,7 @@ xml_parser_free($xml_parser); if ((! in_array($fhtdevxml,$fhtdevs)) AND ( $room != 'hidden')) array_push($fhtdevs,$fhtdevxml); } } #FHT - elseif ($stack[0][children][$i][name]=='HMS_DEVICES') + elseif (substr($stack[0][children][$i][name],0,4)=='HMS_') { for($j=0; $j < count($stack[0][children][$i][children]); $j++) { @@ -352,7 +357,7 @@ xml_parser_free($xml_parser); } } } # HMS - elseif ($stack[0][children][$i][name]=='KS300_DEVICES') + elseif (substr($stack[0][children][$i][name],0,6)=='KS300_') { for($j=0; $j < count($stack[0][children][$i][children]); $j++) { @@ -464,7 +469,7 @@ xml_parser_free($xml_parser); for($i=0; $i < count($stack[0][children]); $i++) { ############################ - if ($stack[0][children][$i][name]=='FS20_DEVICES') + if (substr($stack[0][children][$i][name],0,5)=='FS20_') { $type=$stack[0][children][$i][name]; echo ""; @@ -505,7 +510,7 @@ xml_parser_free($xml_parser); echo ""; } ############################ - elseif ($stack[0][children][$i][name]=='FHT_DEVICES') + elseif (substr($stack[0][children][$i][name],0,4)=='FHT_') { $type=$stack[0][children][$i][name]; echo ""; @@ -584,7 +589,7 @@ xml_parser_free($xml_parser); } } ############################ - elseif ($stack[0][children][$i][name]=='HMS_DEVICES') + elseif (substr($stack[0][children][$i][name],0,4)=='HMS_') { $type=$stack[0][children][$i][name]; echo ""; @@ -597,7 +602,7 @@ xml_parser_free($xml_parser); if ( $stack[0][children][$i][children][$j][children][$k][attrs][key]=="room") {$room=$stack[0][children][$i][children][$j][children][$k][attrs][value]; } - if ( $stack[0][children][$i][children][$j][children][$k][attrs][name]=="type") + if ( $stack[0][children][$i][children][$j][children][$k][attrs][key]=="type") {$type=$stack[0][children][$i][children][$j][children][$k][attrs][value];}; } if (($room != 'hidden') and ($showroom=='ALL' or $showroom==$room)) @@ -633,8 +638,9 @@ xml_parser_free($xml_parser); } } ############################ - elseif ($stack[0][children][$i][name]=='KS300_DEVICES') + elseif (substr($stack[0][children][$i][name],0,6)=='KS300_' or substr($stack[0][children][$i][name],0,6)=='WS300_') { + if ($stack[0][children][$i][name]=='WS300_LIST') $willi=1; $type=$stack[0][children][$i][name]; echo ""; echo "$type"; @@ -676,11 +682,17 @@ xml_parser_free($xml_parser); ";} else {echo " -
-
Temp./Hum.
-

Wind/Rain
-

- + "; + + if (! isset ($willi)) + { + echo "
Temp./Hum.
+

Wind/Rain
+

"; + } + else echo ""; + + echo "
"; }; @@ -701,7 +713,7 @@ xml_parser_free($xml_parser); } } ############################ - elseif ($stack[0][children][$i][name]=='LOGS') + elseif ($stack[0][children][$i][name]=='LOGS'or $stack[0][children][$i][name]=='FileLog_LIST') { echo " @@ -716,16 +728,24 @@ xml_parser_free($xml_parser); if (isset ($showlogs)) for($j=0; $j < count($stack[0][children][$i][children]); $j++) { + for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) + { + $check=$stack[0][children][$i][children][$j][children][$k][attrs][key]; + if ($check=='DEF') + { + $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; + } + } $name=$stack[0][children][$i][children][$j][attrs][name]; - $definition=$stack[0][children][$i][children][$j][attrs][definition]; - if ($definition != "") - {echo " - "; - } + #$definition=$stack[0][children][$i][children][$j][attrs][definition]; + #if ($definition != "") + echo " + "; + } } ############################ - elseif ($stack[0][children][$i][name]=='NOTIFICATIONS') + elseif ($stack[0][children][$i][name]=='NOTIFICATIONS' or $stack[0][children][$i][name]=='notify_LIST') { echo "
Log:$definition
Log:$value / $name
@@ -739,14 +759,20 @@ xml_parser_free($xml_parser); if (isset ($shownoti)) for($j=0; $j < count($stack[0][children][$i][children]); $j++) { - $event=$stack[0][children][$i][children][$j][attrs][event]; - $command=$stack[0][children][$i][children][$j][attrs][command]; - $measured=$stack[0][children][$i][children][$j][children][0][attrs][measured]; - echo ""; + for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) + { + $check=$stack[0][children][$i][children][$j][children][$k][attrs][key]; + if ($check=='DEF') + { + $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; + } + } + $name=$stack[0][children][$i][children][$j][attrs][name]; + echo ""; } } ############################ - elseif ($stack[0][children][$i][name]=='AT_JOBS') + elseif ($stack[0][children][$i][name]=='AT_JOBS' or $stack[0][children][$i][name]=='at_LIST') { echo "
Notification:$event $command
Notification:$value / $name
@@ -761,13 +787,24 @@ xml_parser_free($xml_parser); if (isset ($showat)) for($j=0; $j < count($stack[0][children][$i][children]); $j++) { - $command=$stack[0][children][$i][children][$j][attrs][command]; - $next=$stack[0][children][$i][children][$j][attrs][next]; + #$command=$stack[0][children][$i][children][$j][attrs][command]; + $command=$stack[0][children][$i][children][$j][attrs][name]; + #$next=$stack[0][children][$i][children][$j][attrs][next]; + $next=$stack[0][children][$i][children][$j][attrs][state]; $order=$command; - $order=str_replace("+","@",$order); - $order='del at '.$order; - if ($next != '') {$nexttxt='('.$next .')';} else {$nexttxt='';}; - echo ""; + for($k=0; $k < count($stack[0][children][$i][children][$j][children]); $k++) + { + $check=$stack[0][children][$i][children][$j][children][$k][attrs][key]; + if ($check=='DEF') + { + $value=$stack[0][children][$i][children][$j][children][$k][attrs][value]; + } + } + + #$order=str_replace("+","@",$order); + $order='delete '.$order; + #if ($next != '') {$nexttxt='('.$next .')';} else {$nexttxt='';}; + echo ""; } } };
AT-Job: del$command $nexttxt
AT-Job: del$value / $next / $command