mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
46_TRX_SECURITY.pm: Added RM174RF
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@20805 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
574edf67fe
commit
27f7c24f17
@ -32,6 +32,7 @@
|
|||||||
#
|
#
|
||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
#
|
#
|
||||||
|
# 20.12.2019 Added RM174RF
|
||||||
# 30.12.2018 Added standardized Reading batteryState
|
# 30.12.2018 Added standardized Reading batteryState
|
||||||
# 29.03.2018 Summary for Commandref
|
# 29.03.2018 Summary for Commandref
|
||||||
#
|
#
|
||||||
@ -65,27 +66,34 @@ my %security_device_codes = ( # HEXSTRING => "NAME", "name of reading",
|
|||||||
0x2007 => [ "VISONIC_WINDOW_AUX", "window" ],
|
0x2007 => [ "VISONIC_WINDOW_AUX", "window" ],
|
||||||
0x2008 => [ "MEIANTECH", "alarm" ],
|
0x2008 => [ "MEIANTECH", "alarm" ],
|
||||||
0x2009 => [ "SA30", "alarm" ],
|
0x2009 => [ "SA30", "alarm" ],
|
||||||
|
0x200a => [ "RM174RF", "smoke" ],
|
||||||
);
|
);
|
||||||
|
|
||||||
my %security_device_commands = ( # HEXSTRING => commands
|
my %security_device_commands = ( # HEXSTRING => commands
|
||||||
# 0x20: X10, KD101, Visonic, Meiantech
|
# 0x20: X10, KD101, Visonic, Meiantech
|
||||||
0x2000 => [ "Closed", "", "Open", "", "", "", "" ], # DS10A
|
0x2000 => [ "Closed", "", "Open", "", "", "", "" ], # DS10A
|
||||||
0x2001 => [ "", "", "", "", "alert", "normal", "" ], # MS10A
|
0x2001 => [ "", "", "", "", "alert", "normal", "" ], # MS10A
|
||||||
0x2002 => [ "", "", "", "", "", "", "Panic", "EndPanic", "", "Arm_Away", "Arm_Away_Delayed", "Arm_Home", "Arm_Home_Delayed", "Disarm"], # KR18
|
0x2002 => [
|
||||||
0x2003 => [ "", "", "", "", "", "", "alert", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pair"], # KD101
|
"", "", "", "", "", "", "Panic", "EndPanic", "", "Arm_Away", "Arm_Away_Delayed", "Arm_Home",
|
||||||
|
"Arm_Home_Delayed", "Disarm"
|
||||||
|
], # KR18
|
||||||
|
0x2003 =>
|
||||||
|
[ "", "", "", "", "", "", "alert", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pair" ]
|
||||||
|
, # KD101
|
||||||
0x2004 => [ "normal", "", "alert" ], #VISONIC_WINDOW
|
0x2004 => [ "normal", "", "alert" ], #VISONIC_WINDOW
|
||||||
0x2005 => [ "", "", "", "", "motion", "nomotion", "alert" ], #VISONIC_MOTION
|
0x2005 => [ "", "", "", "", "motion", "nomotion", "alert" ], #VISONIC_MOTION
|
||||||
0x2008 => [ "", "", "", "", "", "", "Panic", "", "IR", "Arm_Away", "", "Arm_Home", "", "Disarm" ], #MEIANTECH
|
0x2008 => [ "", "", "", "", "", "", "Panic", "", "IR", "Arm_Away", "", "Arm_Home", "", "Disarm" ], #MEIANTECH
|
||||||
0x2009 => [ "", "", "", "", "", "", "alert", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pair"], #SA30
|
0x2009 =>
|
||||||
|
[ "", "", "", "", "", "", "alert", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "pair" ], #SA30
|
||||||
|
0x200a => [ "", "", "", "", "", "", "Panic", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" ]
|
||||||
|
, #RM174RF
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
my %security_device_c2b; # DEVICE_TYPE->hash (reverse of security_device_codes)
|
my %security_device_c2b; # DEVICE_TYPE->hash (reverse of security_device_codes)
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub TRX_SECURITY_Initialize($) {
|
||||||
TRX_SECURITY_Initialize($)
|
|
||||||
{
|
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
|
|
||||||
foreach my $k ( keys %security_device_codes ) {
|
foreach my $k ( keys %security_device_codes ) {
|
||||||
@ -97,15 +105,12 @@ TRX_SECURITY_Initialize($)
|
|||||||
$hash->{DefFn} = "TRX_SECURITY_Define";
|
$hash->{DefFn} = "TRX_SECURITY_Define";
|
||||||
$hash->{UndefFn} = "TRX_SECURITY_Undef";
|
$hash->{UndefFn} = "TRX_SECURITY_Undef";
|
||||||
$hash->{ParseFn} = "TRX_SECURITY_Parse";
|
$hash->{ParseFn} = "TRX_SECURITY_Parse";
|
||||||
$hash->{AttrList} = "IODev ignore:1,0 do_not_notify:1,0 ".
|
$hash->{AttrList} = "IODev ignore:1,0 do_not_notify:1,0 " . $readingFnAttributes;
|
||||||
$readingFnAttributes;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
sub
|
sub TRX_SECURITY_Set($@) {
|
||||||
TRX_SECURITY_Set($@)
|
|
||||||
{
|
|
||||||
my ( $hash, @a ) = @_;
|
my ( $hash, @a ) = @_;
|
||||||
my $ret = undef;
|
my $ret = undef;
|
||||||
my $na = int(@a);
|
my $na = int(@a);
|
||||||
@ -120,7 +125,8 @@ TRX_SECURITY_Set($@)
|
|||||||
|
|
||||||
if ( $na == 3 ) {
|
if ( $na == 3 ) {
|
||||||
$level = $a[2];
|
$level = $a[2];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$level = 0;
|
$level = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +139,7 @@ TRX_SECURITY_Set($@)
|
|||||||
|
|
||||||
my $device_type_num = $security_device_c2b{$device_type};
|
my $device_type_num = $security_device_c2b{$device_type};
|
||||||
if ( !defined($device_type_num) ) {
|
if ( !defined($device_type_num) ) {
|
||||||
return "Unknown device_type, choose one of " .
|
return "Unknown device_type, choose one of " . join( " ", sort keys %security_device_c2b );
|
||||||
join(" ", sort keys %security_device_c2b);
|
|
||||||
}
|
}
|
||||||
my $protocol_type = $device_type_num >> 8; # high bytes
|
my $protocol_type = $device_type_num >> 8; # high bytes
|
||||||
|
|
||||||
@ -171,19 +176,23 @@ TRX_SECURITY_Set($@)
|
|||||||
$id1 = $2;
|
$id1 = $2;
|
||||||
$id2 = "00";
|
$id2 = "00";
|
||||||
$id3 = $1;
|
$id3 = $1;
|
||||||
} elsif ($deviceid =~ /^(..)(..)(..)$/) {
|
}
|
||||||
|
elsif ( $deviceid =~ /^(..)(..)(..)$/ ) {
|
||||||
$id1 = $1;
|
$id1 = $1;
|
||||||
$id2 = $2;
|
$id2 = $2;
|
||||||
$id3 = $3;
|
$id3 = $3;
|
||||||
} else {
|
}
|
||||||
Log3 $name, 1,"TRX_SECURITY_Set() security1 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
else {
|
||||||
|
Log3 $name, 1,
|
||||||
|
"TRX_SECURITY_Set() security1 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||||
return "error set name=$name deviceid=$deviceid";
|
return "error set name=$name deviceid=$deviceid";
|
||||||
}
|
}
|
||||||
|
|
||||||
# security1
|
# security1
|
||||||
$hex_prefix = sprintf "0820";
|
$hex_prefix = sprintf "0820";
|
||||||
$hex_command = sprintf "%02x%02x%02s%02s%02s%02x00", $device_type_num & 0xff, $seqnr, $id1, $id2, $id3, $cmnd;
|
$hex_command = sprintf "%02x%02x%02s%02s%02s%02x00", $device_type_num & 0xff, $seqnr, $id1, $id2, $id3, $cmnd;
|
||||||
Log3 $name, 5,"TRX_SECURITY_Set() name=$name device_type=$device_type, deviceid=$deviceid id1=$id1, id2=$id2, id3=$id3, command=$command";
|
Log3 $name, 5,
|
||||||
|
"TRX_SECURITY_Set() name=$name device_type=$device_type, deviceid=$deviceid id1=$id1, id2=$id2, id3=$id3, command=$command";
|
||||||
Log3 $name, 5, "TRX_SECURITY_Set() hexline=$hex_prefix$hex_command";
|
Log3 $name, 5, "TRX_SECURITY_Set() hexline=$hex_prefix$hex_command";
|
||||||
|
|
||||||
if ( $device_type ne "KD101" ) {
|
if ( $device_type ne "KD101" ) {
|
||||||
@ -209,7 +218,8 @@ TRX_SECURITY_Set($@)
|
|||||||
readingsEndUpdate( $hash, 1 );
|
readingsEndUpdate( $hash, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return "No set implemented for $device_type . Unknown protocol type";
|
return "No set implemented for $device_type . Unknown protocol type";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,38 +235,54 @@ TRX_SECURITY_Set($@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub TRX_SECURITY_Define($$) {
|
||||||
TRX_SECURITY_Define($$)
|
|
||||||
{
|
|
||||||
my ( $hash, $def ) = @_;
|
my ( $hash, $def ) = @_;
|
||||||
my @a = split( "[ \t][ \t]*", $def );
|
my @a = split( "[ \t][ \t]*", $def );
|
||||||
|
|
||||||
my $a = int(@a);
|
my $a = int(@a);
|
||||||
|
|
||||||
if ( int(@a) != 5 && int(@a) != 7 ) {
|
if ( int(@a) != 5 && int(@a) != 7 ) {
|
||||||
Log3 $hash, 1,"TRX_SECURITY_Define() wrong syntax '@a'. \nCorrect syntax is 'define <name> TRX_SECURITY <type> <deviceid> <devicelog> [<deviceid2> <devicelog2>]'";
|
Log3 $hash, 1,
|
||||||
|
"TRX_SECURITY_Define() wrong syntax '@a'. \nCorrect syntax is 'define <name> TRX_SECURITY <type> <deviceid> <devicelog> [<deviceid2> <devicelog2>]'";
|
||||||
return "wrong syntax: define <name> TRX_SECURITY <type> <deviceid> <devicelog> [<deviceid2> <devicelog2>]";
|
return "wrong syntax: define <name> TRX_SECURITY <type> <deviceid> <devicelog> [<deviceid2> <devicelog2>]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
|
|
||||||
my $type = lc( $a[2] );
|
my $type = lc( $a[2] );
|
||||||
my $deviceid = $a[3];
|
my $deviceid = $a[3];
|
||||||
my $devicelog = $a[4];
|
my $devicelog = $a[4];
|
||||||
|
|
||||||
|
|
||||||
$type = uc($type);
|
$type = uc($type);
|
||||||
|
|
||||||
my $my_type;
|
my $my_type;
|
||||||
if ( $type eq "WD18" || $type eq "GD18" || $type eq "SD18" || $type eq "COD18" || $type eq "GB10E" ) {
|
if ( $type eq "WD18" || $type eq "GD18" || $type eq "SD18" || $type eq "COD18" || $type eq "GB10E" ) {
|
||||||
$my_type = "DS10A"; # device will be received as DS10A
|
$my_type = "DS10A"; # device will be received as DS10A
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$my_type = $type;
|
$my_type = $type;
|
||||||
}
|
}
|
||||||
my $device_name = "TRX" . $DOT . $my_type . $DOT . $deviceid;
|
my $device_name = "TRX" . $DOT . $my_type . $DOT . $deviceid;
|
||||||
|
|
||||||
if ($type ne "DS10A" && $type ne "SD90" && $type ne "MS10A" && $type ne "MS14A" && $type ne "KR18" && $type ne "KD101" && $type ne "VISONIC_WINDOW" && $type ne "VISONIC_MOTION" && $type ne "VISONIC_WINDOW_AUX" && $type ne "VISONIC_REMOTE" && $type ne "MEIANTECH" && $type ne "SA30" && $type ne "GD18" && $type ne "WD18" && $type ne "SD18" && $type ne "COD18" && $type ne "GB10E") {
|
if ( $type ne "DS10A"
|
||||||
|
&& $type ne "SD90"
|
||||||
|
&& $type ne "MS10A"
|
||||||
|
&& $type ne "MS14A"
|
||||||
|
&& $type ne "KR18"
|
||||||
|
&& $type ne "KD101"
|
||||||
|
&& $type ne "VISONIC_WINDOW"
|
||||||
|
&& $type ne "VISONIC_MOTION"
|
||||||
|
&& $type ne "VISONIC_WINDOW_AUX"
|
||||||
|
&& $type ne "VISONIC_REMOTE"
|
||||||
|
&& $type ne "MEIANTECH"
|
||||||
|
&& $type ne "SA30"
|
||||||
|
&& $type ne "GD18"
|
||||||
|
&& $type ne "WD18"
|
||||||
|
&& $type ne "SD18"
|
||||||
|
&& $type ne "COD18"
|
||||||
|
&& $type ne "GB10E"
|
||||||
|
&& $type ne "RM174RF" )
|
||||||
|
{
|
||||||
Log3 $hash, 1, "TRX_SECURITY_Define() wrong type: $type";
|
Log3 $hash, 1, "TRX_SECURITY_Define() wrong type: $type";
|
||||||
return "TRX_SECURITY: wrong type: $type";
|
return "TRX_SECURITY: wrong type: $type";
|
||||||
}
|
}
|
||||||
@ -264,11 +290,12 @@ TRX_SECURITY_Define($$)
|
|||||||
$hash->{TRX_SECURITY_deviceid} = $deviceid;
|
$hash->{TRX_SECURITY_deviceid} = $deviceid;
|
||||||
$hash->{TRX_SECURITY_devicelog} = $devicelog;
|
$hash->{TRX_SECURITY_devicelog} = $devicelog;
|
||||||
$hash->{TRX_SECURITY_type} = $type;
|
$hash->{TRX_SECURITY_type} = $type;
|
||||||
|
|
||||||
#$hash->{TRX_SECURITY_CODE} = $deviceid;
|
#$hash->{TRX_SECURITY_CODE} = $deviceid;
|
||||||
$modules{TRX_SECURITY}{defptr}{$device_name} = $hash;
|
$modules{TRX_SECURITY}{defptr}{$device_name} = $hash;
|
||||||
|
|
||||||
|
|
||||||
if ( int(@a) == 7 ) {
|
if ( int(@a) == 7 ) {
|
||||||
|
|
||||||
# there is a second deviceid:
|
# there is a second deviceid:
|
||||||
#
|
#
|
||||||
my $deviceid2 = $a[5];
|
my $deviceid2 = $a[5];
|
||||||
@ -278,6 +305,7 @@ TRX_SECURITY_Define($$)
|
|||||||
|
|
||||||
$hash->{TRX_SECURITY_deviceid2} = $deviceid2;
|
$hash->{TRX_SECURITY_deviceid2} = $deviceid2;
|
||||||
$hash->{TRX_SECURITY_devicelog2} = $devicelog2;
|
$hash->{TRX_SECURITY_devicelog2} = $devicelog2;
|
||||||
|
|
||||||
#$hash->{TRX_SECURITY_CODE2} = $deviceid2;
|
#$hash->{TRX_SECURITY_CODE2} = $deviceid2;
|
||||||
$modules{TRX_SECURITY}{defptr2}{$device_name2} = $hash;
|
$modules{TRX_SECURITY}{defptr2}{$device_name2} = $hash;
|
||||||
}
|
}
|
||||||
@ -288,16 +316,12 @@ TRX_SECURITY_Define($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub TRX_SECURITY_Undef($$) {
|
||||||
TRX_SECURITY_Undef($$)
|
|
||||||
{
|
|
||||||
my ( $hash, $name ) = @_;
|
my ( $hash, $name ) = @_;
|
||||||
delete( $modules{TRX_SECURITY}{defptr}{$name} );
|
delete( $modules{TRX_SECURITY}{defptr}{$name} );
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub TRX_SECURITY_parse_X10Sec($$) {
|
sub TRX_SECURITY_parse_X10Sec($$) {
|
||||||
my ( $hash, $bytes ) = @_;
|
my ( $hash, $bytes ) = @_;
|
||||||
@ -309,21 +333,24 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
my $device;
|
my $device;
|
||||||
if ( $subtype >= 3 ) {
|
if ( $subtype >= 3 ) {
|
||||||
$device = sprintf '%02x%02x%02x', $bytes->[3], $bytes->[4], $bytes->[5];
|
$device = sprintf '%02x%02x%02x', $bytes->[3], $bytes->[4], $bytes->[5];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
# that's how we do it on 43_RFXX10REC.pm
|
# that's how we do it on 43_RFXX10REC.pm
|
||||||
$device = sprintf '%02x%02x', $bytes->[5], $bytes->[3];
|
$device = sprintf '%02x%02x', $bytes->[5], $bytes->[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
my %security_devtype =
|
my %security_devtype = ( # HEXSTRING =>
|
||||||
( # HEXSTRING =>
|
|
||||||
0x00 => [ "DS10A", "Window" ], # X10 security door/window sensor
|
0x00 => [ "DS10A", "Window" ], # X10 security door/window sensor
|
||||||
0x01 => [ "MS10A", "motion" ], # X10 security motion sensor
|
0x01 => [ "MS10A", "motion" ], # X10 security motion sensor
|
||||||
0x02 => [ "KR18", "key" ], # X10 security remote (no alive packets)
|
0x02 => [ "KR18", "key" ], # X10 security remote (no alive packets)
|
||||||
0x03 => [ "KD101", "smoke" ], # KD101 (no alive packets)
|
0x03 => [ "KD101", "smoke" ], # KD101 (no alive packets)
|
||||||
0x04 => [ "VISONIC_WINDOW", "window" ], # Visonic PowerCode door/window sensor – primary contact (with alive packets)
|
0x04 => [ "VISONIC_WINDOW", "window" ]
|
||||||
|
, # Visonic PowerCode door/window sensor – primary contact (with alive packets)
|
||||||
0x05 => [ "VISONIC_MOTION", "motion" ], # Visonic PowerCode motion sensor (with alive packets)
|
0x05 => [ "VISONIC_MOTION", "motion" ], # Visonic PowerCode motion sensor (with alive packets)
|
||||||
0x06 => [ "VISONIC_REMOTE", "key" ], # Visonic CodeSecure (no alive packets)
|
0x06 => [ "VISONIC_REMOTE", "key" ], # Visonic CodeSecure (no alive packets)
|
||||||
0x07 => [ "VISONIC_WINDOW_AUX", "window" ], # Visonic PowerCode door/window sensor – auxiliary contact (no alive packets)
|
0x07 => [ "VISONIC_WINDOW_AUX", "window" ]
|
||||||
|
, # Visonic PowerCode door/window sensor – auxiliary contact (no alive packets)
|
||||||
|
0x0a => [ "RM174RF", "smoke" ], # RM174RF (no alive packets)
|
||||||
);
|
);
|
||||||
|
|
||||||
my $dev_type;
|
my $dev_type;
|
||||||
@ -332,12 +359,14 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
my $rec = $security_devtype{$subtype};
|
my $rec = $security_devtype{$subtype};
|
||||||
if ( ref $rec ) {
|
if ( ref $rec ) {
|
||||||
( $dev_type, $dev_reading ) = @$rec;
|
( $dev_type, $dev_reading ) = @$rec;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$error = "TRX_SECURITY: x10_devtype wrong for subtype=$subtype";
|
$error = "TRX_SECURITY: x10_devtype wrong for subtype=$subtype";
|
||||||
Log3 $hash, 1, "TRX_SECURITY_parse_X10Sec() " . $error;
|
Log3 $hash, 1, "TRX_SECURITY_parse_X10Sec() " . $error;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$error = "TRX_SECURITY: error undefined subtype=$subtype";
|
$error = "TRX_SECURITY: error undefined subtype=$subtype";
|
||||||
Log3 $hash, 1, "TRX_SECURITY_parse_X10Sec() " . $error;
|
Log3 $hash, 1, "TRX_SECURITY_parse_X10Sec() " . $error;
|
||||||
return "";
|
return "";
|
||||||
@ -353,7 +382,8 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
$firstdevice = 0;
|
$firstdevice = 0;
|
||||||
$def = $modules{TRX_SECURITY}{defptr2}{$device_name};
|
$def = $modules{TRX_SECURITY}{defptr2}{$device_name};
|
||||||
if ( !$def ) {
|
if ( !$def ) {
|
||||||
Log3 $hash, 1, "TRX_SECURITY_parse_X10Sec() UNDEFINED $device_name TRX_SECURITY $dev_type $device $dev_reading";
|
Log3 $hash, 1,
|
||||||
|
"TRX_SECURITY_parse_X10Sec() UNDEFINED $device_name TRX_SECURITY $dev_type $device $dev_reading";
|
||||||
Log3 $hash, 3, "TRX_SECURITY_parse_X10Sec() Unknown device $device_name, please define it";
|
Log3 $hash, 3, "TRX_SECURITY_parse_X10Sec() Unknown device $device_name, please define it";
|
||||||
return "UNDEFINED $device_name TRX_SECURITY $dev_type $device $dev_reading";
|
return "UNDEFINED $device_name TRX_SECURITY $dev_type $device $dev_reading";
|
||||||
}
|
}
|
||||||
@ -367,8 +397,7 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
|
|
||||||
my $hexdata = sprintf '%02x', $data;
|
my $hexdata = sprintf '%02x', $data;
|
||||||
|
|
||||||
my %x10_security =
|
my %x10_security = (
|
||||||
(
|
|
||||||
0x00 => [ 'X10Sec', 'normal', 'min_delay', '', '' ],
|
0x00 => [ 'X10Sec', 'normal', 'min_delay', '', '' ],
|
||||||
0x01 => [ 'X10Sec', 'normal', 'max_delay', '', '' ],
|
0x01 => [ 'X10Sec', 'normal', 'max_delay', '', '' ],
|
||||||
|
|
||||||
@ -420,10 +449,12 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
my $rec = $x10_security{$data};
|
my $rec = $x10_security{$data};
|
||||||
if ( ref $rec ) {
|
if ( ref $rec ) {
|
||||||
( $type, $command, $delay, $battery, $option ) = @$rec;
|
( $type, $command, $delay, $battery, $option ) = @$rec;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$command = $rec;
|
$command = $rec;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Log3 $name, 1, "TRX_SECURITY_parse_X10Sec() undefined command cmd=$data device-nr=$device, hex=$hexdata";
|
Log3 $name, 1, "TRX_SECURITY_parse_X10Sec() undefined command cmd=$data device-nr=$device, hex=$hexdata";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -450,22 +481,28 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
|
|
||||||
my $device_type = uc( $def->{TRX_SECURITY_type} );
|
my $device_type = uc( $def->{TRX_SECURITY_type} );
|
||||||
|
|
||||||
Log3 $name, 5, "TRX_SECURITY_parse_X10Sec() $name devn=$device_name first=$firstdevice subtype=$subtype device_type=$device_type command=$command, delay=$delay, batt=$battery cmd=$hexdata";
|
Log3 $name, 5,
|
||||||
|
"TRX_SECURITY_parse_X10Sec() $name devn=$device_name first=$firstdevice subtype=$subtype device_type=$device_type command=$command, delay=$delay, batt=$battery cmd=$hexdata";
|
||||||
|
|
||||||
my $sensor = "";
|
my $sensor = "";
|
||||||
|
|
||||||
if ( $device_type eq "SD90" ) {
|
if ( $device_type eq "SD90" ) {
|
||||||
$sensor = $firstdevice == 1 ? $def->{TRX_SECURITY_devicelog} : $def->{TRX_SECURITY_devicelog2};
|
$sensor = $firstdevice == 1 ? $def->{TRX_SECURITY_devicelog} : $def->{TRX_SECURITY_devicelog2};
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$sensor = $def->{TRX_SECURITY_devicelog};
|
$sensor = $def->{TRX_SECURITY_devicelog};
|
||||||
}
|
}
|
||||||
|
|
||||||
$current = $command;
|
$current = $command;
|
||||||
if (($device_type eq "DS10A") || ($device_type eq "VISONIC_WINDOW") || ($device_type eq "VISONIC_WINDOW_AUX")) {
|
if ( ( $device_type eq "DS10A" )
|
||||||
|
|| ( $device_type eq "VISONIC_WINDOW" )
|
||||||
|
|| ( $device_type eq "VISONIC_WINDOW_AUX" ) )
|
||||||
|
{
|
||||||
$current = "Error";
|
$current = "Error";
|
||||||
$current = "Open" if ( $command eq "alert" );
|
$current = "Open" if ( $command eq "alert" );
|
||||||
$current = "Closed" if ( $command eq "normal" );
|
$current = "Closed" if ( $command eq "normal" );
|
||||||
} elsif ($device_type eq "WD18" || $device_type eq "GD18") {
|
}
|
||||||
|
elsif ( $device_type eq "WD18" || $device_type eq "GD18" ) {
|
||||||
$current = "Error";
|
$current = "Error";
|
||||||
$current = "normal" if ( $command eq "alert" );
|
$current = "normal" if ( $command eq "alert" );
|
||||||
$current = "alert" if ( $command eq "normal" );
|
$current = "alert" if ( $command eq "normal" );
|
||||||
@ -486,7 +523,8 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
$sensor = "statechange";
|
$sensor = "statechange";
|
||||||
readingsBulkUpdate( $def, $sensor, $current );
|
readingsBulkUpdate( $def, $sensor, $current );
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
# kr18 remote control or VISONIC_REMOTE
|
# kr18 remote control or VISONIC_REMOTE
|
||||||
$current = $command;
|
$current = $command;
|
||||||
|
|
||||||
@ -518,7 +556,6 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
readingsBulkUpdate( $def, $sensor, $rssi );
|
readingsBulkUpdate( $def, $sensor, $rssi );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( $delay ne '' ) {
|
if ( $delay ne '' ) {
|
||||||
$sensor = "delay";
|
$sensor = "delay";
|
||||||
$current = "Error";
|
$current = "Error";
|
||||||
@ -540,10 +577,7 @@ sub TRX_SECURITY_parse_X10Sec($$) {
|
|||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub TRX_SECURITY_Parse($$) {
|
||||||
sub
|
|
||||||
TRX_SECURITY_Parse($$)
|
|
||||||
{
|
|
||||||
my ( $iohash, $hexline ) = @_;
|
my ( $iohash, $hexline ) = @_;
|
||||||
|
|
||||||
$trx_rssi = 0;
|
$trx_rssi = 0;
|
||||||
@ -553,11 +587,13 @@ TRX_SECURITY_Parse($$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
my $time = time();
|
my $time = time();
|
||||||
|
|
||||||
# convert to binary
|
# convert to binary
|
||||||
my $msg = pack( 'H*', $hexline );
|
my $msg = pack( 'H*', $hexline );
|
||||||
if ( $time_old == 0 ) {
|
if ( $time_old == 0 ) {
|
||||||
Log3 $iohash, 5, "TRX_SECURITY_Parse() decoding delay=0 hex=$hexline";
|
Log3 $iohash, 5, "TRX_SECURITY_Parse() decoding delay=0 hex=$hexline";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
my $time_diff = $time - $time_old;
|
my $time_diff = $time - $time_old;
|
||||||
Log3 $iohash, 5, "TRX_SECURITY_Parse() decoding delay=$time_diff hex=$hexline";
|
Log3 $iohash, 5, "TRX_SECURITY_Parse() decoding delay=$time_diff hex=$hexline";
|
||||||
}
|
}
|
||||||
@ -584,7 +620,8 @@ TRX_SECURITY_Parse($$)
|
|||||||
$res = TRX_SECURITY_parse_X10Sec( $iohash, \@rfxcom_data_array );
|
$res = TRX_SECURITY_parse_X10Sec( $iohash, \@rfxcom_data_array );
|
||||||
Log3 $iohash, 1, "TRX_SECURITY_Parse() unsupported hex=$hexline" if ( $res eq "" );
|
Log3 $iohash, 1, "TRX_SECURITY_Parse() unsupported hex=$hexline" if ( $res eq "" );
|
||||||
return $res;
|
return $res;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Log3 $iohash, 1, "TRX_SECURITY_Parse() not implemented num_bytes=$num_bytes hex=$hexline";
|
Log3 $iohash, 1, "TRX_SECURITY_Parse() not implemented num_bytes=$num_bytes hex=$hexline";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user