mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
reopen + msgInterval added
git-svn-id: https://svn.fhem.de/fhem/trunk@3245 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7bd4334d00
commit
87b81370ea
@ -48,16 +48,15 @@ FBAHA_Define($$)
|
||||
return "wrong syntax: define <name> FBAHA hostname:2002";
|
||||
}
|
||||
|
||||
DevIo_CloseDev($hash);
|
||||
|
||||
my $name = $a[0];
|
||||
my $dev = $a[2];
|
||||
|
||||
$hash->{Clients} = ":FBDECT:";
|
||||
my %matchList = ( "1:FBDECT" => ".*" );
|
||||
$hash->{MatchList} = \%matchList;
|
||||
|
||||
DevIo_CloseDev($hash);
|
||||
$hash->{DeviceName} = $dev;
|
||||
|
||||
my $ret = DevIo_OpenDev($hash, 0, "FBAHA_DoInit");
|
||||
return $ret;
|
||||
}
|
||||
@ -69,7 +68,7 @@ FBAHA_Set($@)
|
||||
{
|
||||
my ($hash, @a) = @_;
|
||||
my $name = shift @a;
|
||||
my %sets = ("createDevs"=>1, "reregister"=>1);
|
||||
my %sets = ("createDevs"=>1, "reregister"=>1, "reopen"=>1);
|
||||
|
||||
return "set $name needs at least one parameter" if(@a < 1);
|
||||
my $type = shift @a;
|
||||
@ -90,6 +89,7 @@ FBAHA_Set($@)
|
||||
}
|
||||
|
||||
if($type eq "reregister") {
|
||||
# Release seems to be deadly on the 546e
|
||||
FBAHA_Write($hash, "02", "") if($hash->{HANDLE}); # RELEASE
|
||||
FBAHA_Write($hash, "00", "00010001"); # REGISTER
|
||||
my ($err, $data) = FBAHA_ReadAnswer($hash, "REGISTER", "^01");
|
||||
@ -102,6 +102,7 @@ FBAHA_Set($@)
|
||||
if($data =~ m/^01030010(........)/) {
|
||||
$hash->{STATE} = "Initialized";
|
||||
$hash->{HANDLE} = $1;
|
||||
Log 1, "FBAHA $hash->{NAME} registered with handle: $hash->{HANDLE}";
|
||||
|
||||
} else {
|
||||
my $msg = "Got bogus answer for REGISTER request: $data";
|
||||
@ -113,6 +114,12 @@ FBAHA_Set($@)
|
||||
FBAHA_Write($hash, "03", "0000028200000000"); # LISTEN
|
||||
}
|
||||
|
||||
if($type eq "reopen") {
|
||||
DevIo_CloseDev($hash);
|
||||
delete $hash->{HANDLE};
|
||||
return DevIo_OpenDev($hash, 0, "FBAHA_DoInit");
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -202,8 +209,6 @@ FBAHA_DoInit($)
|
||||
{
|
||||
my $hash = shift;
|
||||
my $name = $hash->{NAME};
|
||||
Log 1, "FBAHA_DoInit called";
|
||||
|
||||
return FBAHA_Set($hash, ($name, "reregister"));
|
||||
}
|
||||
|
||||
@ -361,6 +366,12 @@ FBAHA_Ready($)
|
||||
create a FHEM device for each DECT device found on the AHA-Host, see also
|
||||
get devList.
|
||||
</li>
|
||||
<li>reopen<br>
|
||||
close and reopen the connection to the AHA server. Debugging only.
|
||||
</li>
|
||||
<li>reregister<br>
|
||||
release existing registration handle, and get a new one. Debugging only.
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
@ -436,6 +447,14 @@ FBAHA_Ready($)
|
||||
legt FHEM Geräte an für jedes auf dem AHA-Server gefundenen DECT
|
||||
Eintrag, siehe auch "get devList".
|
||||
</li>
|
||||
<li>reopen<br>
|
||||
Schließt und &oulm;ffnet die Verbindung zum AHA Server. Nur für
|
||||
debugging.
|
||||
</li>
|
||||
<li>reregister<br>
|
||||
Gibt den AHA handle frei, und registriert sich erneut beim AHA Server. Nur
|
||||
für debugging.
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
|
@ -70,7 +70,7 @@ FBDECT_Define($$)
|
||||
}
|
||||
|
||||
###################################
|
||||
my %sets = ("on"=>1, "off"=>1);
|
||||
my %sets = ("on"=>1, "off"=>1, "msgInterval"=>1);
|
||||
sub
|
||||
FBDECT_Set($@)
|
||||
{
|
||||
@ -79,12 +79,28 @@ FBDECT_Set($@)
|
||||
my $cmd = $a[1];
|
||||
|
||||
if(!$sets{$cmd}) {
|
||||
return SetExtensions($hash, join(" ", sort keys %sets), @a);
|
||||
my $usage = join(" ", sort keys %sets);
|
||||
return SetExtensions($hash, $usage, @a);
|
||||
}
|
||||
|
||||
my $relay;
|
||||
if($cmd eq "on" || $cmd eq "off") {
|
||||
my $relay = sprintf("%08x%04x0000%08x", 15, 4, $cmd eq "on" ? 1 : 0);
|
||||
my $msg = sprintf("%04x0000%08x$relay", $hash->{id}, length($relay)/2);
|
||||
IOWrite($hash, "07", $msg);
|
||||
readingsSingleUpdate($hash, "state", "set_$cmd", 1);
|
||||
}
|
||||
if($cmd eq "msgInterval") {
|
||||
return "msgInterval needs seconds as parameter"
|
||||
if(!defined($a[2]) || $a[2] !~ m/^\d+$/);
|
||||
# Set timer for RELAY, CURRENT, VOLTAGE, POWER, ENERGY,
|
||||
# POWER_FACTOR, TEMP, RELAY_TIMES,
|
||||
foreach my $i (24, 26, 27, 28, 29, 30, 31, 32) {
|
||||
my $txt = sprintf("%08x%04x0000%08x", $i, 4, $a[2]);
|
||||
my $msg = sprintf("%04x0000%08x$txt", $hash->{id}, length($txt)/2);
|
||||
IOWrite($hash, "07", $msg);
|
||||
}
|
||||
}
|
||||
my $relay = sprintf("%08x%04x0000%08x", 15, 4, $cmd eq "on" ? 1 : 0);
|
||||
my $msg = sprintf("%04x0000%08x$relay", $hash->{id}, length($relay)/2);
|
||||
IOWrite($hash, "07", $msg);
|
||||
readingsSingleUpdate($hash, "state", "set_$cmd", 1);
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -238,6 +254,8 @@ FBDECT_Undef($$)
|
||||
set the device on or off.</li>
|
||||
<li>
|
||||
<a href="#setExtensions">set extensions</a> are supported.</li>
|
||||
<li>msgInterval <sec><br>
|
||||
Number of seconds between the sensor messages.
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
@ -312,9 +330,12 @@ FBDECT_Undef($$)
|
||||
<b>Set</b>
|
||||
<ul>
|
||||
<li>on/off<br>
|
||||
Gerät einschalten bzw. ausschalten.</li>
|
||||
Gerät einschalten bzw. ausschalten.</li>
|
||||
<li>
|
||||
Die <a href="#setExtensions">set extensions</a> werden unterstützt.</li>
|
||||
Die <a href="#setExtensions">set extensions</a> werden
|
||||
unterstützt.</li>
|
||||
<li>msgInterval <sec><br>
|
||||
Anzahl der Sekunden zwischen den Sensornachrichten.
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user