2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

Adjusted to new structure of FHEM >v3.3

git-svn-id: https://svn.fhem.de/fhem/trunk@28 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
martinhaas 2007-03-19 13:26:11 +00:00
parent 81e6d216c4
commit 4173691eef
6 changed files with 175 additions and 72 deletions

View File

@ -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 <modpath>/FHEM directory.
# and put this file in the <modpath>/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"
}
}
}

View File

@ -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.

View File

@ -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!)

View File

@ -1,7 +1,7 @@
<?php
##################################################################################
#### pgm3 -- a PHP-webfrontend for fhz1000.pl
#### pgm3 -- a PHP-webfrontend for fhem.pl
###### required settings
@ -10,7 +10,7 @@
# run global: "port <nr> 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";

View File

@ -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;
}

View File

@ -1,6 +1,6 @@
<?php
#### pgm3 -- a PHP-webfrontend for fhz1000.pl
#### pgm3 -- a PHP-webfrontend for fhem.pl
################################################################
#
@ -39,7 +39,7 @@ include "config.php";
include "include/gnuplot.php";
$pgm3version='0.7.2cvs';
$pgm3version='0.8.0cvs';
$Action = $_POST['Action'];
@ -235,6 +235,7 @@ else
echo "$errstr ($errno)<br />\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 "<tr><td $bg1 colspan=4><font $fontcolor1>";
@ -505,7 +510,7 @@ xml_parser_free($xml_parser);
echo "</td></tr>";
}
############################
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 "<tr><td $bg1 colspan=4><font $fontcolor1>";
@ -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 "<tr><td $bg1 colspan=4><font $fontcolor1>";
@ -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 "<tr><td $bg1 colspan=4><font $fontcolor1>";
echo "$type</font></td></tr>";
@ -676,11 +682,17 @@ xml_parser_free($xml_parser);
<input type=submit value='hide'></form></td>";}
else
{echo "<tr valign=center><td align=center $bg2 valign=center>
<form action=$forwardurl method='POST'>
<input type=hidden name=Action value=showks><br>Temp./Hum.<br>
<form action=$forwardurl method='POST'>";
if (! isset ($willi))
{
echo "<input type=hidden name=Action value=showks><br>Temp./Hum.<br>
<input type=radio name=kstyp value=\"1\" checked><br><br>Wind/Rain<br>
<input type=radio name=kstyp value=\"2\"><br><br>
<input type=hidden name=showroom value=$showroom>
<input type=radio name=kstyp value=\"2\"><br><br>";
}
else echo "<input type=hidden name=kstyp value=\"1\" checked>";
echo "<input type=hidden name=showroom value=$showroom>
<input type=hidden name=showks value=$KSdev>
<input type=submit value='show'></form></td>";
};
@ -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 "<tr><td $bg1 colspan=4><font $fontcolor1>
<table cellspacing='0' cellpadding='0' width='100%'>
@ -716,16 +728,24 @@ xml_parser_free($xml_parser);
if (isset ($showlogs))
for($j=0; $j < count($stack[0][children][$i][children]); $j++)
{
$name=$stack[0][children][$i][children][$j][attrs][name];
$definition=$stack[0][children][$i][children][$j][attrs][definition];
if ($definition != "")
{echo "<tr><td colspan=2 border=0>Log:</td>
<td colspan=2 border=0>$definition</td></tr>";
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 "<tr><td colspan=2 border=0>Log:</td>
<td colspan=2 border=0>$value / $name </td></tr>";
}
}
############################
elseif ($stack[0][children][$i][name]=='NOTIFICATIONS')
elseif ($stack[0][children][$i][name]=='NOTIFICATIONS' or $stack[0][children][$i][name]=='notify_LIST')
{
echo "<tr><td $bg1 colspan=4><font $fontcolor1>
<table cellspacing='0' cellpadding='0' width='100%'>
@ -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 "<tr><td colspan=2>Notification:</td><td colspan=2>$event $command</td></tr>";
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 "<tr><td colspan=2>Notification:</td><td colspan=2>$value / $name</td></tr>";
}
}
############################
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 "<tr><td $bg1 colspan=4><font $fontcolor1>
<table cellspacing='0' cellpadding='0' width='100%'>
@ -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 "<tr><td> AT-Job: </td><td><a href='index.php?Action=exec&order=$order$link'>del</a></td><td colspan=2>$command $nexttxt</td></tr>";
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 "<tr><td> AT-Job: </td><td><a href='index.php?Action=exec&order=$order$link'>del</a></td><td colspan=2>$value / $next / $command</td></tr>";
}
}
};