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

Module reorganization / small bugfixes / doc changes

git-svn-id: https://svn.fhem.de/fhem/trunk@110 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2007-11-26 14:56:45 +00:00
parent 8410288c1e
commit ed07484166
12 changed files with 151 additions and 78 deletions

View File

@ -342,22 +342,23 @@
- ==DATE== (4.2)
- feature: added archivedir/archivecmd to the the main logfile
- feature: 99_Sunrise_EL.pm (does not need any Date modules)
- bugfix: Seldom xmllist error resulting in corrupt xml (Martin/Peter, 4.9)
- bugfix: seldom xmllist error resulting in corrupt xml (Martin/Peter, 4.9)
- bugfix: FHT mode holiday_short added (9.9, Dirk)
- bugfix: Modifying a device from its own trigger crashes (Klaus, 10.9)
- feature: webpgm2 output reformatted
- feature: webpgm2 displaying multiple plots
- feature: FHT lime-protection code discovered by Dirk (7.10)
- feature: Softwarebuffer for FHT devices (Dirk 17.10)
- feature: softwarebuffer for FHT devices (Dirk 17.10)
- feature: FHT low temperatur warning and offset (Dirk 17.10)
- change: Change FHT state into warnings (Dirk 17.10)
- change: change FHT state into warnings (Dirk 17.10)
- feature: Softwarebuffer code simplified (Rudi 22.11)
- bugfix: bug #12327 doppeltes my
- bugfix: set STATE from trigger
- bugfix: readings state vs STATE problem (xmllist/trigger)
- change: SUNRISE doc changed (99_SUNRISE.pm -> 99_SUNRISE_EL.pm)
- feature: Support for the M232 ELV device (Boris, 25.11)
- feature: support for the M232 ELV device (Boris, 25.11)
- feature: alternativ Quad-based numbers for the FS20 (Matthias, 24.11)
- feature: dummy type added (contrib/99_dummy.pm)
- TODO
emem -2.5kW / getDevData for emwz -1
dummy type / dummy attribute

View File

@ -69,7 +69,7 @@ FHZ_Initialize($)
$hash->{StateFn} = "FHZ_SetState";
$hash->{ParseFn} = "FHZ_Parse";
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 filtertimeout repeater:1,0 " .
"showtime:1,0 model:fhz1000,fhz1300 loglevel:0,1,2,3,4,5,6" .
"showtime:1,0 model:fhz1000,fhz1300 loglevel:0,1,2,3,4,5,6 ".
"fhtsoftbuffer:1,0";
}
@ -208,7 +208,7 @@ FHZ_Define($$)
my $dev = $a[2];
$attr{$name}{savefirst} = 1;
$attr{$name}{fhtsoftbuffer} = 1;
$attr{$name}{fhtsoftbuffer} = 0;
if($dev eq "none") {
Log 1, "FHZ device is none, commands will be echoed only";

View File

@ -247,15 +247,24 @@ FS20_Define($$)
"addr [fg addr] [lm addr] [gm FF]";
return $u if(int(@a) < 4);
return "Define $a[0]: wrong housecode format: specify a 4 digit hex value"
if($a[2] !~ m/^[a-f0-9]{4}$/i);
return "Define $a[0]: wrong btn format: specify a 2 digit hex value"
if($a[3] !~ m/^[a-f0-9]{2}$/i);
return "Define $a[0]: wrong housecode format: specify a 4 digit hex value ".
"or an 8 digit quad value"
if( ($a[2] !~ m/^[a-f0-9]{4}$/i) && ($a[2] !~ m/^[1-4]{8}$/i) );
$hash->{XMIT} = lc($a[2]);
$hash->{BTN} = lc($a[3]);
return "Define $a[0]: wrong btn format: specify a 2 digit hex value " .
"or a 4 digit quad value"
if( ($a[3] !~ m/^[a-f0-9]{2}$/i) && ($a[3] !~ m/^[1-4]{4}$/i) );
my $code = lc("$a[2] $a[3]");
my $housecode = $a[2];
$housecode = four2hex($housecode,4) if (length($housecode) == 8);
my $btncode = $a[3];
$btncode = four2hex($btncode,2) if (length($btncode) == 4);
$hash->{XMIT} = lc($housecode);
$hash->{BTN} = lc($btncode);
my $code = "$housecode $btncode";
my $ncode = 1;
my $name = $a[0];
@ -268,16 +277,21 @@ FS20_Define($$)
$a[$i] = lc($a[$i]);
if($a[$i] eq "fg") {
return "Bad fg address, see the doc" if($a[$i+1] !~ m/^f[a-f0-9]$/);
return "Bad fg address for $name, see the doc" if( ($a[$i+1] !~ m/^f[a-f0-9]$/) && ($a[$i+1] !~ m/^44[1-4][1-4]$/));
} elsif($a[$i] eq "lm") {
return "Bad lm address, see the doc" if($a[$i+1] !~ m/^[a-f0-9]f$/);
return "Bad lm address for $name, see the doc" if( ($a[$i+1] !~ m/^[a-f0-9]f$/) && ($a[$i+1] !~ m/^[1-4][1-4]44$/));
} elsif($a[$i] eq "gm") {
return "Bad gm address, mus be ff" if($a[$i+1] ne "ff");
return "Bad gm address for $name, must be ff" if( ($a[$i+1] ne "ff") && ($a[$i+1] ne "4444"));
} else {
return $u;
}
$code = lc("$a[2] $a[$i+1]");
my $grpcode = $a[$i+1];
if (length($grpcode) == 4) {
$grpcode = four2hex($grpcode,2);
}
$code = "$housecode $grpcode";
$hash->{CODE}{$ncode++} = $code;
$defptr{$code}{$name} = $hash;
}
@ -342,12 +356,38 @@ FS20_Parse($$)
# it by the second FHZ
return "" if($dev eq "0001" && $btn eq "00" && $cde eq "00");
Log 3, "FS20 Unknown device $dev, Button $btn Code $cde ($v), " .
my $dev_four = hex2four($dev);
my $btn_four = hex2four($btn);
Log 3, "FS20 Unknown device $dev ($dev_four), Button $btn ($btn_four) Code $cde ($v), " .
"please define it";
return "UNDEFINED FS20 $dev/$btn/$cde";
}
}
#############################
sub
hex2four($)
{
my $v = shift;
my $r = "";
foreach my $x (split("", $v)) {
$r .= sprintf("%d%d", (hex($x)/4)+1, (hex($x)%4)+1);
}
return $r;
}
#############################
sub
four2hex($$)
{
my ($v,$len) = @_;
my $r = 0;
foreach my $x (split("", $v)) {
$r = $r*4+($x-1);
}
return sprintf("%0*x", $len,$r);
}
1;

