mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
45_TRX.pm: added readings for Settings (firmware, frequency, protocols)
git-svn-id: https://svn.fhem.de/fhem/trunk@16653 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c45bac06ab
commit
26bb6eca63
@ -13,7 +13,7 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
@ -28,7 +28,8 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
#
|
#
|
||||||
|
# 23.04.2018 added readings for Settings (firmware, frequency, protocols)
|
||||||
# 02.04.2018 support for vair CO2 sensors (forum #67734) -Thanks to vbs
|
# 02.04.2018 support for vair CO2 sensors (forum #67734) -Thanks to vbs
|
||||||
# 29.03.2018 Summary for Commandref
|
# 29.03.2018 Summary for Commandref
|
||||||
#
|
#
|
||||||
@ -43,520 +44,463 @@ use Time::HiRes qw(gettimeofday usleep);
|
|||||||
|
|
||||||
my $last_rmsg = "abcd";
|
my $last_rmsg = "abcd";
|
||||||
my $last_time = 1;
|
my $last_time = 1;
|
||||||
my $trx_rssi = 0;
|
my $trx_rssi = 0;
|
||||||
|
|
||||||
sub TRX_Clear($);
|
sub TRX_Clear($);
|
||||||
sub TRX_Read($@);
|
sub TRX_Read($@);
|
||||||
sub TRX_Ready($);
|
sub TRX_Ready($);
|
||||||
sub TRX_Parse($$$$);
|
sub TRX_Parse($$$$);
|
||||||
|
|
||||||
my %sets = (
|
my %sets = ( "reopen" => "" );
|
||||||
"reopen" => ""
|
|
||||||
);
|
|
||||||
|
|
||||||
sub
|
sub TRX_Initialize($) {
|
||||||
TRX_Initialize($)
|
my ($hash) = @_;
|
||||||
{
|
|
||||||
my ($hash) = @_;
|
|
||||||
|
|
||||||
|
require "$attr{global}{modpath}/FHEM/DevIo.pm";
|
||||||
|
|
||||||
require "$attr{global}{modpath}/FHEM/DevIo.pm";
|
# Provider
|
||||||
|
$hash->{ReadFn} = "TRX_Read";
|
||||||
|
$hash->{WriteFn} = "TRX_Write";
|
||||||
|
$hash->{Clients} = ":TRX_WEATHER:TRX_SECURITY:TRX_LIGHT:TRX_ELSE:";
|
||||||
|
my %mc = (
|
||||||
|
"1:TRX_WEATHER" => "^..(40|4e|50|51|52|54|55|56|57|58|5a|5b|5c|5d|71).*",
|
||||||
|
"2:TRX_SECURITY" => "^..(20).*",
|
||||||
|
"3:TRX_LIGHT" => "^..(10|11|12|13|14|15|16|17|18|19).*",
|
||||||
|
"4:TRX_ELSE" =>
|
||||||
|
"^..(0[0-9a-f]|1[a-f]|2[1-9a-f]|3[0-9a-f]|4[1-9a-d]|4f|53|59|5e|5f|6[0-9a-f]|70|7[2-9a-f]|[8-9a-f][0-9a-f]).*",
|
||||||
|
);
|
||||||
|
$hash->{MatchList} = \%mc;
|
||||||
|
|
||||||
# Provider
|
$hash->{ReadyFn} = "TRX_Ready";
|
||||||
$hash->{ReadFn} = "TRX_Read";
|
$hash->{ReadAnswerFn} = "TRX_ReadAnswer";
|
||||||
$hash->{WriteFn} = "TRX_Write";
|
|
||||||
$hash->{Clients} =
|
|
||||||
":TRX_WEATHER:TRX_SECURITY:TRX_LIGHT:TRX_ELSE:";
|
|
||||||
my %mc = (
|
|
||||||
"1:TRX_WEATHER" => "^..(40|4e|50|51|52|54|55|56|57|58|5a|5b|5c|5d|71).*",
|
|
||||||
"2:TRX_SECURITY" => "^..(20).*",
|
|
||||||
"3:TRX_LIGHT" => "^..(10|11|12|13|14|15|16|17|18|19).*",
|
|
||||||
"4:TRX_ELSE" => "^..(0[0-9a-f]|1[a-f]|2[1-9a-f]|3[0-9a-f]|4[1-9a-d]|4f|53|59|5e|5f|6[0-9a-f]|70|7[2-9a-f]|[8-9a-f][0-9a-f]).*",
|
|
||||||
);
|
|
||||||
$hash->{MatchList} = \%mc;
|
|
||||||
|
|
||||||
$hash->{ReadyFn} = "TRX_Ready";
|
# Normal devices
|
||||||
$hash->{ReadAnswerFn} = "TRX_ReadAnswer";
|
$hash->{DefFn} = "TRX_Define";
|
||||||
|
$hash->{UndefFn} = "TRX_Undef";
|
||||||
# Normal devices
|
$hash->{GetFn} = "TRX_Get";
|
||||||
$hash->{DefFn} = "TRX_Define";
|
$hash->{SetFn} = "TRX_Set";
|
||||||
$hash->{UndefFn} = "TRX_Undef";
|
$hash->{StateFn} = "TRX_SetState";
|
||||||
$hash->{GetFn} = "TRX_Get";
|
$hash->{AttrList} = "do_not_notify:1,0 dummy:1,0 do_not_init:1,0 addvaltrigger:1,0 longids rssi:1,0";
|
||||||
$hash->{SetFn} = "TRX_Set";
|
$hash->{ShutdownFn} = "TRX_Shutdown";
|
||||||
$hash->{StateFn} = "TRX_SetState";
|
|
||||||
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 do_not_init:1,0 addvaltrigger:1,0 longids rssi:1,0";
|
|
||||||
$hash->{ShutdownFn} = "TRX_Shutdown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub TRX_Define($$) {
|
||||||
TRX_Define($$)
|
my ( $hash, $def ) = @_;
|
||||||
{
|
my @a = split( "[ \t][ \t]*", $def );
|
||||||
my ($hash, $def) = @_;
|
|
||||||
my @a = split("[ \t][ \t]*", $def);
|
|
||||||
|
|
||||||
|
if ( @a != 3 && @a != 4 ) {
|
||||||
if (@a != 3 && @a != 4) {
|
my $msg = "wrong syntax: define <name> TRX devicename [noinit]";
|
||||||
my $msg = "wrong syntax: define <name> TRX devicename [noinit]";
|
Log3 undef, 2, $msg;
|
||||||
Log3 undef, 2, $msg;
|
return $msg;
|
||||||
return $msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
DevIo_CloseDev($hash);
|
|
||||||
|
|
||||||
my $name = $a[0];
|
|
||||||
my $dev = $a[2];
|
|
||||||
my $opt = $a[3] if(@a == 4);;
|
|
||||||
|
|
||||||
if($dev eq "none") {
|
|
||||||
Log3 $name, 1, "TRX: $name device is none, commands will be echoed only";
|
|
||||||
$attr{$name}{dummy} = 1;
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(defined($opt)) {
|
|
||||||
if($opt eq "noinit") {
|
|
||||||
Log3 $name, 1 , "TRX: $name no init is done";
|
|
||||||
$attr{$name}{do_not_init} = 1;
|
|
||||||
} else {
|
|
||||||
return "wrong syntax: define <name> TRX devicename [noinit]"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
DevIo_CloseDev($hash);
|
||||||
$hash->{DeviceName} = $dev;
|
|
||||||
my $ret = DevIo_OpenDev($hash, 0, "TRX_DoInit");
|
my $name = $a[0];
|
||||||
return $ret;
|
my $dev = $a[2];
|
||||||
|
my $opt = $a[3] if ( @a == 4 );
|
||||||
|
|
||||||
|
if ( $dev eq "none" ) {
|
||||||
|
Log3 $name, 1, "TRX: $name device is none, commands will be echoed only";
|
||||||
|
$attr{$name}{dummy} = 1;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( defined($opt) ) {
|
||||||
|
if ( $opt eq "noinit" ) {
|
||||||
|
Log3 $name, 1, "TRX: $name no init is done";
|
||||||
|
$attr{$name}{do_not_init} = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "wrong syntax: define <name> TRX devicename [noinit]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$hash->{DeviceName} = $dev;
|
||||||
|
my $ret = DevIo_OpenDev( $hash, 0, "TRX_DoInit" );
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# Input is hexstring
|
# Input is hexstring
|
||||||
sub
|
sub TRX_Write($$) {
|
||||||
TRX_Write($$)
|
my ( $hash, $fn, $msg ) = @_;
|
||||||
{
|
my $name = $hash->{NAME};
|
||||||
my ($hash,$fn,$msg) = @_;
|
|
||||||
my $name = $hash->{NAME};
|
|
||||||
|
|
||||||
return if(!defined($fn));
|
return if ( !defined($fn) );
|
||||||
|
|
||||||
my $bstring;
|
my $bstring;
|
||||||
$bstring = "$fn$msg";
|
$bstring = "$fn$msg";
|
||||||
Log3 $name, 5, "$hash->{NAME} sending $bstring";
|
Log3 $name, 5, "$hash->{NAME} sending $bstring";
|
||||||
|
|
||||||
DevIo_SimpleWrite($hash, $bstring, 1);
|
DevIo_SimpleWrite( $hash, $bstring, 1 );
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
sub
|
|
||||||
TRX_Undef($$)
|
|
||||||
{
|
|
||||||
my ($hash, $arg) = @_;
|
|
||||||
my $name = $hash->{NAME};
|
|
||||||
|
|
||||||
foreach my $d (sort keys %defs) {
|
|
||||||
if(defined($defs{$d}) &&
|
|
||||||
defined($defs{$d}{IODev}) &&
|
|
||||||
$defs{$d}{IODev} == $hash)
|
|
||||||
{
|
|
||||||
my $lev = ($reread_active ? 4 : 2);
|
|
||||||
Log3 $name, $lev, "deleting port for $d";
|
|
||||||
delete $defs{$d}{IODev};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DevIo_CloseDev($hash);
|
|
||||||
return undef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub TRX_Undef($$) {
|
||||||
TRX_Shutdown($)
|
my ( $hash, $arg ) = @_;
|
||||||
{
|
my $name = $hash->{NAME};
|
||||||
my ($hash) = @_;
|
|
||||||
return undef;
|
foreach my $d ( sort keys %defs ) {
|
||||||
|
if ( defined( $defs{$d} )
|
||||||
|
&& defined( $defs{$d}{IODev} )
|
||||||
|
&& $defs{$d}{IODev} == $hash )
|
||||||
|
{
|
||||||
|
my $lev = ( $reread_active ? 4 : 2 );
|
||||||
|
Log3 $name, $lev, "deleting port for $d";
|
||||||
|
delete $defs{$d}{IODev};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DevIo_CloseDev($hash);
|
||||||
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub TRX_Shutdown($) {
|
||||||
TRX_Reopen($)
|
my ($hash) = @_;
|
||||||
{
|
return undef;
|
||||||
my ($hash) = @_;
|
|
||||||
DevIo_CloseDev($hash);
|
|
||||||
sleep(1);
|
|
||||||
DevIo_OpenDev($hash, 0, "TRX_DoInit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub TRX_Reopen($) {
|
||||||
TRX_Get($@)
|
my ($hash) = @_;
|
||||||
{
|
DevIo_CloseDev($hash);
|
||||||
my ($hash, @a) = @_;
|
|
||||||
|
|
||||||
my $msg;
|
|
||||||
my $name=$a[0];
|
|
||||||
my $reading= $a[1];
|
|
||||||
|
|
||||||
$msg="$name => No Get function ($reading) implemented";
|
|
||||||
Log3 $name, 1, $msg if ($reading ne "?");
|
|
||||||
return $msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
sub
|
|
||||||
TRX_Set($@)
|
|
||||||
{
|
|
||||||
my ($hash, @a) = @_;
|
|
||||||
|
|
||||||
return "\"set TRX\" needs at least one parameter" if(@a < 1);
|
|
||||||
return "Unknown argument $a[1], choose one of " . join(" ", sort keys %sets)
|
|
||||||
if(!defined($sets{$a[1]}));
|
|
||||||
|
|
||||||
my $name = shift @a;
|
|
||||||
my $type = shift @a;
|
|
||||||
|
|
||||||
if($type eq "reopen") { ####################################
|
|
||||||
TRX_Reopen($hash);
|
|
||||||
}
|
|
||||||
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
sub
|
|
||||||
TRX_SetState($$$$)
|
|
||||||
{
|
|
||||||
my ($hash, $tim, $vt, $val) = @_;
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub
|
|
||||||
TRX_Clear($)
|
|
||||||
{
|
|
||||||
my $hash = shift;
|
|
||||||
|
|
||||||
# Clear the pipe
|
|
||||||
$hash->{RA_Timeout} = 0.1;
|
|
||||||
|
|
||||||
for(;;) {
|
|
||||||
my ($err, undef) = TRX_ReadAnswer($hash, "Clear");
|
|
||||||
last if($err);
|
|
||||||
}
|
|
||||||
delete($hash->{RA_Timeout});
|
|
||||||
$hash->{PARTIAL} = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
sub
|
|
||||||
TRX_DoInit($)
|
|
||||||
{
|
|
||||||
my $hash = shift;
|
|
||||||
my $name = $hash->{NAME};
|
|
||||||
my $err;
|
|
||||||
my $msg = undef;
|
|
||||||
my $buf;
|
|
||||||
my $char = undef ;
|
|
||||||
|
|
||||||
|
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"do_not_init"})) {
|
|
||||||
Log3 $name, 1, "TRX: defined with noinit. Do not send init string to device.";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
# Reset
|
|
||||||
my $init = pack('H*', "0D00000000000000000000000000");
|
|
||||||
DevIo_SimpleWrite($hash, $init, 0);
|
|
||||||
DevIo_TimeoutRead($hash, 0.5);
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
DevIo_OpenDev( $hash, 0, "TRX_DoInit" );
|
||||||
|
}
|
||||||
|
|
||||||
TRX_Clear($hash);
|
#####################################
|
||||||
|
sub TRX_Get($@) {
|
||||||
|
my ( $hash, @a ) = @_;
|
||||||
|
|
||||||
sleep(1);
|
my $msg;
|
||||||
|
my $name = $a[0];
|
||||||
|
my $reading = $a[1];
|
||||||
|
|
||||||
#
|
$msg = "$name => No Get function ($reading) implemented";
|
||||||
# Get Status
|
Log3 $name, 1, $msg if ( $reading ne "?" );
|
||||||
$init = pack('H*', "0D00000102000000000000000000");
|
return $msg;
|
||||||
DevIo_SimpleWrite($hash, $init, 0);
|
}
|
||||||
usleep(50000); # wait 50 ms
|
|
||||||
$buf = unpack('H*',DevIo_TimeoutRead($hash, 0.2));
|
|
||||||
|
|
||||||
if (! $buf) {
|
#####################################
|
||||||
Log3 $name, 1, "TRX: Initialization Error: No character read";
|
sub TRX_Set($@) {
|
||||||
return "TRX: Initialization Error $name: no char read";
|
my ( $hash, @a ) = @_;
|
||||||
} elsif ($buf !~ m/0d0100....................../ && $buf !~ m/140100..................................../) {
|
|
||||||
Log3 $name, 1, "TRX: Initialization Error hexline='$buf', expected 0d0100......................";
|
|
||||||
return "TRX: Initialization Error %name expected 0D010, but buf=$buf received.";
|
|
||||||
} else {
|
|
||||||
Log3 $name,1, "TRX: Init OK";
|
|
||||||
|
|
||||||
# Analyse result and display it:
|
return "\"set TRX\" needs at least one parameter" if ( @a < 1 );
|
||||||
if ($buf =~ m/0d0100(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)/) {
|
return "Unknown argument $a[1], choose one of " . join( " ", sort keys %sets )
|
||||||
my $status = "";
|
if ( !defined( $sets{ $a[1] } ) );
|
||||||
|
|
||||||
my $seqnbr = $1;
|
my $name = shift @a;
|
||||||
my $cmnd = $2;
|
my $type = shift @a;
|
||||||
my $msg1 = $3;
|
|
||||||
my $msg2 = ord(pack('H*', $4));
|
|
||||||
my $msg3 = ord(pack('H*', $5));
|
|
||||||
my $msg4 = ord(pack('H*', $6));
|
|
||||||
my $msg5 = ord(pack('H*', $7));
|
|
||||||
my $freq = {
|
|
||||||
'50' => '310MHz',
|
|
||||||
'51' => '315MHz',
|
|
||||||
'52' => '433.92MHz receiver only',
|
|
||||||
'53' => '433.92MHz transceiver',
|
|
||||||
'55' => '868.00MHz',
|
|
||||||
'56' => '868.00MHz FSK',
|
|
||||||
'57' => '868.30MHz',
|
|
||||||
'58' => '868.30MHz FSK',
|
|
||||||
'59' => '868.35MHz',
|
|
||||||
'5a' => '868.35MHz FSK',
|
|
||||||
'5b' => '868.95MHz'
|
|
||||||
}->{$msg1} || 'unknown Mhz';
|
|
||||||
$status .= $freq;
|
|
||||||
$status .= ", " . sprintf "firmware=%d",$msg2;
|
|
||||||
$status .= ", protocols enabled: ";
|
|
||||||
$status .= "undecoded " if ($msg3 & 0x80);
|
|
||||||
$status .= "RFU " if ($msg3 & 0x40);
|
|
||||||
$status .= "ByronSX " if ($msg3 & 0x20);
|
|
||||||
$status .= "RSL " if ($msg3 & 0x10);
|
|
||||||
$status .= "Lighting4 " if ($msg3 & 0x08);
|
|
||||||
$status .= "FineOffset/Viking " if ($msg3 & 0x04);
|
|
||||||
$status .= "Rubicson " if ($msg3 & 0x02);
|
|
||||||
$status .= "AE/Blyss " if ($msg3 & 0x01);
|
|
||||||
$status .= "BlindsT1/T2/T3/T4 " if ($msg4 & 0x80);
|
|
||||||
$status .= "BlindsT0 " if ($msg4 & 0x40);
|
|
||||||
$status .= "ProGuard " if ($msg4 & 0x20);
|
|
||||||
$status .= "FS20 " if ($msg4 & 0x10);
|
|
||||||
$status .= "LaCrosse " if ($msg4 & 0x08);
|
|
||||||
$status .= "Hideki " if ($msg4 & 0x04);
|
|
||||||
$status .= "LightwaveRF " if ($msg4 & 0x02);
|
|
||||||
$status .= "Mertik " if ($msg4 & 0x01);
|
|
||||||
$status .= "Visonic " if ($msg5 & 0x80);
|
|
||||||
$status .= "ATI " if ($msg5 & 0x40);
|
|
||||||
$status .= "OREGON " if ($msg5 & 0x20);
|
|
||||||
$status .= "KOPPLA " if ($msg5 & 0x10);
|
|
||||||
$status .= "HOMEEASY " if ($msg5 & 0x08);
|
|
||||||
$status .= "AC " if ($msg5 & 0x04);
|
|
||||||
$status .= "ARC " if ($msg5 & 0x02);
|
|
||||||
$status .= "X10 " if ($msg5 & 0x01);
|
|
||||||
my $hexline = unpack('H*', $buf);
|
|
||||||
Log3 $name, 4, "TRX: Init status hexline='$hexline'";
|
|
||||||
Log3 $name, 1, "TRX: Init status: '$status'";
|
|
||||||
}
|
|
||||||
# Since 1001
|
|
||||||
if ($buf =~ m/140100(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)/) {
|
|
||||||
my $status = "";
|
|
||||||
|
|
||||||
my $seqnbr = $1;
|
if ( $type eq "reopen" ) { ####################################
|
||||||
my $cmnd = $2;
|
TRX_Reopen($hash);
|
||||||
my $msg1 = $3;
|
}
|
||||||
my $msg2 = ord(pack('H*', $4));
|
|
||||||
my $msg3 = ord(pack('H*', $5));
|
|
||||||
my $msg4 = ord(pack('H*', $6));
|
|
||||||
my $msg5 = ord(pack('H*', $7));
|
|
||||||
my $msg6 = ord(pack('H*', $8));
|
|
||||||
my $freq = {
|
|
||||||
'50' => '310MHz',
|
|
||||||
'51' => '315MHz',
|
|
||||||
'52' => '433.92MHz receiver only',
|
|
||||||
'53' => '433.92MHz transceiver',
|
|
||||||
'55' => '868.00MHz',
|
|
||||||
'56' => '868.00MHz FSK',
|
|
||||||
'57' => '868.30MHz',
|
|
||||||
'58' => '868.30MHz FSK',
|
|
||||||
'59' => '868.35MHz',
|
|
||||||
'5a' => '868.35MHz FSK',
|
|
||||||
'5b' => '868.95MHz'
|
|
||||||
}->{$msg1} || 'unknown Mhz';
|
|
||||||
$status .= $freq;
|
|
||||||
$status .= ", " . sprintf "firmware=%d",$msg2+1000;
|
|
||||||
$status .= ", protocols enabled: ";
|
|
||||||
$status .= "undecoded " if ($msg3 & 0x80);
|
|
||||||
$status .= "RFU " if ($msg3 & 0x40);
|
|
||||||
$status .= "ByronSX " if ($msg3 & 0x20);
|
|
||||||
$status .= "RSL " if ($msg3 & 0x10);
|
|
||||||
$status .= "Lighting4 " if ($msg3 & 0x08);
|
|
||||||
$status .= "FineOffset/Viking " if ($msg3 & 0x04);
|
|
||||||
$status .= "Rubicson " if ($msg3 & 0x02);
|
|
||||||
$status .= "AE/Blyss " if ($msg3 & 0x01);
|
|
||||||
$status .= "BlindsT1/T2/T3/T4 " if ($msg4 & 0x80);
|
|
||||||
$status .= "BlindsT0 " if ($msg4 & 0x40);
|
|
||||||
$status .= "ProGuard " if ($msg4 & 0x20);
|
|
||||||
$status .= "FS20 " if ($msg4 & 0x10);
|
|
||||||
$status .= "LaCrosse " if ($msg4 & 0x08);
|
|
||||||
$status .= "Hideki " if ($msg4 & 0x04);
|
|
||||||
$status .= "LightwaveRF " if ($msg4 & 0x02);
|
|
||||||
$status .= "Mertik " if ($msg4 & 0x01);
|
|
||||||
$status .= "Visonic " if ($msg5 & 0x80);
|
|
||||||
$status .= "ATI " if ($msg5 & 0x40);
|
|
||||||
$status .= "OREGON " if ($msg5 & 0x20);
|
|
||||||
$status .= "KOPPLA " if ($msg5 & 0x10);
|
|
||||||
$status .= "HOMEEASY " if ($msg5 & 0x08);
|
|
||||||
$status .= "AC " if ($msg5 & 0x04);
|
|
||||||
$status .= "ARC " if ($msg5 & 0x02);
|
|
||||||
$status .= "X10 " if ($msg5 & 0x01);
|
|
||||||
$status .= "HomeComfort " if ($msg6 & 0x02);
|
|
||||||
$status .= "KEELOQ " if ($msg6 & 0x01);
|
|
||||||
my $hexline = unpack('H*', $buf);
|
|
||||||
Log3 $name, 4, "TRX: Init status hexline='$hexline'";
|
|
||||||
Log3 $name, 1, "TRX: Init status: '$status'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Reset the counter
|
return undef;
|
||||||
delete($hash->{XMIT_TIME});
|
}
|
||||||
delete($hash->{NR_CMD_LAST_H});
|
|
||||||
|
|
||||||
readingsSingleUpdate($hash, "state", "Initialized", 1);
|
#####################################
|
||||||
|
sub TRX_SetState($$$$) {
|
||||||
|
my ( $hash, $tim, $vt, $val ) = @_;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
return undef;
|
sub TRX_Clear($) {
|
||||||
|
my $hash = shift;
|
||||||
|
|
||||||
|
# Clear the pipe
|
||||||
|
$hash->{RA_Timeout} = 0.1;
|
||||||
|
|
||||||
|
for ( ; ; ) {
|
||||||
|
my ( $err, undef ) = TRX_ReadAnswer( $hash, "Clear" );
|
||||||
|
last if ($err);
|
||||||
|
}
|
||||||
|
delete( $hash->{RA_Timeout} );
|
||||||
|
$hash->{PARTIAL} = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
sub TRX_DoInit($) {
|
||||||
|
my $hash = shift;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my $err;
|
||||||
|
my $msg = undef;
|
||||||
|
my $buf;
|
||||||
|
my $char = undef;
|
||||||
|
|
||||||
|
if ( defined( $attr{$name} ) && defined( $attr{$name}{"do_not_init"} ) ) {
|
||||||
|
Log3 $name, 1, "TRX: defined with noinit. Do not send init string to device.";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Reset
|
||||||
|
my $init = pack( 'H*', "0D00000000000000000000000000" );
|
||||||
|
DevIo_SimpleWrite( $hash, $init, 0 );
|
||||||
|
DevIo_TimeoutRead( $hash, 0.5 );
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
TRX_Clear($hash);
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
#
|
||||||
|
# Get Status
|
||||||
|
$init = pack( 'H*', "0D00000102000000000000000000" );
|
||||||
|
DevIo_SimpleWrite( $hash, $init, 0 );
|
||||||
|
usleep(50000); # wait 50 ms
|
||||||
|
$buf = unpack( 'H*', DevIo_TimeoutRead( $hash, 0.2 ) );
|
||||||
|
|
||||||
|
if ( !$buf ) {
|
||||||
|
Log3 $name, 1, "TRX: Initialization Error: No character read";
|
||||||
|
return "TRX: Initialization Error $name: no char read";
|
||||||
|
}
|
||||||
|
elsif ( $buf !~ m/0d0100....................../ && $buf !~ m/140100..................................../ ) {
|
||||||
|
Log3 $name, 1, "TRX: Initialization Error hexline='$buf', expected 0d0100......................";
|
||||||
|
return "TRX: Initialization Error %name expected 0D010, but buf=$buf received.";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log3 $name, 1, "TRX: Init OK";
|
||||||
|
|
||||||
|
my $fw = undef;
|
||||||
|
if ( $buf =~ m/0d0100(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)/ ) {
|
||||||
|
$fw = 1;
|
||||||
|
}
|
||||||
|
elsif ( $buf =~ m/140100(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)/ ) {
|
||||||
|
$fw = 2;
|
||||||
|
}
|
||||||
|
if ($fw) {
|
||||||
|
|
||||||
|
# Analyse result and display it:
|
||||||
|
my $status = "";
|
||||||
|
|
||||||
|
my $seqnbr = $1;
|
||||||
|
my $cmnd = $2;
|
||||||
|
my $msg1 = $3;
|
||||||
|
my $msg2 = ord( pack( 'H*', $4 ) );
|
||||||
|
my $msg3 = ord( pack( 'H*', $5 ) );
|
||||||
|
my $msg4 = ord( pack( 'H*', $6 ) );
|
||||||
|
my $msg5 = ord( pack( 'H*', $7 ) );
|
||||||
|
my $msg6 = ord( pack( 'H*', $8 ) ) if $fw == 2;
|
||||||
|
my $freq = {
|
||||||
|
'50' => '310MHz',
|
||||||
|
'51' => '315MHz',
|
||||||
|
'52' => '433.92MHz receiver only',
|
||||||
|
'53' => '433.92MHz transceiver',
|
||||||
|
'55' => '868.00MHz',
|
||||||
|
'56' => '868.00MHz FSK',
|
||||||
|
'57' => '868.30MHz',
|
||||||
|
'58' => '868.30MHz FSK',
|
||||||
|
'59' => '868.35MHz',
|
||||||
|
'5a' => '868.35MHz FSK',
|
||||||
|
'5b' => '868.95MHz'
|
||||||
|
}->{$msg1}
|
||||||
|
|| 'unknown Mhz';
|
||||||
|
$status .= $freq;
|
||||||
|
my $firmware = "";
|
||||||
|
if ($fw==2) {
|
||||||
|
$firmware = $msg2 + 1000;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$firmware = $msg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
$status .= ", " . sprintf "firmware=%d", $firmware;
|
||||||
|
my $protocols = "";
|
||||||
|
$status .= ", protocols enabled: ";
|
||||||
|
$protocols .= "undecoded " if ( $msg3 & 0x80 );
|
||||||
|
$protocols .= "RFU " if ( $msg3 & 0x40 );
|
||||||
|
$protocols .= "ByronSX " if ( $msg3 & 0x20 );
|
||||||
|
$protocols .= "RSL " if ( $msg3 & 0x10 );
|
||||||
|
$protocols .= "Lighting4 " if ( $msg3 & 0x08 );
|
||||||
|
$protocols .= "FineOffset/Viking " if ( $msg3 & 0x04 );
|
||||||
|
$protocols .= "Rubicson " if ( $msg3 & 0x02 );
|
||||||
|
$protocols .= "AE/Blyss " if ( $msg3 & 0x01 );
|
||||||
|
$protocols .= "BlindsT1/T2/T3/T4 " if ( $msg4 & 0x80 );
|
||||||
|
$protocols .= "BlindsT0 " if ( $msg4 & 0x40 );
|
||||||
|
$protocols .= "ProGuard " if ( $msg4 & 0x20 );
|
||||||
|
$protocols .= "FS20 " if ( $msg4 & 0x10 );
|
||||||
|
$protocols .= "LaCrosse " if ( $msg4 & 0x08 );
|
||||||
|
$protocols .= "Hideki " if ( $msg4 & 0x04 );
|
||||||
|
$protocols .= "LightwaveRF " if ( $msg4 & 0x02 );
|
||||||
|
$protocols .= "Mertik " if ( $msg4 & 0x01 );
|
||||||
|
$protocols .= "Visonic " if ( $msg5 & 0x80 );
|
||||||
|
$protocols .= "ATI " if ( $msg5 & 0x40 );
|
||||||
|
$protocols .= "OREGON " if ( $msg5 & 0x20 );
|
||||||
|
$protocols .= "KOPPLA " if ( $msg5 & 0x10 );
|
||||||
|
$protocols .= "HOMEEASY " if ( $msg5 & 0x08 );
|
||||||
|
$protocols .= "AC " if ( $msg5 & 0x04 );
|
||||||
|
$protocols .= "ARC " if ( $msg5 & 0x02 );
|
||||||
|
$protocols .= "X10 " if ( $msg5 & 0x01 );
|
||||||
|
$protocols .= "HomeComfort " if ( $msg6 & 0x02 and $fw == 2 );
|
||||||
|
$protocols .= "KEELOQ " if ( $msg6 & 0x01 and $fw == 2 );
|
||||||
|
$status .= $protocols;
|
||||||
|
my $hexline = unpack( 'H*', $buf );
|
||||||
|
Log3 $name, 4, "TRX: Init status hexline='$hexline'";
|
||||||
|
Log3 $name, 1, "TRX: Init status: '$status'";
|
||||||
|
readingsBeginUpdate($hash);
|
||||||
|
readingsBulkUpdate( $hash, "frequency", $freq );
|
||||||
|
readingsBulkUpdate( $hash, "firmware", $firmware );
|
||||||
|
readingsBulkUpdate( $hash, "protocols", $protocols );
|
||||||
|
readingsEndUpdate( $hash, 1 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reset the counter
|
||||||
|
delete( $hash->{XMIT_TIME} );
|
||||||
|
delete( $hash->{NR_CMD_LAST_H} );
|
||||||
|
|
||||||
|
readingsSingleUpdate( $hash, "state", "Initialized", 1 );
|
||||||
|
|
||||||
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# This is a direct read for commands like get
|
# This is a direct read for commands like get
|
||||||
sub
|
sub TRX_ReadAnswer($$) {
|
||||||
TRX_ReadAnswer($$)
|
my ( $hash, $arg ) = @_;
|
||||||
{
|
return ( "No FD (dummy device?)", undef )
|
||||||
my ($hash, $arg) = @_;
|
if ( !$hash || ( $^O !~ /Win/ && !defined( $hash->{FD} ) ) );
|
||||||
return ("No FD (dummy device?)", undef)
|
|
||||||
if(!$hash || ($^O !~ /Win/ && !defined($hash->{FD})));
|
|
||||||
# my $to = ($hash->{RA_Timeout} ? $hash->{RA_Timeout} : 3);
|
|
||||||
my $to = ($hash->{RA_Timeout} ? $hash->{RA_Timeout} : 9);
|
|
||||||
Log3 $hash, 4, "TRX_ReadAnswer arg:$arg";
|
|
||||||
|
|
||||||
for(;;) {
|
# my $to = ($hash->{RA_Timeout} ? $hash->{RA_Timeout} : 3);
|
||||||
|
my $to = ( $hash->{RA_Timeout} ? $hash->{RA_Timeout} : 9 );
|
||||||
|
Log3 $hash, 4, "TRX_ReadAnswer arg:$arg";
|
||||||
|
|
||||||
my $buf;
|
for ( ; ; ) {
|
||||||
if($^O =~ m/Win/ && $hash->{USBDev}) {
|
|
||||||
$hash->{USBDev}->read_const_time($to*1000); # set timeout (ms)
|
|
||||||
# Read anstatt input sonst funzt read_const_time nicht.
|
|
||||||
$buf = $hash->{USBDev}->read(999);
|
|
||||||
return ("Timeout reading answer for get $arg", undef)
|
|
||||||
if(length($buf) == 0);
|
|
||||||
|
|
||||||
} else {
|
my $buf;
|
||||||
if(!$hash->{FD}) {
|
if ( $^O =~ m/Win/ && $hash->{USBDev} ) {
|
||||||
Log3 $hash, 1, "TRX_ReadAnswer: device lost";
|
$hash->{USBDev}->read_const_time( $to * 1000 ); # set timeout (ms)
|
||||||
return ("Device lost when reading answer for get $arg", undef);
|
# Read anstatt input sonst funzt read_const_time nicht.
|
||||||
}
|
$buf = $hash->{USBDev}->read(999);
|
||||||
|
return ( "Timeout reading answer for get $arg", undef )
|
||||||
|
if ( length($buf) == 0 );
|
||||||
|
|
||||||
my $rin = '';
|
}
|
||||||
vec($rin, $hash->{FD}, 1) = 1;
|
else {
|
||||||
my $nfound = select($rin, undef, undef, $to);
|
if ( !$hash->{FD} ) {
|
||||||
if($nfound < 0) {
|
Log3 $hash, 1, "TRX_ReadAnswer: device lost";
|
||||||
my $err = $!;
|
return ( "Device lost when reading answer for get $arg", undef );
|
||||||
Log3 $hash, 5, "TRX_ReadAnswer: nfound < 0 / err:$err";
|
}
|
||||||
next if ($err == EAGAIN() || $err == EINTR() || $err == 0);
|
|
||||||
DevIo_Disconnected($hash);
|
|
||||||
return("TRX_ReadAnswer $arg: $err", undef);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($nfound == 0){
|
my $rin = '';
|
||||||
Log3 $hash, 5, "TRX_ReadAnswer: select timeout";
|
vec( $rin, $hash->{FD}, 1 ) = 1;
|
||||||
return ("Timeout reading answer for get $arg", undef);
|
my $nfound = select( $rin, undef, undef, $to );
|
||||||
}
|
if ( $nfound < 0 ) {
|
||||||
|
my $err = $!;
|
||||||
|
Log3 $hash, 5, "TRX_ReadAnswer: nfound < 0 / err:$err";
|
||||||
|
next if ( $err == EAGAIN() || $err == EINTR() || $err == 0 );
|
||||||
|
DevIo_Disconnected($hash);
|
||||||
|
return ( "TRX_ReadAnswer $arg: $err", undef );
|
||||||
|
}
|
||||||
|
|
||||||
$buf = DevIo_SimpleRead($hash);
|
if ( $nfound == 0 ) {
|
||||||
if(!defined($buf)){
|
Log3 $hash, 5, "TRX_ReadAnswer: select timeout";
|
||||||
Log3 $hash, 1,"TRX_ReadAnswer: no data read";
|
return ( "Timeout reading answer for get $arg", undef );
|
||||||
return ("No data", undef);
|
}
|
||||||
}
|
|
||||||
|
$buf = DevIo_SimpleRead($hash);
|
||||||
|
if ( !defined($buf) ) {
|
||||||
|
Log3 $hash, 1, "TRX_ReadAnswer: no data read";
|
||||||
|
return ( "No data", undef );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $ret = TRX_Read( $hash, $buf );
|
||||||
|
if ( defined($ret) ) {
|
||||||
|
Log3 $hash, 4, "TRX_ReadAnswer for $arg: $ret";
|
||||||
|
return ( undef, $ret );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $ret = TRX_Read($hash, $buf);
|
|
||||||
if(defined($ret)){
|
|
||||||
Log3 $hash, 4, "TRX_ReadAnswer for $arg: $ret";
|
|
||||||
return (undef, $ret);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
# called from the global loop, when the select for hash->{FD} reports data
|
# called from the global loop, when the select for hash->{FD} reports data
|
||||||
sub
|
sub TRX_Read($@) {
|
||||||
TRX_Read($@)
|
my ( $hash, $local ) = @_;
|
||||||
{
|
|
||||||
my ($hash, $local) = @_;
|
|
||||||
|
|
||||||
my $mybuf = (defined($local) ? $local : DevIo_SimpleRead($hash));
|
my $mybuf = ( defined($local) ? $local : DevIo_SimpleRead($hash) );
|
||||||
return "" if(!defined($mybuf));
|
return "" if ( !defined($mybuf) );
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
my $TRX_data = $hash->{PARTIAL};
|
my $TRX_data = $hash->{PARTIAL};
|
||||||
Log3 $name, 5, "TRX/RAW: $TRX_data/$mybuf";
|
Log3 $name, 5, "TRX/RAW: $TRX_data/$mybuf";
|
||||||
$TRX_data .= $mybuf;
|
$TRX_data .= $mybuf;
|
||||||
|
|
||||||
my $hexline = unpack('H*', $TRX_data);
|
my $hexline = unpack( 'H*', $TRX_data );
|
||||||
Log3 $name, 5, "TRX: TRX_Read '$hexline'";
|
Log3 $name, 5, "TRX: TRX_Read '$hexline'";
|
||||||
|
|
||||||
# first char as byte represents number of bytes of the message
|
# first char as byte represents number of bytes of the message
|
||||||
my $num_bytes = ord(substr($TRX_data,0,1));
|
my $num_bytes = ord( substr( $TRX_data, 0, 1 ) );
|
||||||
|
|
||||||
while(length($TRX_data) > $num_bytes) {
|
while ( length($TRX_data) > $num_bytes ) {
|
||||||
# the buffer contains at least the number of bytes we need
|
|
||||||
my $rmsg;
|
|
||||||
$rmsg = substr($TRX_data, 0, $num_bytes+1);
|
|
||||||
#my $hexline = unpack('H*', $rmsg);
|
|
||||||
Log3 $name, 5, "TRX_Read rmsg '$hexline'";
|
|
||||||
$TRX_data = substr($TRX_data, $num_bytes+1);;
|
|
||||||
#$hexline = unpack('H*', $TRX_data);
|
|
||||||
Log3 $name, 5, "TRX_Read TRX_data '$hexline'";
|
|
||||||
#
|
|
||||||
TRX_Parse($hash, $hash, $name, unpack('H*', $rmsg));
|
|
||||||
$num_bytes = ord(substr($TRX_data,0,1));
|
|
||||||
}
|
|
||||||
Log3 $name, 5, "TRX_Read END";
|
|
||||||
|
|
||||||
$hash->{PARTIAL} = $TRX_data;
|
# the buffer contains at least the number of bytes we need
|
||||||
|
my $rmsg;
|
||||||
|
$rmsg = substr( $TRX_data, 0, $num_bytes + 1 );
|
||||||
|
|
||||||
|
#my $hexline = unpack('H*', $rmsg);
|
||||||
|
Log3 $name, 5, "TRX_Read rmsg '$hexline'";
|
||||||
|
$TRX_data = substr( $TRX_data, $num_bytes + 1 );
|
||||||
|
|
||||||
|
#$hexline = unpack('H*', $TRX_data);
|
||||||
|
Log3 $name, 5, "TRX_Read TRX_data '$hexline'";
|
||||||
|
#
|
||||||
|
TRX_Parse( $hash, $hash, $name, unpack( 'H*', $rmsg ) );
|
||||||
|
$num_bytes = ord( substr( $TRX_data, 0, 1 ) );
|
||||||
|
}
|
||||||
|
Log3 $name, 5, "TRX_Read END";
|
||||||
|
|
||||||
|
$hash->{PARTIAL} = $TRX_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub TRX_Parse($$$$) {
|
||||||
TRX_Parse($$$$)
|
my ( $hash, $iohash, $name, $rmsg ) = @_;
|
||||||
{
|
|
||||||
my ($hash, $iohash, $name, $rmsg) = @_;
|
|
||||||
|
|
||||||
#Log3 $hash, 5, "TRX_Parse() '$rmsg'";
|
#Log3 $hash, 5, "TRX_Parse() '$rmsg'";
|
||||||
|
|
||||||
if(!defined($hash->{STATE}) || $hash->{STATE} ne "Initialized"){
|
if ( !defined( $hash->{STATE} ) || $hash->{STATE} ne "Initialized" ) {
|
||||||
Log3 $hash, 4,"TRX_Parse $rmsg: dongle not yet initialized";
|
Log3 $hash, 4, "TRX_Parse $rmsg: dongle not yet initialized";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my %addvals;
|
my %addvals;
|
||||||
# Parse only if message is different within 2 seconds
|
|
||||||
# (some Oregon sensors always sends the message twice, X10 security sensors even sends the message five times)
|
|
||||||
if (("$last_rmsg" ne "$rmsg") || (time() - $last_time) > 1) {
|
|
||||||
Log3 $hash, 5, "TRX_Parse() '$rmsg'";
|
|
||||||
%addvals = (RAWMSG => $rmsg);
|
|
||||||
Dispatch($hash, $rmsg, \%addvals);
|
|
||||||
$hash->{"${name}_MSGCNT"}++;
|
|
||||||
$hash->{"${name}_TIME"} = TimeNow();
|
|
||||||
$hash->{RAWMSG} = $rmsg;
|
|
||||||
readingsSingleUpdate($hash, "state", $hash->{READINGS}{state}{VAL}, 0);
|
|
||||||
} else {
|
|
||||||
Log3 $hash, 5, "TRX_Parse() '$rmsg' dup";
|
|
||||||
}
|
|
||||||
|
|
||||||
$last_rmsg = $rmsg;
|
# Parse only if message is different within 2 seconds
|
||||||
$last_time = time();
|
# (some Oregon sensors always sends the message twice, X10 security sensors even sends the message five times)
|
||||||
|
if ( ( "$last_rmsg" ne "$rmsg" ) || ( time() - $last_time ) > 1 ) {
|
||||||
|
Log3 $hash, 5, "TRX_Parse() '$rmsg'";
|
||||||
|
%addvals = ( RAWMSG => $rmsg );
|
||||||
|
Dispatch( $hash, $rmsg, \%addvals );
|
||||||
|
$hash->{"${name}_MSGCNT"}++;
|
||||||
|
$hash->{"${name}_TIME"} = TimeNow();
|
||||||
|
$hash->{RAWMSG} = $rmsg;
|
||||||
|
readingsSingleUpdate( $hash, "state", $hash->{READINGS}{state}{VAL}, 0 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log3 $hash, 5, "TRX_Parse() '$rmsg' dup";
|
||||||
|
}
|
||||||
|
|
||||||
|
$last_rmsg = $rmsg;
|
||||||
|
$last_time = time();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub TRX_Ready($) {
|
||||||
TRX_Ready($)
|
my ($hash) = @_;
|
||||||
{
|
|
||||||
my ($hash) = @_;
|
|
||||||
|
|
||||||
return DevIo_OpenDev($hash, 1, "TRX_DoInit")
|
return DevIo_OpenDev( $hash, 1, "TRX_DoInit" )
|
||||||
if($hash->{STATE} eq "disconnected");
|
if ( $hash->{STATE} eq "disconnected" );
|
||||||
|
|
||||||
# This is relevant for windows/USB only
|
# This is relevant for windows/USB only
|
||||||
my $po = $hash->{USBDev};
|
my $po = $hash->{USBDev};
|
||||||
my ($BlockingFlags, $InBytes, $OutBytes, $ErrorFlags) = $po->status;
|
my ( $BlockingFlags, $InBytes, $OutBytes, $ErrorFlags ) = $po->status;
|
||||||
return ($InBytes>0);
|
return ( $InBytes > 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
@ -626,16 +570,26 @@ KlikAanKlikUit, NEXA, CHACON, HomeEasy UK.</li>
|
|||||||
</ul>
|
</ul>
|
||||||
<br>
|
<br>
|
||||||
</table>
|
</table>
|
||||||
|
<a name="TRXReadings"></a>
|
||||||
|
<b>Readings</b>
|
||||||
|
<ul>
|
||||||
|
<ul>
|
||||||
|
<li>firmware: Firmware of the RFXTRX Device</li>
|
||||||
|
<li>frequency: Frequency and type of the RFXTRX Device</li>
|
||||||
|
<li>protocols: enabled protocols of the RFXTRX Device</li>
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
<a name="TRXattr"></a>
|
<a name="TRXAttributes"></a>
|
||||||
<b>Attributes</b>
|
<b>Attributes</b>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#attrdummy">dummy</a></li><br>
|
<ul>
|
||||||
<li>longids<br>
|
<li><a href="#attrdummy">dummy</a></li><br>
|
||||||
Comma separated list of device-types for TRX_WEATHER that should be handled using long IDs. This additional ID is a one byte hex string and is generated by the Oregon sensor when is it powered on. The value seems to be randomly generated. This has the advantage that you may use more than one Oregon sensor of the same type even if it has no switch to set a sensor id. For example the author uses two BTHR918N sensors at the same time. All have different deviceids. The drawback is that the deviceid changes after changing batteries. All devices listed as longids will get an additional one byte hex string appended to the device name.<br>
|
<li>longids<br>
|
||||||
Default is to use no long IDs.
|
Comma separated list of device-types for TRX_WEATHER that should be handled using long IDs. This additional ID is a one byte hex string and is generated by the Oregon sensor when is it powered on. The value seems to be randomly generated. This has the advantage that you may use more than one Oregon sensor of the same type even if it has no switch to set a sensor id. For example the author uses two BTHR918N sensors at the same time. All have different deviceids. The drawback is that the deviceid changes after changing batteries. All devices listed as longids will get an additional one byte hex string appended to the device name.<br>
|
||||||
<br><br>
|
Default is to use no long IDs.
|
||||||
Examples:<PRE>
|
<br><br>
|
||||||
|
Examples:<PRE>
|
||||||
# Do not use any long IDs for any devices (this is default):
|
# Do not use any long IDs for any devices (this is default):
|
||||||
attr RFXCOMUSB longids 0
|
attr RFXCOMUSB longids 0
|
||||||
# Use long IDs for all devices:
|
# Use long IDs for all devices:
|
||||||
@ -646,19 +600,19 @@ attr RFXTRXUSB longids BTHR918N
|
|||||||
# Use longids for TX3_T and TX3_H devices.
|
# Use longids for TX3_T and TX3_H devices.
|
||||||
# Will generate devices names like TX3_T_07, TX3_T_01 ,TX3_H_07.
|
# Will generate devices names like TX3_T_07, TX3_T_01 ,TX3_H_07.
|
||||||
attr RFXTRXUSB longids TX3_T,TX3_H</PRE>
|
attr RFXTRXUSB longids TX3_T,TX3_H</PRE>
|
||||||
</li><br>
|
</li>
|
||||||
<li>rssi<br>
|
<li>rssi<br>
|
||||||
1: enable RSSI logging, 0: disable RSSI logging<br>
|
1: enable RSSI logging, 0: disable RSSI logging<br>
|
||||||
Default is no RSSI logging.
|
Default is no RSSI logging.
|
||||||
<br><br>
|
<br><br>
|
||||||
Examples:<PRE>
|
Examples:<PRE>
|
||||||
# Do log rssi values (this is default):
|
# Do log rssi values (this is default):
|
||||||
attr RFXCOMUSB rssi 0
|
attr RFXCOMUSB rssi 0
|
||||||
# Enable rssi logging for devices:
|
# Enable rssi logging for devices:
|
||||||
attr RFXCOMUSB rssi 1
|
attr RFXCOMUSB rssi 1</PRE>
|
||||||
</li><br>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
=end html
|
=end html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user