2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-12 22:56:34 +00:00

CUL_HM added

git-svn-id: https://svn.fhem.de/fhem/trunk@751 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2010-11-06 19:31:38 +00:00
parent a7c0b99e2c
commit 88674818c5
5 changed files with 161 additions and 47 deletions

View File

@ -7,6 +7,7 @@
- bugfix: S300TH sanity check won't allow negative temperatures.
- feature: decode CUL uptime
- feature: USB doc changes, FHZ initFS20_02/stopHMS parameters by Andreas.
- feature: CUL_HM (experimental) for HomeMatic devices.
- 2010-08-15 (5.0)
- **NOTE*: The default installation path is changed to satisfy lintian

View File

@ -5,15 +5,15 @@ use strict;
use warnings;
use Time::HiRes qw(gettimeofday);
sub CUL_Attr(@);
sub CUL_Clear($);
sub CUL_Write($$$);
sub CUL_Read($);
sub CUL_ReadAnswer($$$$);
sub CUL_Ready($);
sub CUL_HandleCurRequest($$);
sub CUL_HandleWriteQueue($);
sub CUL_Parse($$$$$);
sub CUL_Read($);
sub CUL_ReadAnswer($$$$);
sub CUL_Ready($);
sub CUL_Write($$$);
sub CUL_OpenDev($$);
sub CUL_CloseDev($);
@ -38,7 +38,6 @@ my %sets = (
"bWidth" => "",
"rAmpl" => "",
"sens" => "",
"verbose" => "X",
"led" => "l",
"patable" => "x",
"file" => "",
@ -47,18 +46,11 @@ my %sets = (
my @ampllist = (24, 27, 30, 33, 36, 38, 40, 42); # rAmpl(dB)
sub
CUL_Initialize($)
{
my ($hash) = @_;
my $clientsSlowRF = ":FS20:FHT:FHT8V:KS300:USF1000:BS:HMS" .
":CUL_EM:CUL_WS:CUL_FHTTK:CUL_RFR:CUL_HOERMANN:";
my $clientsHomeMatic = ":CUL_HM:";
# Provider
$hash->{ReadFn} = "CUL_Read";
$hash->{WriteFn} = "CUL_Write";
$hash->{Clients} =
":FS20:FHT:KS300:CUL_EM:CUL_WS:USF1000:BS:HMS:CUL_FHTTK:CUL_RFR:FHT8V".
":CUL_HOERMANN:";
my %mc = (
my %matchListSlowRF = (
"1:USF1000" => "^81..(04|0c)..0101a001a5ceaa00....",
"2:BS" => "^81..(04|0c)..0101a001a5cf",
"3:FS20" => "^81..(04|0c)..0101a001",
@ -70,8 +62,23 @@ CUL_Initialize($)
"9:CUL_FHTTK" => "^T........",
"A:CUL_RFR" => "^[0-9A-F]{4}U.",
"B:CUL_HOERMANN"=> "^R..........",
);
$hash->{MatchList} = \%mc;
);
my %matchListHomeMatic = (
"1:CUL_HM" => "^A......................",
);
sub
CUL_Initialize($)
{
my ($hash) = @_;
# Provider
$hash->{ReadFn} = "CUL_Read";
$hash->{WriteFn} = "CUL_Write";
$hash->{Clients} = $clientsSlowRF;
$hash->{MatchList} = \%matchListSlowRF;
$hash->{HomeMaticClients} = $clientsHomeMatic;
$hash->{HomeMaticMatchList} = \%matchListHomeMatic;
$hash->{ReadyFn} = "CUL_Ready";
# Normal devices
@ -80,9 +87,11 @@ CUL_Initialize($)
$hash->{GetFn} = "CUL_Get";
$hash->{SetFn} = "CUL_Set";
$hash->{StateFn} = "CUL_SetState";
$hash->{AttrFn} = "CUL_Attr";
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " .
"showtime:1,0 model:CUL,CUN,CUR loglevel:0,1,2,3,4,5,6 " .
"fhtsoftbuffer:1,0 sendpool addvaltrigger";
"fhtsoftbuffer:1,0 sendpool addvaltrigger " .
"rfmode:SlowRF,HomeMatic hm_autopair";
$hash->{ShutdownFn} = "CUL_Shutdown";
}
@ -282,7 +291,6 @@ WRITEEND:
return "Expecting a 0-padded hex number"
if((length($arg)&1) == 1 && $type ne "raw");
$initstr = "X$arg" if($type eq "verbose");
Log $ll, "set $name $type $arg";
CUL_SimpleWrite($hash, $sets{$type} . $arg);
@ -456,6 +464,7 @@ CUL_DoInit($)
Log 1, $msg;
return $msg;
}
$ver =~ s/[\r\n]//g;
$hash->{VERSION} = $ver;
if($ver =~ m/CUR/) {
@ -757,7 +766,7 @@ CUL_Parse($$$$$)
my $rssi;
my $dmsg = $rmsg;
if($initstr =~ m/X2/ && $dmsg =~ m/^[FTKEHR]([A-F0-9][A-F0-9])+$/) { # RSSI
if($dmsg =~ m/^[AFTKEHR]([A-F0-9][A-F0-9])+$/) { # RSSI
my $l = length($dmsg);
$rssi = hex(substr($dmsg, $l-2, 2));
$dmsg = substr($dmsg, 0, $l-2);
@ -829,6 +838,8 @@ CUL_Parse($$$$$)
;
} elsif($fn eq "R" && $len >= 11) { # CUL_EM / Native
;
} elsif($fn eq "A" && $len >= 21) { # AskSin/BidCos/HomeMatic
;
} else {
Log GetLogLevel($name,2), "$name: unknown message $dmsg";
return;
@ -1069,4 +1080,36 @@ CUL_Disconnected($)
DoTrigger($name, "DISCONNECTED");
}
sub
CUL_Attr(@)
{
my @a = @_;
if($a[2] eq "rfmode") {
my $name = $a[1];
my $hash = $defs{$name};
if($a[3] eq "HomeMatic") {
return if($initstr eq "Ar");
$hash->{mode} = "HomeMatic";
$initstr = "Ar";
CUL_SimpleWrite($hash, $initstr);
} else {
return if($initstr eq "X21");
delete($hash->{mode});
$initstr = "X21";
CUL_SimpleWrite($hash, "Ax");
CUL_SimpleWrite($hash, $initstr);
}
Log 2, "Switched $name rfmode to $a[3]";
}
return undef;
}
1;

View File

@ -172,7 +172,6 @@ autocreate_Notify($$)
}
}
CommandSave(undef, undef) if(!$ret && $nrcreated && $attr{$me}{autosave});
return $ret;
}

View File

@ -76,6 +76,7 @@
<a href="#CUL">CUL</a> &nbsp;
<a href="#CUL_EM">CUL_EM</a> &nbsp;
<a href="#CUL_FHTTK">CUL_FHTTK</a> &nbsp;
<a href="#CUL_HM">CUL_HM</a> &nbsp;
<a href="#CUL_HOERMANN">CUL_HOERMANN</a> &nbsp;
<a href="#CUL_RFR">CUL_RFR</a> &nbsp;
<a href="#CUL_WS">CUL_WS</a> &nbsp;
@ -790,7 +791,8 @@ A line ending with \ will be concatenated with the next one, so long lines
<pre> fhem> xmllist
&lt;FHZINFO&gt;
&lt;internal_LIST&gt;
&lt;internal name="global" state="internal" sets="" attrs="room configfile logfile modpath pidfilename port statefile userattr verbose version"&gt;
&lt;internal name="global" state="internal" sets=""
attrs="room configfile logfile ..."&gt;
&lt;INT key="DEF" value="&lt;no definition&gt;"/&gt;
&lt;INT key="NR" value="0"/&gt;
&lt;INT key="STATE" value="internal"/&gt;
@ -1102,7 +1104,6 @@ A line ending with \ will be concatenated with the next one, so long lines
<a name="fhtsoftbuffer"></a>
<li>fhtsoftbuffer<br/>
Can be applied to FHZ devices.<br/>
As the FHZ command buffer for FHT devices is limited (see fhtbuf),
and commands are only sent to the FHT device every 120 seconds,
the hardware buffer may overflow and FHT commands get lost.
@ -1899,11 +1900,6 @@ A line ending with \ will be concatenated with the next one, so long lines
<a name="CULset"></a>
<b>Set </b>
<ul>
<li>verbose<br>
Set a CUL "verbose" level. See the CUL firmware README document for
details. Note: only X00/X01/X21/X25 is supported by the fhem CUL
module, the other flags may crash fhem.
</li><br>
<li>raw<br>
Issue a CUL firmware command. See the CUL firmware README document for
details on CUL commands.
@ -1973,7 +1969,7 @@ A line ending with \ will be concatenated with the next one, so long lines
<li><a href="#showtime">showtime</a></li><br>
<li><a href="#loglevel">loglevel</a></li><br>
<li><a href="#model">model</a> (CUL,CUN,CUR)</li><br>
<li><a href="#sendpool">sendpool</a><br>
<li><a name="sendpool">sendpool</a><br>
If using more than one CUL/CUN for covering a large area, sending
different events by the different CUL's might disturb each other. This
phenomenon is also known as the Palm-Beach-Resort effect.
@ -1984,17 +1980,28 @@ A line ending with \ will be concatenated with the next one, so long lines
attr CUN2 sendpool CUN1,CUN2,CUN3<br>
attr CUN3 sendpool CUN1,CUN2,CUN3<br>
</li><br>
<li><a name="culfhtsoftbuffer">fhtsoftbuffer</a><br/>
As the CUL command buffer for FHT devices is limited (see fhtbuf),
and commands are only sent to the FHT device every 120 seconds,
the hardware buffer may overflow and FHT commands get lost or errors
may occur.
Setting this attribute implements an "unlimited" software buffer.<br>
Default is disabled (i.e. not set or set to 0).</li><br>
<li><a href="#addvaltrigger">addvaltrigger</a><br>
<li><a name="addvaltrigger">addvaltrigger</a><br>
Create triggers for additional device values. Right now these are RSSI
and RAWMSG for the CUL family and RAWMSG for the FHZ.
</li><br>
<li><a name="rfmode">rfmode</a><br>
Configure the RF Transceiver of the CUL (the CC1101). Available
arguments are:
<ul>
<li>SlowRF<br>
To communicate with FS20/FHT/HMS/EM1010/S300/Hoermann devices @1kHz
datarate. This is the default.
<li>HomeMatic<br>
To communicate with HomeMatic type of devices @20kHz datarate
</ul>
</li><br>
<li><a name="rfmode">hm_autopair</a><br>
Only useful in HomeMatic mode, see rfmode above. The CUL_HM Module will
try to pair any device requesting a pairing.
</li><br>
</ul>
<br>
</ul>
@ -2103,6 +2110,62 @@ A line ending with \ will be concatenated with the next one, so long lines
<br>
</ul>
<a name="CUL_HM"></a>
<h3>CUL_HM</h3>
<ul>
Support for eQ-3 HomeMatic devices via the CUL. Note: The <a
href="#rfmode">rfmode </a> attribute of at least one attache CUL/CUN device
must be set to HomeMatic. Note: The protocoll used by HomeMatic devices
(BidCos, known as AskSin in the culfw) must be enabled in the culfw firmware.
This is the default for all CUN and for newer CUL (i.e. V3.0 and greater)
devices. <b>Note: This module is experimental!</b>
<br><br>
<a name="CUL_HMdefine"></a>
<b>Define</b>
<ul>
<code>define &lt;name&gt; CUL_HM &lt;6-digit-hex-code&gt;</code>
<br><br>
Best to avoid this command with the <a href="#autocreate">autocreate</a>
module enabled, and the <a href="#hm_autopair">hm_autopair</a> attribute
set for the corresponding CUL device. Now set the physical device in
pairing mode (Anlernmodus), the rest should happen automatically.
</ul><br>
<a name="CUL_HMset"></a>
<b>Set</b>
<ul>
Depends on the subType of the device.
<li>switch
<ul>
<li>on - set the switch on</li>
<li>off - set the switch off</li>
</ul>
</li>
</ul><br>
<a name="CUL_HMget"></a>
<b>Get</b> <ul>N/A</ul><br>
<a name="CUL_HMattr"></a>
<b>Attributes</b>
<ul>
<li><a href="#do_not_notify">do_not_notify</a></li>
<li><a href="#ignore">ignore</a></li>
<li><a href="#showtime">showtime</a></li>
<li><a href="#loglevel">loglevel</a></li>
<li><a name="#model">name</a><br>
This attribute is set automatically after a successful pairing.
It is not supposed to be set by hand.</li>
<li><a name="#subType">subType</a><br>
This attribute is set automatically after a successful pairing.
It is not supposed to be set by hand. It is necessary to be set
in order to use the set command.</li>
</ul>
<br>
</ul>
<a name="CUL_HOERMANN"></a>
<h3>CUL_HOERMANN</h3>
<ul>

View File

@ -162,7 +162,7 @@ my $nextat; # Time when next timer will be triggered.
my $intAtCnt=0;
my %duplicate; # Pool of received msg for multi-fhz/cul setups
my $duplidx=0; # helper for the above pool
my $cvsid = '$Id: fhem.pl,v 1.115 2010-10-27 16:51:32 rudolfkoenig Exp $';
my $cvsid = '$Id: fhem.pl,v 1.116 2010-11-06 19:31:38 rudolfkoenig Exp $';
my $namedef =
"where <name> is either:\n" .
"- a single device name\n" .
@ -1169,8 +1169,9 @@ AssignIoPort($)
# Set the I/O device, search for the last compatible one.
for my $p (sort { $defs{$b}{NR} <=> $defs{$a}{NR} } keys %defs) {
my $cl = $modules{$defs{$p}{TYPE}}{Clients};
my $re = $modules{$defs{$p}{TYPE}}{regexpClients};
my $mode = ($defs{$p}{mode} ? $defs{$p}{mode} : "");
my $cl = $modules{$defs{$p}{TYPE}}{"${mode}Clients"};
my $re = $modules{$defs{$p}{TYPE}}{"${mode}regexpClients"};
if(((defined($cl) && $cl =~ m/:$hash->{TYPE}:/) ||
(defined($re) && $hash->{TYPE} =~ m/$re/)) &&
$defs{$p}{NAME} ne $hash->{NAME}) { # e.g. RFR
@ -2157,11 +2158,12 @@ Dispatch($$$)
}
my @found;
my $mode = ($hash->{mode} ? $hash->{mode} : "");
foreach my $m (sort { $modules{$a}{ORDER} cmp $modules{$b}{ORDER} }
grep {defined($modules{$_}{ORDER})} keys %modules) {
my $cl = $iohash->{Clients};
my $re = $iohash->{regexpClients};
my $cl = $iohash->{"${mode}Clients"};
my $re = $iohash->{"${mode}regexpClients"};
next if(!(defined($cl) && $cl =~ m/:$m:/) ||
(defined($re) && $m =~ m/$re/));
@ -2175,10 +2177,9 @@ Dispatch($$$)
}
if(!int(@found)) {
my $h = $iohash->{MatchList};
my $h = $iohash->{"${mode}MatchList"};
if(defined($h)) {
foreach my $m (sort keys %{$h}) {
if($dmsg =~ m/$h->{$m}/) {
my ($order, $mname) = split(":", $m);
@ -2318,6 +2319,14 @@ ReadingsVal($$$)
return $default;
}
sub
AttrVal($$$)
{
my ($d,$n,$default) = @_;
return $attr{$d}{$n} if(defined($attr{$d}) && defined($attr{$d}{$n}));
return $default;
}
sub
addToAttrList($)
{
@ -2333,4 +2342,3 @@ addToAttrList($)
$hash{$arg} = 1;
$attr{global}{userattr} = join(" ", sort keys %hash);
}