View File

@ -28,7 +28,7 @@ EM_Initialize($)
$hash->{UndefFn} = "EM_Undef";
$hash->{GetFn} = "EM_Get";
$hash->{SetFn} = "EM_Set";
$hash->{AttrList}= "model:em1010pc loglevel:0,1,2,3,4,5,6";
$hash->{AttrList}= "model:em1010pc dummy:1,0 loglevel:0,1,2,3,4,5,6";
}
#####################################

View File

@ -31,7 +31,7 @@ M232Counter_GetStatus($)
my ($hash) = @_;
if(!$hash->{LOCAL}) {
InternalTimer(gettimeofday()+60, "M232Counter_GetStatus", $hash);
InternalTimer(gettimeofday()+60, "M232Counter_GetStatus", $hash, 1);
}
my $name = $hash->{NAME};
@ -161,15 +161,9 @@ M232Counter_Define($$)
AssignIoPort($hash);
# InternalTimer blocks if init_done is not true
my $oid = $init_done;
$init_done = 1;
if(!$hash->{LOCAL}) {
InternalTimer(gettimeofday()+60, "M232Counter_GetStatus", $hash);
InternalTimer(gettimeofday()+60, "M232Counter_GetStatus", $hash, 0);
}
$init_done = $oid;
return undef;
}

41
fhem/FHEM/98_dummy.pm Normal file
View File

@ -0,0 +1,41 @@
##############################################
package main;
use strict;
use warnings;
sub
dummy_Initialize($)
{
my ($hash) = @_;
$hash->{SetFn} = "dummy_Set";
$hash->{DefFn} = "dummy_Define";
}
###################################
sub
dummy_Set($@)
{
my ($hash, @a) = @_;
return "no set value specified" if(int(@a) != 2);
my $v = $a[1];
$hash->{CHANGED}[0] = $v;
$hash->{STATE} = $v;
$hash->{READINGS}{state}{TIME} = TimeNow();
$hash->{READINGS}{state}{VAL} = $v;
return undef;
}
sub
dummy_Define($$)
{
my ($hash, $def) = @_;
my @a = split("[ \t][ \t]*", $def);
return "Wrong syntax: use define <name> dummy" if(int(@a) != 2);
return undef;
}
1;

View File

@ -17,3 +17,4 @@ time_str2num($)
return mktime($a[5],$a[4],$a[3],$a[2],$a[1]-1,$a[0]-1900,0,0,-1);
}
1;

View File

@ -1,34 +0,0 @@
##############################################
package main;
use strict;
use warnings;
#####################################
sub
weblink_Initialize($)
{
my ($hash) = @_;
$hash->{DefFn} = "weblink_Define";
}
#####################################
sub
weblink_Define($$)
{
my ($hash, $def) = @_;
my ($type, $name, $wltype, $link) = split("[ \t]+", $def, 4);
my %thash = ( link=>1, fileplot=>1 );
if(!$link || !$thash{$wltype}) {
return "Usage: define <name> weblink [" . join("|",sort keys %thash) . "] <httplink>";
}
$hash->{WLTYPE} = $wltype;
$hash->{LINK} = $link;
$hash->{STATE} = "initial";
return undef;
}
1;

View File

@ -14,6 +14,10 @@
skeleton for self-written perl funtions.
- 99_ALARM.pm
Example for a Low Budget ALARM System by Martin
- 99_dummy.pm
Used for programming
- 99_weblink.pm
Used by fhemweb2.pl
- checkmsg.pl
Check header/function/crc of an FS20 hex message
- crc.pl

View File

@ -946,15 +946,37 @@ split in multiple lines<br><br>
Notes:
<ul>
Normally you won't have to define fileplot weblinks manually, as fhemweb.pl
(webpgm2) makes it easy for you, just plot a logfile (see <a
href="#logtype">logtype</a>) and convert it to weblink. Now you can
group these weblinks by putting them into rooms.
If you convert the current logfile to a weblink, it will always refer to the
current file (and not the one you originally specified).
<li>Normally you won't have to define fileplot weblinks manually, as
fhemweb.pl (webpgm2) makes it easy for you, just plot a logfile (see
<a href="#logtype">logtype</a>) and convert it to weblink. Now you
can group these weblinks by putting them into rooms. If you convert
the current logfile to a weblink, it will always refer to the current
file (and not the one you originally specified).</li>
<li>The <b>99_weblink.pm</b> module is in the contrib directory, you have
to "install" it manually by copying it into the FHEM directory. </li>
</ul>
</ul>
<a name="dummy"></a>
<h4>Type dummy</h4>
<ul>
<code>define &lt;name&gt; dummy</code>
<br><br>
Define a dummy. A dummy can take via <a href="#set">set</a> any values.
Used for programming.
Example:
<ul>
<code>define myvar dummy</code><br>
<code>set myvar 7</code><br>
</ul>
Notes:
<ul>
<li>The <b>99_dummy.pm</b> module is in the contrib directory, you have
to "install" it manually by copying it into the FHEM directory.</li>
</ul>>
</ul>
</ul>

View File

@ -164,11 +164,11 @@ description and <a href="faq.html">faq.html</a> for the F.A.Q.
else everybody will be able to set your devices</li>
</ul>
<h3>Web frontend 2 (webfrontend/pgm2, the simple one)</h3>
<h3>Web frontend 2 (webfrontend/pgm2)</h3>
<ul>
This frontend is CGI/CSS based. It has support for rooms, and FHT/KS300 logs.<br>
Screenshots: <a href="pgm2-1.gif">overview</a>, <a href="pgm2-2.gif">details
</a> and KS300 temperature <a href="pgm2-3.gif">logs</a><br><br>
Screenshots: <a href="pgm2-1.png">one</a>, <a href="pgm2-2.png">two</a>.
<br><br>
<ul>
<li>Copy the file fhemweb.pl and *.gplot to your cgi-bin directory
@ -189,7 +189,7 @@ description and <a href="faq.html">faq.html</a> for the F.A.Q.
For special features like assigning devices to rooms see the README file.
</ul>
<h3>Web frontend 3 (webfrontend/pgm3, the professional one)</h3>
<h3>Web frontend 3 (webfrontend/pgm3)</h3>
<ul>
This frontend is PHP based and was contributed by Martin Haas.
Look at the webfrontends/pgm3/docs for more documentation or at

View File

@ -135,7 +135,7 @@ my %intAt; # Internal at timer hash.
my $intAtCnt=0;
my $reread_active = 0;
my $AttrList = "room comment";
my $cvsid = '$Id: fhem.pl,v 1.29 2007-11-26 08:27:04 rudolfkoenig Exp $';
my $cvsid = '$Id: fhem.pl,v 1.30 2007-11-26 14:56:45 rudolfkoenig Exp $';
$init_done = 0;
@ -745,9 +745,13 @@ CommandSave($$)
print SFH "\ndefattr" . ($r ne "~" ? " room $r" : "") . "\n";
foreach my $d (sort keys %{$rooms{$r}} ) {
next if($defs{$d}{VOLATILE});
my $def = $defs{$d}{DEF};
$def =~ s/;/;;/g;
print SFH "define $d $defs{$d}{TYPE} $def\n";
if($defs{$d}{DEF}) {
my $def = $defs{$d}{DEF};
$def =~ s/;/;;/g;
print SFH "define $d $defs{$d}{TYPE} $def\n";
} else {
print SFH "define $d $defs{$d}{TYPE}\n";
}
foreach my $a (sort keys %{$attr{$d}}) {
next if($a eq "room");
print SFH "attr $d $a $attr{$d}{$a}\n";
@ -915,7 +919,7 @@ CommandDefine($$)
$hash{NAME} = $a[0];
$hash{TYPE} = $a[1];
$hash{STATE} = "???";
$hash{DEF} = $a[2];
$hash{DEF} = $a[2] if(int(@a) > 2);
$hash{NR} = $devcount++;
# If the device wants to issue initialization gets/sets, then it needs to be
@ -1233,7 +1237,7 @@ CommandAttr($$)
my $list = getAllAttr($a[0]);
return "Unknown argument $a[1], choose one of $list" if($a[1] eq "?");
return "Unknown attribute $a[1], use attr global userattr"
return "Unknown attribute $a[1], use attr global userattr ($list)"
if(" $list " !~ m/ ${a[1]}[ :;]/);