loglevel removed, Log3 uses verbose
git-svn-id: https://svn.fhem.de/fhem/trunk@3774 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -68,7 +68,7 @@ TRX_Initialize($)
|
||||
$hash->{UndefFn} = "TRX_Undef";
|
||||
$hash->{GetFn} = "TRX_Get";
|
||||
$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 loglevel:0,1,2,3,4,5,6";
|
||||
$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";
|
||||
}
|
||||
|
||||
@@ -79,8 +79,12 @@ TRX_Define($$)
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
return "wrong syntax: define <name> TRX devicename [noinit]"
|
||||
if(@a != 3 && @a != 4);
|
||||
|
||||
if (@a != 3 && @a != 4) {
|
||||
my $msg = "wrong syntax: define <name> TRX devicename [noinit]";
|
||||
Log3 undef, 2, $msg;
|
||||
return $msg;
|
||||
}
|
||||
|
||||
DevIo_CloseDev($hash);
|
||||
|
||||
@@ -89,14 +93,14 @@ TRX_Define($$)
|
||||
my $opt = $a[3] if(@a == 4);;
|
||||
|
||||
if($dev eq "none") {
|
||||
Log 1, "TRX: $name device is none, commands will be echoed only";
|
||||
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") {
|
||||
Log 1, "TRX: $name no init is done";
|
||||
Log3 $name, 1 , "TRX: $name no init is done";
|
||||
$attr{$name}{do_not_init} = 1;
|
||||
} else {
|
||||
return "wrong syntax: define <name> TRX devicename [noinit]"
|
||||
@@ -111,17 +115,16 @@ TRX_Define($$)
|
||||
#####################################
|
||||
# Input is hexstring
|
||||
sub
|
||||
TRX_Write($$$)
|
||||
TRX_Write($$)
|
||||
{
|
||||
my ($hash,$fn,$msg) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
my $ll5 = GetLogLevel($name,5);
|
||||
|
||||
return if(!defined($fn));
|
||||
|
||||
my $bstring;
|
||||
$bstring = "$fn$msg";
|
||||
Log $ll5, "$hash->{NAME} sending $bstring";
|
||||
Log3 $name, 5, "$hash->{NAME} sending $bstring";
|
||||
|
||||
DevIo_SimpleWrite($hash, $bstring, 1);
|
||||
}
|
||||
@@ -140,7 +143,7 @@ TRX_Undef($$)
|
||||
$defs{$d}{IODev} == $hash)
|
||||
{
|
||||
my $lev = ($reread_active ? 4 : 2);
|
||||
Log GetLogLevel($name,$lev), "deleting port for $d";
|
||||
Log3 $name, $lev, "deleting port for $d";
|
||||
delete $defs{$d}{IODev};
|
||||
}
|
||||
}
|
||||
@@ -166,9 +169,10 @@ TRX_Get($@)
|
||||
my $msg;
|
||||
my $name=$a[0];
|
||||
my $reading= $a[1];
|
||||
|
||||
$msg="$name => No Get function ($reading) implemented";
|
||||
Log 1,$msg;
|
||||
return $msg;
|
||||
Log3 $name, 1,$msg if ($reading ne "?");
|
||||
return $msg;
|
||||
}
|
||||
|
||||
#####################################
|
||||
@@ -210,7 +214,7 @@ TRX_DoInit($)
|
||||
|
||||
|
||||
if(defined($attr{$name}) && defined($attr{$name}{"do_not_init"})) {
|
||||
Log 1, "TRX: defined with noinit. Do not send init string to device.";
|
||||
Log3 $name, 1, "TRX: defined with noinit. Do not send init string to device.";
|
||||
$hash->{STATE} = "Initialized";
|
||||
|
||||
# Reset the counter
|
||||
@@ -234,14 +238,14 @@ TRX_DoInit($)
|
||||
$buf = DevIo_TimeoutRead($hash, 0.1);
|
||||
|
||||
if (! $buf) {
|
||||
Log 1, "TRX: Initialization Error: No character read";
|
||||
Log3 $name, 1, "TRX: Initialization Error: No character read";
|
||||
return "TRX: Initialization Error $name: no char read";
|
||||
} elsif ($buf !~ m/\x0d\x01\x00.........../) {
|
||||
my $hexline = unpack('H*', $buf);
|
||||
Log 1, "TRX: Initialization Error hexline='$hexline'";
|
||||
Log3 $name, 1, "TRX: Initialization Error hexline='$hexline'";
|
||||
return "TRX: Initialization Error %name expected char=0x2c, but char=$char received.";
|
||||
} else {
|
||||
Log 1, "TRX: Init OK";
|
||||
Log3 $name,1, "TRX: Init OK";
|
||||
$hash->{STATE} = "Initialized";
|
||||
# Analyse result and display it:
|
||||
if ($buf =~ m/\x0d\x01\x00(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)/) {
|
||||
@@ -295,8 +299,8 @@ TRX_DoInit($)
|
||||
$status .= "ARC " if ($msg5 & 0x02);
|
||||
$status .= "X10 " if ($msg5 & 0x01);
|
||||
my $hexline = unpack('H*', $buf);
|
||||
Log 4, "TRX: Init status hexline='$hexline'";
|
||||
Log 1, "TRX: Init status: '$status'";
|
||||
Log3 $name, 4, "TRX: Init status hexline='$hexline'";
|
||||
Log3 $name, 1, "TRX: Init status: '$status'";
|
||||
}
|
||||
}
|
||||
#
|
||||
@@ -328,11 +332,11 @@ TRX_Read($)
|
||||
}
|
||||
|
||||
my $TRX_data = $hash->{PARTIAL};
|
||||
#Log 5, "TRX/RAW: $TRX_data/$mybuf";
|
||||
Log3 $name, 5, "TRX/RAW: $TRX_data/$mybuf";
|
||||
$TRX_data .= $mybuf;
|
||||
|
||||
#my $hexline = unpack('H*', $TRX_data);
|
||||
#Log 1, "TRX: TRX_Read '$hexline'";
|
||||
my $hexline = unpack('H*', $TRX_data);
|
||||
Log3 $name, 5, "TRX: TRX_Read '$hexline'";
|
||||
|
||||
# first char as byte represents number of bytes of the message
|
||||
my $num_bytes = ord(substr($TRX_data,0,1));
|
||||
@@ -342,15 +346,15 @@ TRX_Read($)
|
||||
my $rmsg;
|
||||
$rmsg = substr($TRX_data, 0, $num_bytes+1);
|
||||
#my $hexline = unpack('H*', $rmsg);
|
||||
#Log 1, "TRX_Read rmsg '$hexline'";
|
||||
Log3 $name, 5, "TRX_Read rmsg '$hexline'";
|
||||
$TRX_data = substr($TRX_data, $num_bytes+1);;
|
||||
#$hexline = unpack('H*', $TRX_data);
|
||||
#Log 1, "TRX_Read TRX_data '$hexline'";
|
||||
Log3 $name, 5, "TRX_Read TRX_data '$hexline'";
|
||||
#
|
||||
TRX_Parse($hash, $hash, $name, unpack('H*', $rmsg));
|
||||
$num_bytes = ord(substr($TRX_data,0,1));
|
||||
}
|
||||
#Log 1, "TRX_Read END";
|
||||
Log3 $name, 5, "TRX_Read END";
|
||||
|
||||
$hash->{PARTIAL} = $TRX_data;
|
||||
}
|
||||
@@ -360,22 +364,20 @@ TRX_Parse($$$$)
|
||||
{
|
||||
my ($hash, $iohash, $name, $rmsg) = @_;
|
||||
|
||||
#Log 1, "TRX_Parse1 '$rmsg'";
|
||||
Log 5, "TRX_Parse1 '$rmsg'";
|
||||
Log3 $name, 5, "TRX_Parse1 '$rmsg'";
|
||||
|
||||
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) {
|
||||
#Log 1, "TRX_Dispatch '$rmsg'";
|
||||
Log3 $name, 1, "TRX_Dispatch '$rmsg'";
|
||||
%addvals = (RAWMSG => $rmsg);
|
||||
Dispatch($hash, $rmsg, \%addvals);
|
||||
$hash->{"${name}_MSGCNT"}++;
|
||||
$hash->{"${name}_TIME"} = TimeNow();
|
||||
$hash->{RAWMSG} = $rmsg;
|
||||
} else {
|
||||
#Log 1, "TRX_Dispatch '$rmsg' dup";
|
||||
#Log 1, "<-duplicate->";
|
||||
Log3 $name, 1, "TRX_Dispatch '$rmsg' dup";
|
||||
}
|
||||
|
||||
$last_rmsg = $rmsg;
|
||||
|
||||
@@ -32,9 +32,6 @@ package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Debug this module? YES = 1, NO = 0
|
||||
my $TRX_ELSE_debug = 0;
|
||||
|
||||
my $time_old = 0;
|
||||
|
||||
my $DOT = q{_};
|
||||
@@ -48,10 +45,10 @@ TRX_ELSE_Initialize($)
|
||||
$hash->{DefFn} = "TRX_ELSE_Define";
|
||||
$hash->{UndefFn} = "TRX_ELSE_Undef";
|
||||
$hash->{ParseFn} = "TRX_ELSE_Parse";
|
||||
$hash->{AttrList} = "IODev ignore:1,0 do_not_notify:1,0 loglevel:0,1,2,3,4,5,6 ".
|
||||
$hash->{AttrList} = "IODev ignore:1,0 do_not_notify:1,0 ".
|
||||
$readingFnAttributes;
|
||||
|
||||
Log 1, "TRX_ELSE: Initialize" if ($TRX_ELSE_debug == 1);
|
||||
Log3 $hash, 5, "TRX_ELSE_Initialize() Initialize";
|
||||
}
|
||||
|
||||
#####################################
|
||||
@@ -61,8 +58,8 @@ TRX_ELSE_Define($$)
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
my $a = int(@a);
|
||||
#print "a0 = $a[0]";
|
||||
my $a = int(@a);
|
||||
|
||||
return "wrong syntax: define <name> TRX_ELSE code" if(int(@a) != 3);
|
||||
|
||||
my $name = $a[0];
|
||||
@@ -93,16 +90,16 @@ TRX_ELSE_Parse($$)
|
||||
|
||||
my $time = time();
|
||||
if ($time_old ==0) {
|
||||
Log 5, "TRX_ELSE: decoding delay=0 hex=$msg";
|
||||
Log3 $hash, 5, "TRX_ELSE_Parse() decoding delay=0 hex=$msg";
|
||||
} else {
|
||||
my $time_diff = $time - $time_old ;
|
||||
Log 5, "TRX_ELSE: decoding delay=$time_diff hex=$msg";
|
||||
Log3 $hash, 5, "TRX_ELSE_Parse() decoding delay=$time_diff hex=$msg";
|
||||
}
|
||||
$time_old = $time;
|
||||
|
||||
# convert to binary
|
||||
my $bin_msg = pack('H*', $msg);
|
||||
#Log 1, "TRX_ELSE: 2 hex=$hexline";
|
||||
Log3 $hash, 5, "TRX_ELSE_Parse() 2 hex=$msg";
|
||||
|
||||
# convert string to array of bytes. Skip length byte
|
||||
my @rfxcom_data_array = ();
|
||||
@@ -118,17 +115,16 @@ TRX_ELSE_Parse($$)
|
||||
|
||||
my $type = $rfxcom_data_array[0];
|
||||
|
||||
Log 1, "TRX_ELSE: num_bytes=$num_bytes hex=$msg type=$type" if ($TRX_ELSE_debug == 1);
|
||||
Log3 $hash, 5, "TRX_ELSE_Parse() num_bytes=$num_bytes hex=$msg type=$type";
|
||||
my $res = "";
|
||||
if ($type == 0x02) {
|
||||
my $subtype = $rfxcom_data_array[1];
|
||||
my $msg = $rfxcom_data_array[3];
|
||||
if (($msg != 0x00) && ($msg != 0x01)) {
|
||||
Log 0, "TRX_ELSE: error transmit NACK=".sprintf("%02x",$msg);
|
||||
Log3 $hash, 1, "TRX_ELSE_Parse() error transmit NACK=".sprintf("%02x",$msg);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
#Log 0, "TRX_ELSE: hex=$msg";
|
||||
|
||||
my $type_hex = sprintf("%02x", $type);
|
||||
|
||||
@@ -136,7 +132,7 @@ TRX_ELSE_Parse($$)
|
||||
|
||||
my $def = $modules{TRX_ELSE}{defptr}{$device_name};
|
||||
if (!$def) {
|
||||
Log 3, "TRX_ELSE: Unknown device $device_name, please define it";
|
||||
Log3 $hash, 3, "TRX_ELSE: Unknown device $device_name, please define it";
|
||||
return "UNDEFINED $device_name TRX_ELSE $type_hex";
|
||||
|
||||
}
|
||||
|
||||
@@ -35,9 +35,6 @@ package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Debug this module? YES = 1, NO = 0
|
||||
my $TRX_LIGHT_debug = 0;
|
||||
|
||||
my $time_old = 0;
|
||||
|
||||
my $TRX_LIGHT_type_default = "ds10a";
|
||||
@@ -115,7 +112,6 @@ TRX_LIGHT_Initialize($)
|
||||
$hash->{UndefFn} = "TRX_LIGHT_Undef";
|
||||
$hash->{ParseFn} = "TRX_LIGHT_Parse";
|
||||
$hash->{AttrList} = "IODev ignore:1,0 do_not_notify:1,0 ".
|
||||
"loglevel:0,1,2,3,4,5,6 ".
|
||||
$readingFnAttributes;
|
||||
|
||||
}
|
||||
@@ -146,7 +142,7 @@ TRX_LIGHT_Do_On_Till($@)
|
||||
my $hms_till = sprintf("%02d:%02d:%02d", $hr, $min, $sec);
|
||||
my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]);
|
||||
if($hms_now ge $hms_till) {
|
||||
Log 4, "on-till: won't switch as now ($hms_now) is later than $hms_till";
|
||||
Log3 $hash, 4, "on-till: won't switch as now ($hms_now) is later than $hms_till";
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -243,17 +239,17 @@ TRX_LIGHT_Set($@)
|
||||
my $command_codes = $hash->{TRX_LIGHT_commandcodes}.",";
|
||||
my $l = $command_codes;
|
||||
$l =~ s/([0-9]*):([a-z]*),/$2 /g;
|
||||
#Log 1,"PT2262: l=$l";
|
||||
Log3 $name, 5,"TRX_LIGHT_Set() PT2262: l=$l";
|
||||
|
||||
if (!($command =~ /^[0-2]*$/)) { # if it is base4 just accept it
|
||||
if ($command ne "?" && $command_codes =~ /([0-9]*):$command,/ ) {
|
||||
Log 1,"PT2262: arg=$command found=$1" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $name, 5,"TRX_LIGHT_Set() PT2262: arg=$command found=$1";
|
||||
$command = $1;
|
||||
} else {
|
||||
Log 1,"PT2262: else arg=$command l='$l'" if ($TRX_LIGHT_debug == 1);
|
||||
my $error = "Unknown command $command, choose one of $l ";
|
||||
Log3 $name, 5,"TRX_LIGHT_Set() PT2262: else arg=$command l='$l'";
|
||||
|
||||
Log 4, $error;
|
||||
my $error = "Unknown command $command, choose one of $l ";
|
||||
Log3 $name, 1, "TRX_LIGHT_Set() PT2262".$error if ($command ne "?");
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
@@ -265,7 +261,7 @@ TRX_LIGHT_Set($@)
|
||||
#my $error = "Unknown command $command, choose one of $l";
|
||||
my $error = "Unknown command $command, choose one of $l "."on-till on-for-timer";
|
||||
|
||||
Log 4, $error;
|
||||
Log3 $name, 1, "TRX_LIGHT_Set()".$error if ($command ne "?");
|
||||
return $error;
|
||||
}
|
||||
|
||||
@@ -282,21 +278,21 @@ TRX_LIGHT_Set($@)
|
||||
$house = ord("$1");
|
||||
$unit = $2;
|
||||
} else {
|
||||
Log 4,"TRX_LIGHT_Set lighting1 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||
Log3 $name, 1, "TRX_LIGHT_Set() lighting1 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||
return "error set name=$name deviceid=$deviceid";
|
||||
}
|
||||
|
||||
# lighting1
|
||||
$hex_prefix = sprintf "0710";
|
||||
$hex_command = sprintf "%02x%02x%02x%02x%02x00", $device_type_num & 0xff, $seqnr, $house, $unit, $cmnd;
|
||||
Log 1,"TRX_LIGHT_Set name=$name device_type=$device_type, deviceid=$deviceid house=$house, unit=$unit command=$command" if ($TRX_LIGHT_debug == 1);
|
||||
Log 1,"TRX_LIGHT_Set hexline=$hex_prefix$hex_command" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $name, 5, "TRX_LIGHT_Set() name=$name device_type=$device_type, deviceid=$deviceid house=$house, unit=$unit command=$command";
|
||||
Log3 $name, 5,"TRX_LIGHT_Set hexline=$hex_prefix$hex_command";
|
||||
} elsif ($protocol_type == 0x11) {
|
||||
# lighting2
|
||||
if (uc($deviceid) =~ /^[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/ ) {
|
||||
;
|
||||
} else {
|
||||
Log 4,"TRX_LIGHT_Set lighting2 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||
Log3 $name, 1,"TRX_LIGHT_Set() lighting2 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||
return "error set name=$name deviceid=$deviceid";
|
||||
}
|
||||
$hex_prefix = sprintf "0B11";
|
||||
@@ -305,8 +301,8 @@ TRX_LIGHT_Set($@)
|
||||
$command .= sprintf " %d", $level;
|
||||
$command_state = $command;
|
||||
}
|
||||
Log 1,"TRX_LIGHT_Set lighting2 name=$name device_type=$device_type, deviceid=$deviceid command=$command" if ($TRX_LIGHT_debug == 1);
|
||||
Log 1,"TRX_LIGHT_Set lighting2 hexline=$hex_prefix$hex_command" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $name, 5, "TRX_LIGHT_Set() lighting2 name=$name device_type=$device_type, deviceid=$deviceid command=$command";
|
||||
Log3 $name, 5, "TRX_LIGHT_Set() lighting2 hexline=$hex_prefix$hex_command";
|
||||
} elsif ($protocol_type == 0x12) {
|
||||
# lighting3
|
||||
my $koppla_id = "";
|
||||
@@ -317,9 +313,9 @@ TRX_LIGHT_Set($@)
|
||||
return "error set name=$name deviceid=$deviceid. system must be in range 01-16";
|
||||
}
|
||||
$koppla_id = sprintf("%02X",$koppla_system).$3."0".$2;
|
||||
Log 1,"TRX_LIGHT_Set lighting3: deviceid=$deviceid kopplaid=$koppla_id" if (1 || $TRX_LIGHT_debug == 1);
|
||||
Log3 $name, 5,"TRX_LIGHT_Set() lighting3: deviceid=$deviceid kopplaid=$koppla_id";
|
||||
} else {
|
||||
Log 4,"TRX_LIGHT_Set lighting3 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid. Wrong deviceid must be 3 digits with range 0000 - f3FF";
|
||||
Log3 $name, 1,"TRX_LIGHT_Set() lighting3 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid. Wrong deviceid must be 3 digits with range 0000 - f3FF";
|
||||
return "error set name=$name deviceid=$deviceid. Wrong deviceid must be 5 digits consisting of 2 digit decimal value for system (01-16) and a 3 hex digit channel (000 - 3ff)";
|
||||
}
|
||||
$hex_prefix = sprintf "0812";
|
||||
@@ -328,8 +324,8 @@ TRX_LIGHT_Set($@)
|
||||
$command .= sprintf " %d", $level;
|
||||
$command_state = $command;
|
||||
}
|
||||
Log 1,"TRX_LIGHT_Set lighting3 name=$name device_type=$device_type, deviceid=$deviceid command=$command" if (1 ||$TRX_LIGHT_debug == 1);
|
||||
Log 1,"TRX_LIGHT_Set lighting3 hexline=$hex_prefix$hex_command" if (1 || $TRX_LIGHT_debug == 1);
|
||||
Log3 $name, 5,"TRX_LIGHT_Set() lighting3 name=$name device_type=$device_type, deviceid=$deviceid command=$command";
|
||||
Log3 $name, 5,"TRX_LIGHT_Set() lighting3 hexline=$hex_prefix$hex_command";
|
||||
} elsif ($protocol_type == 0x13) {
|
||||
# lighting4 (PT2262)
|
||||
my $pt2262_cmd;
|
||||
@@ -340,7 +336,8 @@ TRX_LIGHT_Set($@)
|
||||
if ($command =~ /^[0-3]*$/) { # if it is base4 just append it
|
||||
$pt2262_cmd = $deviceid.$command;
|
||||
} else {
|
||||
return "-999- set PT2262: cmd=$command name=$name not found";
|
||||
|
||||
return "TRX_LIGHT_Set() PT2262: cmd=$command name=$name not found";
|
||||
}
|
||||
|
||||
|
||||
@@ -351,22 +348,22 @@ TRX_LIGHT_Set($@)
|
||||
my %b42b = (0 => "00", 1 => "01", 2 => "10", 3 => "11");
|
||||
($bindata = $base_4) =~ s/(.)/$b42b{lc $1}/g;
|
||||
$hexdata = unpack("H*", pack("B*", $bindata));
|
||||
Log 1,"TRX_LIGHT_Set PT2262: base4='$base_4', binary='$bindata' hex='$hexdata'" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $name, 5,"TRX_LIGHT_Set() PT2262: base4='$base_4', binary='$bindata' hex='$hexdata'";
|
||||
|
||||
} else {
|
||||
Log 4,"TRX_LIGHT_Set lighting4:PT2262 cmd='$pt2262_cmd' needs to be base4 and has 12 digits (name=$name device_type=$device_type, deviceid=$deviceid)";
|
||||
Log3 $name, 5,"TRX_LIGHT_Set() lighting4:PT2262 cmd='$pt2262_cmd' needs to be base4 and has 12 digits (name=$name device_type=$device_type, deviceid=$deviceid)";
|
||||
return "error set name=$name deviceid=$pt2262_cmd (needs to be base4 and has 12 digits)";
|
||||
}
|
||||
$hex_prefix = sprintf "0913";
|
||||
$hex_command = sprintf "00%02x%s015E00", $seqnr, $hexdata;
|
||||
Log 1,"TRX_LIGHT_Set lighting4:PT2262 name=$name cmd=$command cmd_state=$command_state hexdata=$hexdata" if (1 || $TRX_LIGHT_debug == 1);
|
||||
Log 1,"TRX_LIGHT_Set lighting4:PT2262 hexline=$hex_prefix$hex_command" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $name, 5, "TRX_LIGHT_Set() lighting4:PT2262 name=$name cmd=$command cmd_state=$command_state hexdata=$hexdata";
|
||||
Log3 $name, 5, "TRX_LIGHT_Set() lighting4:PT2262 hexline=$hex_prefix$hex_command";
|
||||
} elsif ($protocol_type == 0x14) {
|
||||
# lighting5
|
||||
if (uc($deviceid) =~ /^[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$/ ) {
|
||||
;
|
||||
} else {
|
||||
Log 4,"TRX_LIGHT_Set lighting5 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||
Log3 $name, 1, "TRX_LIGHT_Set() lighting5 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||
return "error set name=$name deviceid=$deviceid";
|
||||
}
|
||||
$hex_prefix = sprintf "0A14";
|
||||
@@ -375,8 +372,8 @@ TRX_LIGHT_Set($@)
|
||||
$command .= sprintf " %d", $level;
|
||||
$command_state = $command;
|
||||
}
|
||||
Log 1,"TRX_LIGHT_Set lighting5 name=$name device_type=$device_type, deviceid=$deviceid command=$command" if ($TRX_LIGHT_debug == 1);
|
||||
Log 1,"TRX_LIGHT_Set lighting5 hexline=$hex_prefix$hex_command" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $name, 5, "TRX_LIGHT_Set() lighting5 name=$name device_type=$device_type, deviceid=$deviceid command=$command";
|
||||
Log3 $name, 5, "TRX_LIGHT_Set() lighting5 hexline=$hex_prefix$hex_command";
|
||||
} else {
|
||||
return "No set implemented for $device_type . Unknown protocol type";
|
||||
}
|
||||
@@ -408,11 +405,11 @@ TRX_LIGHT_Define($$)
|
||||
|
||||
if (int(@a) > 2 && uc($a[2]) eq "PT2262") {
|
||||
if (int(@a) != 3 && int(@a) != 6) {
|
||||
Log 1,"TRX_LIGHT wrong syntax '@a'. \nCorrect syntax is 'define <name> TRX_LIGHT PT2262 [<deviceid> <devicelog> <commandcodes>]'";
|
||||
Log3 $hash, 1, "TRX_LIGHT_Define() wrong syntax '@a'. \nCorrect syntax is 'define <name> TRX_LIGHT PT2262 [<deviceid> <devicelog> <commandcodes>]'";
|
||||
return "wrong syntax: define <name> TRX_LIGHT PT2262 [<deviceid> <devicelog> [<commandcodes>]]";
|
||||
}
|
||||
} elsif(int(@a) != 5 && int(@a) != 7) {
|
||||
Log 1,"TRX_LIGHT wrong syntax '@a'. \nCorrect syntax is 'define <name> TRX_LIGHT <type> <deviceid> <devicelog> [<deviceid2> <devicelog2>]'";
|
||||
Log3 $hash, 1, "TRX_LIGHT_Define() wrong syntax '@a'. \nCorrect syntax is 'define <name> TRX_LIGHT <type> <deviceid> <devicelog> [<deviceid2> <devicelog2>]'";
|
||||
return "wrong syntax: define <name> TRX_LIGHT <type> <deviceid> <devicelog> [<deviceid2> <devicelog2>]";
|
||||
}
|
||||
|
||||
@@ -423,7 +420,7 @@ TRX_LIGHT_Define($$)
|
||||
$commandcodes = $a[5] if ($type eq "PT2262" && int(@a) > 5);
|
||||
|
||||
if ($type ne "X10" && $type ne "ARC" && $type ne "MS14A" && $type ne "AB400D" && $type ne "WAVEMAN" && $type ne "EMW200" && $type ne "IMPULS" && $type ne "RISINGSUN" && $type ne "PHILIPS_SBC" && $type ne "AC" && $type ne "HOMEEASY" && $type ne "ANSLUT" && $type ne "KOPPLA" && $type ne "LIGHTWAVERF" && $type ne "EMW100" && $type ne "BBSB" && $type ne "PT2262") {
|
||||
Log 1,"TRX_LIGHT define: wrong type: $type";
|
||||
Log3 $name, 1,"TRX_LIGHT_Define() wrong type: $type";
|
||||
return "TRX_LIGHT: wrong type: $type";
|
||||
}
|
||||
|
||||
@@ -477,8 +474,9 @@ TRX_LIGHT_Undef($$)
|
||||
############################################
|
||||
# T R X _ L I G H T _ p a r s e _ X 1 0 ( )
|
||||
#-------------------------------------------
|
||||
sub TRX_LIGHT_parse_X10 {
|
||||
my $bytes = shift;
|
||||
sub TRX_LIGHT_parse_X10 ($$)
|
||||
{
|
||||
my ($hash, $bytes) = @_;
|
||||
|
||||
my $error = "";
|
||||
|
||||
@@ -498,7 +496,7 @@ sub TRX_LIGHT_parse_X10 {
|
||||
($dev_type, $dev_reading) = @$rec;
|
||||
} else {
|
||||
$error = sprintf "TRX_LIGHT: error undefined type=%02x, subtype=%02x", $type, $subtype;
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_LIGHT_parse_X10() ".$error;
|
||||
return $error;
|
||||
}
|
||||
|
||||
@@ -533,7 +531,7 @@ sub TRX_LIGHT_parse_X10 {
|
||||
$dev_first = $x10_housecode{$devnr};
|
||||
} else {
|
||||
$error = sprintf "TRX_LIGHT: x10_housecode wrong housecode=%02x", $devnr;
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_LIGHT_parse_X10() ".$error;
|
||||
return $error;
|
||||
}
|
||||
my $unit = $bytes->[4]; # unitcode
|
||||
@@ -551,7 +549,7 @@ sub TRX_LIGHT_parse_X10 {
|
||||
$data = $bytes->[7];
|
||||
} else {
|
||||
$error = sprintf "TRX_LIGHT: wrong type=%02x", $type;
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_LIGHT_parse_X10() ".$error;
|
||||
return $error;
|
||||
}
|
||||
my $hexdata = sprintf '%02x', $data;
|
||||
@@ -564,12 +562,12 @@ sub TRX_LIGHT_parse_X10 {
|
||||
$command = $code->[$data];
|
||||
} else {
|
||||
$error = sprintf "TRX_LIGHT: unknown cmd type_subtype=%02x cmd=%02x", $type_subtype, $data;
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_LIGHT_parse_X10() ".$error;
|
||||
return $error;
|
||||
}
|
||||
} else {
|
||||
$error = sprintf "TRX_LIGHT: unknown type_subtype %02x data=%02x", $type_subtype, $data;
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_LIGHT_parse_X10() ".$error;
|
||||
return $error;
|
||||
}
|
||||
|
||||
@@ -578,7 +576,7 @@ sub TRX_LIGHT_parse_X10 {
|
||||
|
||||
#--------------
|
||||
my $device_name = "TRX".$DOT.$dev_type.$DOT.$device;
|
||||
Log 1, "TRX_LIGHT: device_name=$device_name data=$hexdata" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $hash, 5, "TRX_LIGHT: device_name=$device_name data=$hexdata";
|
||||
|
||||
my $firstdevice = 1;
|
||||
my $def = $modules{TRX_LIGHT}{defptr}{$device_name};
|
||||
@@ -586,8 +584,8 @@ sub TRX_LIGHT_parse_X10 {
|
||||
$firstdevice = 0;
|
||||
$def = $modules{TRX_LIGHT}{defptr2}{$device_name};
|
||||
if (!$def) {
|
||||
Log 1, "UNDEFINED $device_name TRX_LIGHT $dev_type $device $dev_reading" if ($TRX_LIGHT_debug == 1);
|
||||
Log 3, "TRX_LIGHT: TRX_LIGHT Unknown device $device_name, please define it";
|
||||
Log3 $hash, 5, "TRX_LIGHT_parse_X10() UNDEFINED $device_name TRX_LIGHT $dev_type $device $dev_reading";
|
||||
Log3 $hash, 3, "TRX_LIGHT_parse_X10() Unknown device $device_name, please define it";
|
||||
return "UNDEFINED $device_name TRX_LIGHT $dev_type $device $dev_reading";
|
||||
|
||||
}
|
||||
@@ -597,7 +595,7 @@ sub TRX_LIGHT_parse_X10 {
|
||||
my $name = $def->{NAME};
|
||||
return "" if(IsIgnored($name));
|
||||
|
||||
Log 1, "TRX_LIGHT: $name devn=$device_name first=$firstdevice command=$command, cmd=$hexdata" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $hash, 5, "TRX_LIGHT_parse_X10() $name devn=$device_name first=$firstdevice command=$command, cmd=$hexdata";
|
||||
|
||||
my $n = 0;
|
||||
my $tm = TimeNow();
|
||||
@@ -642,7 +640,7 @@ sub TRX_LIGHT_parse_X10 {
|
||||
readingsBulkUpdate($def, $sensor, $current);
|
||||
} else {
|
||||
$error = sprintf "TRX_LIGHT: error unknown sensor type=%x device_type=%s devn=%s first=%d command=%s", $type, $device_type, $device_name, $firstdevice, $command;
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_LIGHT_parse_X10() ".$error;
|
||||
return $error;
|
||||
}
|
||||
|
||||
@@ -659,8 +657,9 @@ sub TRX_LIGHT_parse_X10 {
|
||||
########################################################
|
||||
# T R X _ L I G H T _ p a r s e _ P T 2 2 6 2 ( )
|
||||
#-------------------------------------------------------
|
||||
sub TRX_LIGHT_parse_PT2262 {
|
||||
my $bytes = shift;
|
||||
sub TRX_LIGHT_parse_PT2262 ($$)
|
||||
{
|
||||
my ($hash, $bytes) = @_;
|
||||
|
||||
my $error = "";
|
||||
|
||||
@@ -680,7 +679,7 @@ sub TRX_LIGHT_parse_PT2262 {
|
||||
($dev_type, $dev_reading) = @$rec;
|
||||
} else {
|
||||
$error = sprintf "TRX_LIGHT: PT2262 error undefined type=%02x, subtype=%02x", $type, $subtype;
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_LIGHT_parse_PT2262() ".$error;
|
||||
return $error;
|
||||
}
|
||||
|
||||
@@ -720,23 +719,23 @@ sub TRX_LIGHT_parse_PT2262 {
|
||||
$def = $modules{TRX_LIGHT}{defptr}{$device_name.$DOT.substr($base_4,0,$i)};
|
||||
$command_codes = $def->{TRX_LIGHT_commandcodes};
|
||||
$command_rest = substr($base_4,$i);
|
||||
Log 1, "TRX_LIGHT: PT2262 found device_name=$device_name i=$i code=$base_4 commandcodes='$command_codes' command_rest='$command_rest' " if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $hash, 5, "TRX_LIGHT_parse_PT2262() found device_name=$device_name i=$i code=$base_4 commandcodes='$command_codes' command_rest='$command_rest' ";
|
||||
}
|
||||
}
|
||||
|
||||
#--------------
|
||||
if ($device ne "") {
|
||||
# found a device
|
||||
Log 1, "TRX_LIGHT: PT2262 found device_name=$device_name data=$hexdata" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $hash, 5, "TRX_LIGHT: PT2262 found device_name=$device_name data=$hexdata";
|
||||
$device_name .= $DOT.$device
|
||||
} else {
|
||||
# no specific device found. Using generic one:
|
||||
Log 1, "TRX_LIGHT: PT2262 device_name=$device_name data=$hexdata" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $hash, 5, "TRX_LIGHT: PT2262 device_name=$device_name data=$hexdata";
|
||||
$def = $modules{TRX_LIGHT}{defptr}{$device_name};
|
||||
if(!$def) {
|
||||
$dev_reading = "";
|
||||
Log 1, "UNDEFINED $device_name TRX_LIGHT $dev_type $device $dev_reading" if ($TRX_LIGHT_debug == 1);
|
||||
Log 3, "TRX_LIGHT: TRX_LIGHT Unknown device $device_name, please define it";
|
||||
Log3 $hash, 5, "TRX_LIGHT_parse_PT2262() UNDEFINED $device_name TRX_LIGHT $dev_type $device $dev_reading";
|
||||
Log3 $hash, 3, "TRX_LIGHT_parse_PT2262() Unknown device $device_name, please define it";
|
||||
return "UNDEFINED $device_name TRX_LIGHT $dev_type $device $dev_reading";
|
||||
}
|
||||
}
|
||||
@@ -745,7 +744,7 @@ sub TRX_LIGHT_parse_PT2262 {
|
||||
my $name = $def->{NAME};
|
||||
return "" if(IsIgnored($name));
|
||||
|
||||
Log 1, "TRX_LIGHT: PT2262 $name devn=$device_name command=$command, cmd=$hexdata" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $hash, 1, "TRX_LIGHT_parse_PT2262() $name devn=$device_name command=$command, cmd=$hexdata";
|
||||
|
||||
my $n = 0;
|
||||
my $val = "";
|
||||
@@ -768,10 +767,10 @@ sub TRX_LIGHT_parse_PT2262 {
|
||||
$command_codes .= ",";
|
||||
#if ($command_codes =~ /$command_rest:(.*),/o ) {
|
||||
if ($command_codes =~ /$command_rest:([a-z|A-Z]*),/ ) {
|
||||
Log 1,"PT2262: found=$1" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $hash, 5,"PT2262: found=$1";
|
||||
$command = $1;
|
||||
}
|
||||
Log 1,"PT2622 readingsBulkUpdate($def, $sensor, $command)" if ($TRX_LIGHT_debug == 1);
|
||||
Log3 $hash, 1,"TRX_LIGHT_parse_PT2262() readingsBulkUpdate($def, $sensor, $command)";
|
||||
$val = $command;
|
||||
readingsBulkUpdate($def, $sensor, $val);
|
||||
}
|
||||
@@ -794,10 +793,10 @@ TRX_LIGHT_Parse($$)
|
||||
# convert to binary
|
||||
my $msg = pack('H*', $hexline);
|
||||
if ($time_old ==0) {
|
||||
Log 5, "TRX_LIGHT: decoding delay=0 hex=$hexline";
|
||||
Log3 $iohash, 5, "TRX_LIGHT_Parse() decoding delay=0 hex=$hexline";
|
||||
} else {
|
||||
my $time_diff = $time - $time_old ;
|
||||
Log 5, "TRX_LIGHT: decoding delay=$time_diff hex=$hexline";
|
||||
Log3 $iohash, 5, "TRX_LIGHT_Parse() decoding delay=$time_diff hex=$hexline";
|
||||
}
|
||||
$time_old = $time;
|
||||
|
||||
@@ -815,21 +814,21 @@ TRX_LIGHT_Parse($$)
|
||||
|
||||
my $type = $rfxcom_data_array[0];
|
||||
|
||||
#Log 1, "TRX_LIGHT: num_bytes=$num_bytes hex=$hexline type=$type" if ($TRX_LIGHT_debug == 1);
|
||||
#Log3 $iohash, 5, "TRX_LIGHT: num_bytes=$num_bytes hex=$hexline type=$type";
|
||||
my $res = "";
|
||||
if ($type == 0x10 || $type == 0x11 || $type == 0x12 || $type == 0x14) {
|
||||
Log 1, "TRX_LIGHT: X10 num_bytes=$num_bytes hex=$hexline" if ($TRX_LIGHT_debug == 1);
|
||||
$res = TRX_LIGHT_parse_X10(\@rfxcom_data_array);
|
||||
Log 1, "TRX_LIGHT: unsupported hex=$hexline" if ($res eq "");
|
||||
Log3 $iohash, 1, "TRX_LIGHT_Parse() X10 num_bytes=$num_bytes hex=$hexline";
|
||||
$res = TRX_LIGHT_parse_X10($iohash, \@rfxcom_data_array);
|
||||
Log3 $iohash, 1, "TRX_LIGHT_Parse() unsupported hex=$hexline" if ($res eq "");
|
||||
return $res;
|
||||
} elsif ($type == 0x13) {
|
||||
#Log 1, "TRX_LIGHT: Lighting4/PT2262 num_bytes=$num_bytes hex=$hexline";
|
||||
Log 1, "TRX_LIGHT: Lighting4/PT2262 num_bytes=$num_bytes hex=$hexline" if ($TRX_LIGHT_debug == 1);
|
||||
$res = TRX_LIGHT_parse_PT2262(\@rfxcom_data_array);
|
||||
Log 1, "TRX_LIGHT: unsupported hex=$hexline" if ($res eq "");
|
||||
#Log3 $iohash, 1, "TRX_LIGHT_Parse() Lighting4/PT2262 num_bytes=$num_bytes hex=$hexline";
|
||||
Log3 $iohash, 5, "TRX_LIGHT_Parse()Lighting4/PT2262 num_bytes=$num_bytes hex=$hexline";
|
||||
$res = TRX_LIGHT_parse_PT2262($iohash, \@rfxcom_data_array);
|
||||
Log3 $iohash, 1, "TRX_LIGHT_Parse() unsupported hex=$hexline" if ($res eq "");
|
||||
return $res;
|
||||
} else {
|
||||
Log 0, "TRX_LIGHT: not implemented num_bytes=$num_bytes hex=$hexline";
|
||||
Log3 $iohash, 1, "TRX_LIGHT_Parse() not implemented num_bytes=$num_bytes hex=$hexline";
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
@@ -81,7 +81,6 @@ TRX_SECURITY_Initialize($)
|
||||
$hash->{UndefFn} = "TRX_SECURITY_Undef";
|
||||
$hash->{ParseFn} = "TRX_SECURITY_Parse";
|
||||
$hash->{AttrList} = "IODev ignore:1,0 do_not_notify:1,0 ".
|
||||
"loglevel:0,1,2,3,4,5,6 ".
|
||||
$readingFnAttributes;
|
||||
|
||||
}
|
||||
@@ -134,7 +133,7 @@ TRX_SECURITY_Set($@)
|
||||
}
|
||||
my $error = "Unknown command $command, choose one of $l";
|
||||
|
||||
Log 4, $error;
|
||||
Log3 $hash, 1, "TRX_SECURITY_Set() ".$error if ($command ne "?" );
|
||||
return $error;
|
||||
}
|
||||
|
||||
@@ -160,15 +159,15 @@ TRX_SECURITY_Set($@)
|
||||
$id2 = $2;
|
||||
$id3 = $3;
|
||||
} else {
|
||||
Log 4,"TRX_SECURITY_Set lightning1 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||
Log3 $hash, 1,"TRX_SECURITY_Set() lightning1 wrong deviceid: name=$name device_type=$device_type, deviceid=$deviceid";
|
||||
return "error set name=$name deviceid=$deviceid";
|
||||
}
|
||||
|
||||
# lightning1
|
||||
$hex_prefix = sprintf "0820";
|
||||
$hex_command = sprintf "%02x%02x%02s%02s%02s%02x00", $device_type_num & 0xff, $seqnr, $id1, $id2, $id3, $cmnd;
|
||||
Log 1,"TRX_SECURITY_Set name=$name device_type=$device_type, deviceid=$deviceid id1=$id1, id2=$id2, id3=$id3, command=$command" if ($TRX_SECURITY_debug == 1);
|
||||
Log 1,"TRX_SECURITY_Set hexline=$hex_prefix$hex_command" if ($TRX_SECURITY_debug == 1);
|
||||
Log3 $hash, 1,"TRX_SECURITY_Set() name=$name device_type=$device_type, deviceid=$deviceid id1=$id1, id2=$id2, id3=$id3, command=$command";
|
||||
Log3 $hash, 5,"TRX_SECURITY_Set() hexline=$hex_prefix$hex_command";
|
||||
|
||||
if ($device_type ne "KD101") {
|
||||
my $sensor = "";
|
||||
@@ -217,7 +216,7 @@ TRX_SECURITY_Define($$)
|
||||
my $a = int(@a);
|
||||
|
||||
if(int(@a) != 5 && int(@a) != 7) {
|
||||
Log 1,"TRX_SECURITY 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>]";
|
||||
}
|
||||
|
||||
@@ -240,7 +239,7 @@ TRX_SECURITY_Define($$)
|
||||
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_REMOTE" && $type ne "GD18" && $type ne "WD18") {
|
||||
Log 1,"TRX_SECURITY define: wrong type: $type";
|
||||
Log3 $hash, 1,"TRX_SECURITY_Define() wrong type: $type";
|
||||
return "TRX_SECURITY: wrong type: $type";
|
||||
}
|
||||
|
||||
@@ -282,8 +281,8 @@ TRX_SECURITY_Undef($$)
|
||||
|
||||
|
||||
#####################################
|
||||
sub TRX_SECURITY_parse_X10Sec {
|
||||
my $bytes = shift;
|
||||
sub TRX_SECURITY_parse_X10Sec($$) {
|
||||
my ($hash, $bytes) = @_;
|
||||
|
||||
my $error;
|
||||
|
||||
@@ -317,18 +316,18 @@ sub TRX_SECURITY_parse_X10Sec {
|
||||
($dev_type, $dev_reading ) = @$rec;
|
||||
} else {
|
||||
$error = "TRX_SECURITY: x10_devtype wrong for subtype=$subtype";
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_SECURITY_parse_X10Sec() ".$error;
|
||||
return "";
|
||||
}
|
||||
} else {
|
||||
$error = "TRX_SECURITY: error undefined subtype=$subtype";
|
||||
Log 1, $error;
|
||||
Log3 $hash, 1, "TRX_SECURITY_parse_X10Sec() ".$error;
|
||||
return "";
|
||||
}
|
||||
|
||||
#--------------
|
||||
my $device_name = "TRX".$DOT.$dev_type.$DOT.$device;
|
||||
Log 4, "device_name=$device_name";
|
||||
Log3 $hash, 5, "TRX_SECURITY_parse_X10Sec() device_name=$device_name";
|
||||
|
||||
my $firstdevice = 1;
|
||||
my $def = $modules{TRX_SECURITY}{defptr}{$device_name};
|
||||
@@ -336,8 +335,8 @@ sub TRX_SECURITY_parse_X10Sec {
|
||||
$firstdevice = 0;
|
||||
$def = $modules{TRX_SECURITY}{defptr2}{$device_name};
|
||||
if (!$def) {
|
||||
Log 1, "UNDEFINED $device_name TRX_SECURITY $dev_type $device $dev_reading";
|
||||
Log 3, "TRX_SECURITY: TRX_SECURITY Unknown device $device_name, please define it";
|
||||
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";
|
||||
return "UNDEFINED $device_name TRX_SECURITY $dev_type $device $dev_reading";
|
||||
}
|
||||
}
|
||||
@@ -407,7 +406,7 @@ sub TRX_SECURITY_parse_X10Sec {
|
||||
$command = $rec;
|
||||
}
|
||||
} else {
|
||||
Log 1, "TRX_SECURITY: undefined command cmd=$data device-nr=$device, hex=$hexdata";
|
||||
Log3 $hash, 1, "TRX_SECURITY_parse_X10Sec() undefined command cmd=$data device-nr=$device, hex=$hexdata";
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -416,18 +415,18 @@ sub TRX_SECURITY_parse_X10Sec {
|
||||
if ($battery_level == 0x9) { $battery = 'batt_ok'}
|
||||
elsif ($battery_level == 0x0) { $battery = 'batt_low'}
|
||||
else {
|
||||
Log 1,"TRX_SECURITY: X10Sec unkown battery_level=$battery_level";
|
||||
Log3 $hash, 1,"TRX_SECURITY_parse_X10Sec() unkown battery_level=$battery_level";
|
||||
}
|
||||
}
|
||||
|
||||
if ($trx_rssi == 1) {
|
||||
$rssi = sprintf("%d", ($bytes->[7] & 0xf0) >> 4);
|
||||
#Log 1, "TRX_SECURITY: $name devn=$device_name rssi=$rssi";
|
||||
Log3 $hash, 5, "TRX_SECURITY_parse_X10Sec() $name devn=$device_name rssi=$rssi";
|
||||
}
|
||||
|
||||
my $current = "";
|
||||
|
||||
Log 1, "TRX_SECURITY: $name devn=$device_name first=$firstdevice subtype=$subtype command=$command, delay=$delay, batt=$battery cmd=$hexdata" if ($TRX_SECURITY_debug == 1);
|
||||
Log3 $hash, 5, "TRX_SECURITY_parse_X10Sec() $name devn=$device_name first=$firstdevice subtype=$subtype command=$command, delay=$delay, batt=$battery cmd=$hexdata";
|
||||
|
||||
|
||||
my $n = 0;
|
||||
@@ -532,17 +531,17 @@ TRX_SECURITY_Parse($$)
|
||||
$trx_rssi = 0;
|
||||
if (defined($attr{$iohash->{NAME}}{rssi})) {
|
||||
$trx_rssi = $attr{$iohash->{NAME}}{rssi};
|
||||
#Log 1,"TRX_SECURITY_Parse: attr rssi = $trx_rssi";
|
||||
Log3 $iohash, 5,"TRX_SECURITY_Parse() attr rssi = $trx_rssi";
|
||||
}
|
||||
|
||||
my $time = time();
|
||||
# convert to binary
|
||||
my $msg = pack('H*', $hexline);
|
||||
if ($time_old ==0) {
|
||||
Log 5, "TRX_SECURITY: decoding delay=0 hex=$hexline";
|
||||
Log3 $iohash, 5, "TRX_SECURITY_Parse() decoding delay=0 hex=$hexline";
|
||||
} else {
|
||||
my $time_diff = $time - $time_old ;
|
||||
Log 5, "TRX_SECURITY: decoding delay=$time_diff hex=$hexline";
|
||||
Log3 $iohash, 5, "TRX_SECURITY_Parse() decoding delay=$time_diff hex=$hexline";
|
||||
}
|
||||
$time_old = $time;
|
||||
|
||||
@@ -560,15 +559,15 @@ TRX_SECURITY_Parse($$)
|
||||
|
||||
my $type = $rfxcom_data_array[0];
|
||||
|
||||
#Log 1, "TRX_SECURITY: X10Sec num_bytes=$num_bytes hex=$hexline type=$type" if ($TRX_SECURITY_debug == 1);
|
||||
Log3 $iohash, 5, "TRX_SECURITY_Parse() X10Sec num_bytes=$num_bytes hex=$hexline type=$type";
|
||||
my $res = "";
|
||||
if ($type == 0x20) {
|
||||
Log 1, "TRX_SECURITY: X10Sec num_bytes=$num_bytes hex=$hexline" if ($TRX_SECURITY_debug == 1);
|
||||
$res = TRX_SECURITY_parse_X10Sec(\@rfxcom_data_array);
|
||||
Log 1, "TRX_SECURITY: unsupported hex=$hexline" if ($res eq "");
|
||||
Log3 $iohash, 5, "TRX_SECURITY_Parse() X10Sec num_bytes=$num_bytes hex=$hexline";
|
||||
$res = TRX_SECURITY_parse_X10Sec($iohash, \@rfxcom_data_array);
|
||||
Log3 $iohash, 1, "TRX_SECURITY_Parse() unsupported hex=$hexline" if ($res eq "");
|
||||
return $res;
|
||||
} else {
|
||||
Log 0, "TRX_SECURITY: not implemented num_bytes=$num_bytes hex=$hexline";
|
||||
Log3 $iohash, 0, "TRX_SECURITY_Parse() not implemented num_bytes=$num_bytes hex=$hexline";
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
##################################
|
||||
#
|
||||
# values for "set global verbose"
|
||||
# 4: log unknown protocols
|
||||
# 4: log unknown prologtocols
|
||||
# 5: log decoding hexlines for debugging
|
||||
#
|
||||
package main;
|
||||
@@ -117,7 +117,6 @@ TRX_WEATHER_Initialize($)
|
||||
$hash->{UndefFn} = "TRX_WEATHER_Undef";
|
||||
$hash->{ParseFn} = "TRX_WEATHER_Parse";
|
||||
$hash->{AttrList} = "IODev ignore:1,0 do_not_notify:1,0 ".
|
||||
"loglevel:0,1,2,3,4,5,6 ".
|
||||
$readingFnAttributes;
|
||||
|
||||
}
|
||||
@@ -359,7 +358,6 @@ sub TRX_WEATHER_common_anemometer {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -375,14 +373,11 @@ sub TRX_WEATHER_common_anemometer {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_anemometer error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_anemometer error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
|
||||
#my $seqnbr = sprintf "%02x", $bytes->[2];
|
||||
#Log 1,"seqnbr=$seqnbr";
|
||||
|
||||
my $dev_str = $dev_type;
|
||||
if (TRX_WEATHER_use_longid($longids,$dev_type)) {
|
||||
$dev_str .= $DOT.sprintf("%02x", $bytes->[3]);
|
||||
@@ -437,7 +432,6 @@ sub TRX_WEATHER_common_temp {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -457,13 +451,12 @@ sub TRX_WEATHER_common_temp {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_temp error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_temp error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
|
||||
#my $seqnbr = sprintf "%02x", $bytes->[2];
|
||||
#Log 1,"seqnbr=$seqnbr";
|
||||
|
||||
my $dev_str = $dev_type;
|
||||
if (TRX_WEATHER_use_longid($longids,$dev_type)) {
|
||||
@@ -472,7 +465,6 @@ sub TRX_WEATHER_common_temp {
|
||||
if ($bytes->[4] > 0) {
|
||||
$dev_str .= $DOT.sprintf("%d", $bytes->[4]);
|
||||
}
|
||||
#Log 1,"dev_str=$dev_str";
|
||||
|
||||
my @res = ();
|
||||
|
||||
@@ -494,7 +486,6 @@ sub TRX_WEATHER_common_hydro {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -506,7 +497,7 @@ sub TRX_WEATHER_common_hydro {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_hydro error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_hydro error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
@@ -518,7 +509,6 @@ sub TRX_WEATHER_common_hydro {
|
||||
if ($bytes->[4] > 0) {
|
||||
$dev_str .= $DOT.sprintf("%d", $bytes->[4]);
|
||||
}
|
||||
#Log 1,"dev_str=$dev_str";
|
||||
|
||||
my @res = ();
|
||||
|
||||
@@ -540,7 +530,6 @@ sub TRX_WEATHER_common_temphydro {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -559,7 +548,7 @@ sub TRX_WEATHER_common_temphydro {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_temphydro error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_temphydro error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
@@ -568,24 +557,24 @@ sub TRX_WEATHER_common_temphydro {
|
||||
if (TRX_WEATHER_use_longid($longids,$dev_type)) {
|
||||
$dev_str .= $DOT.sprintf("%02x", $bytes->[3]);
|
||||
} elsif ($dev_type eq "TFATS34C") {
|
||||
#Log 1,"TRX_WEATHER: TFA";
|
||||
#Log3 undef, 1,"TRX_WEATHER: TFA";
|
||||
if ($bytes->[3] > 0x20 && $bytes->[3] <= 0x3F) {
|
||||
#Log 1,"TRX_WEATHER: TFA 1";
|
||||
#Log3 undef, 1,"TRX_WEATHER: TFA 1";
|
||||
$dev_str .= $DOT."1";
|
||||
} elsif ($bytes->[3] >= 0x40 && $bytes->[3] <= 0x5F) {
|
||||
#Log 1,"TRX_WEATHER: TFA 2";
|
||||
#Log3 undef, 1,"TRX_WEATHER: TFA 2";
|
||||
$dev_str .= $DOT."2";
|
||||
} elsif ($bytes->[3] >= 0x60 && $bytes->[3] <= 0x7F) {
|
||||
#Log 1,"TRX_WEATHER: TFA 3";
|
||||
#Log3 undef, 1,"TRX_WEATHER: TFA 3";
|
||||
$dev_str .= $DOT."3";
|
||||
} elsif ($bytes->[3] >= 0xA0 && $bytes->[3] <= 0xBF) {
|
||||
#Log 1,"TRX_WEATHER: TFA 4";
|
||||
#Log3 undef, 1,"TRX_WEATHER: TFA 4";
|
||||
$dev_str .= $DOT."4";
|
||||
} elsif ($bytes->[3] >= 0xC0 && $bytes->[3] <= 0xDF) {
|
||||
#Log 1,"TRX_WEATHER: TFA 5";
|
||||
#Log3 undef, 1,"TRX_WEATHER: TFA 5";
|
||||
$dev_str .= $DOT."5";
|
||||
} else {
|
||||
#Log 1,"TRX_WEATHER: TFA 9";
|
||||
#Log3 undef, 1,"TRX_WEATHER: TFA 9";
|
||||
$dev_str .= $DOT."9";
|
||||
}
|
||||
} elsif ($bytes->[4] > 0) {
|
||||
@@ -617,7 +606,6 @@ sub TRX_WEATHER_common_temphydrobaro {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -629,7 +617,7 @@ sub TRX_WEATHER_common_temphydrobaro {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_temphydrobaro error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_temphydrobaro error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
@@ -641,7 +629,6 @@ sub TRX_WEATHER_common_temphydrobaro {
|
||||
if ($bytes->[4] > 0) {
|
||||
$dev_str .= $DOT.sprintf("%d", $bytes->[4]);
|
||||
}
|
||||
#Log 1,"dev_str=$dev_str";
|
||||
|
||||
my @res = ();
|
||||
|
||||
@@ -666,7 +653,6 @@ sub TRX_WEATHER_common_rain {
|
||||
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -681,7 +667,7 @@ sub TRX_WEATHER_common_rain {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_rain error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_rain error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
@@ -751,7 +737,6 @@ sub TRX_WEATHER_common_uv {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -764,13 +749,12 @@ sub TRX_WEATHER_common_uv {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_uv error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_uv error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
|
||||
#my $seqnbr = sprintf "%02x", $bytes->[2];
|
||||
#Log 1,"seqnbr=$seqnbr";
|
||||
|
||||
my $dev_str = $dev_type;
|
||||
if (TRX_WEATHER_use_longid($longids,$dev_type)) {
|
||||
@@ -779,7 +763,6 @@ sub TRX_WEATHER_common_uv {
|
||||
if ($bytes->[4] > 0) {
|
||||
$dev_str .= $DOT.sprintf("%d", $bytes->[4]);
|
||||
}
|
||||
#Log 1,"dev_str=$dev_str";
|
||||
|
||||
my @res = ();
|
||||
|
||||
@@ -816,7 +799,6 @@ sub TRX_WEATHER_common_datetime {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -827,7 +809,7 @@ sub TRX_WEATHER_common_datetime {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_datetime error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_datetime error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
@@ -875,7 +857,6 @@ sub TRX_WEATHER_common_energy {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -887,13 +868,12 @@ sub TRX_WEATHER_common_energy {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_energy error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_energy error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
|
||||
#my $seqnbr = sprintf "%02x", $bytes->[2];
|
||||
#Log 1,"seqnbr=$seqnbr";
|
||||
|
||||
my $dev_str = $dev_type;
|
||||
$dev_str .= $DOT.sprintf("%02x%02x", $bytes->[3],$bytes->[4]);
|
||||
@@ -954,7 +934,6 @@ sub TRX_WEATHER_common_energy2 {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -965,13 +944,12 @@ sub TRX_WEATHER_common_energy2 {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_energy2 error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_energy2 error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
|
||||
#my $seqnbr = sprintf "%02x", $bytes->[2];
|
||||
#Log 1,"seqnbr=$seqnbr";
|
||||
|
||||
my $dev_str = $dev_type;
|
||||
$dev_str .= $DOT.sprintf("%02x%02x", $bytes->[3],$bytes->[4]);
|
||||
@@ -1045,7 +1023,6 @@ sub TRX_WEATHER_common_weight {
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
@@ -1057,13 +1034,12 @@ sub TRX_WEATHER_common_weight {
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_weight error undefined subtype=$subtype";
|
||||
Log3 undef, 3, "TRX_WEATHER: common_weight error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
|
||||
#my $seqnbr = sprintf "%02x", $bytes->[2];
|
||||
#Log 1,"seqnbr=$seqnbr";
|
||||
|
||||
my $dev_str = $dev_type;
|
||||
if (TRX_WEATHER_use_longid($longids,$dev_type)) {
|
||||
@@ -1104,28 +1080,28 @@ TRX_WEATHER_Parse($$)
|
||||
|
||||
#my $hashname = $iohash->{NAME};
|
||||
#my $longid = AttrVal($hashname,"longids","");
|
||||
#Log 1,"2: name=$hashname, attr longids = $longid";
|
||||
#Log3 $iohash, $iohash, 5 ,"2: name=$hashname, attr longids = $longid";
|
||||
|
||||
my $longids = 0;
|
||||
if (defined($attr{$iohash->{NAME}}{longids})) {
|
||||
$longids = $attr{$iohash->{NAME}}{longids};
|
||||
#Log 1,"0: attr longids = $longids";
|
||||
#Log3 $iohash, 5,"0: attr longids = $longids";
|
||||
}
|
||||
|
||||
$trx_rssi = 0;
|
||||
if (defined($attr{$iohash->{NAME}}{rssi})) {
|
||||
$trx_rssi = $attr{$iohash->{NAME}}{rssi};
|
||||
#Log 1,"0: attr rssi = $trx_rssi";
|
||||
#Log3 $iohash, 5, "0: attr rssi = $trx_rssi";
|
||||
}
|
||||
|
||||
my $time = time();
|
||||
# convert to binary
|
||||
my $msg = pack('H*', $hexline);
|
||||
if ($time_old ==0) {
|
||||
Log 5, "TRX_WEATHER: decoding delay=0 hex=$hexline";
|
||||
Log3 $iohash, 5, "TRX_WEATHER: decoding delay=0 hex=$hexline";
|
||||
} else {
|
||||
my $time_diff = $time - $time_old ;
|
||||
Log 5, "TRX_WEATHER: decoding delay=$time_diff hex=$hexline";
|
||||
Log3 $iohash, 5, "TRX_WEATHER: decoding delay=$time_diff hex=$hexline";
|
||||
}
|
||||
$time_old = $time;
|
||||
|
||||
@@ -1150,41 +1126,40 @@ TRX_WEATHER_Parse($$)
|
||||
my $rec = $types{$key};
|
||||
|
||||
unless ($rec) {
|
||||
Log 4, "TRX_WEATHER: ERROR: Unknown sensor_id=$sensor_id message='$hexline'";
|
||||
Log 1, "TRX_WEATHER: ERROR: Unknown sensor_id=$sensor_id message='$hexline'";
|
||||
Log3 $iohash, 1, "TRX_WEATHER: ERROR: Unknown sensor_id=$sensor_id message='$hexline'";
|
||||
return "";
|
||||
}
|
||||
|
||||
my $method = $rec->{method};
|
||||
unless ($method) {
|
||||
Log 4, "TRX_WEATHER: Possible message from Oregon part '$rec->{part}'";
|
||||
Log 4, "TRX_WEATHER: sensor_id=$sensor_id";
|
||||
Log3 $iohash, 4, "TRX_WEATHER: Possible message from Oregon part '$rec->{part}'";
|
||||
Log3 $iohash, 4, "TRX_WEATHER: sensor_id=$sensor_id";
|
||||
return;
|
||||
}
|
||||
|
||||
my @res;
|
||||
|
||||
if (! defined(&$method)) {
|
||||
Log 4, "TRX_WEATHER: Error: Unknown function=$method. Please define it in file $0";
|
||||
Log 4, "TRX_WEATHER: sensor_id=$sensor_id\n";
|
||||
Log3 $iohash, 4, "TRX_WEATHER: Error: Unknown function=$method. Please define it in file $0";
|
||||
Log3 $iohash, 4, "TRX_WEATHER: sensor_id=$sensor_id\n";
|
||||
return "";
|
||||
} else {
|
||||
#Log 1, "TRX_WEATHER: parsing sensor_id=$sensor_id message='$hexline'";
|
||||
Log3 $iohash, 5, "TRX_WEATHER: parsing sensor_id=$sensor_id message='$hexline'";
|
||||
@res = $method->($rec->{part}, $longids, \@rfxcom_data_array);
|
||||
}
|
||||
|
||||
# get device name from first entry
|
||||
my $device_name = $res[0]->{device};
|
||||
#Log 1, "device_name=$device_name";
|
||||
#Log3 $iohash, 5, "device_name=$device_name";
|
||||
|
||||
if (! defined($device_name)) {
|
||||
Log 4, "TRX_WEATHER: error device_name undefined\n";
|
||||
Log3 $iohash, 4, "TRX_WEATHER: error device_name undefined\n";
|
||||
return "";
|
||||
}
|
||||
|
||||
my $def = $modules{TRX_WEATHER}{defptr}{"$device_name"};
|
||||
if(!$def) {
|
||||
Log 3, "TRX_WEATHER: Unknown device $device_name, please define it";
|
||||
Log3 $iohash, 3, "TRX_WEATHER: Unknown device $device_name, please define it";
|
||||
return "UNDEFINED $device_name TRX_WEATHER $device_name";
|
||||
}
|
||||
# Use $def->{NAME}, because the device may be renamed:
|
||||
@@ -1203,28 +1178,28 @@ TRX_WEATHER_Parse($$)
|
||||
#print "!> i=".$i."\n";
|
||||
#printf "%s\t",$i->{device};
|
||||
if ($i->{type} eq "temp") {
|
||||
#printf "Temperatur %2.1f %s ; ",$i->{current},$i->{units};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." Temperatur ".$i->{current}." ".$i->{units};
|
||||
$val .= "T: ".$i->{current}." ";
|
||||
|
||||
$sensor = "temperature";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "chilltemp") {
|
||||
#printf "Temperatur %2.1f %s ; ",$i->{current},$i->{units};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." windchill ".$i->{current}." ".$i->{units};
|
||||
$val .= "CT: ".$i->{current}." ";
|
||||
|
||||
$sensor = "windchill";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "humidity") {
|
||||
#printf "Luftfeuchtigkeit %d%s, %s ;",$i->{current},$i->{units},$i->{string};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." Luftfeuchtigkeit ".$i->{current}.$i->{units};
|
||||
$val .= "H: ".$i->{current}." ";
|
||||
|
||||
$sensor = "humidity";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "battery") {
|
||||
#printf "Batterie %d%s; ",$i->{current},$i->{units};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." Batterie ".$i->{current};
|
||||
my $tmp_battery = $i->{current};
|
||||
my @words = split(/\s+/,$i->{current});
|
||||
$val .= "BAT: ".$words[0]." "; #use only first word
|
||||
@@ -1233,7 +1208,7 @@ TRX_WEATHER_Parse($$)
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "pressure") {
|
||||
#printf "Luftdruck %d %s, Vorhersage=%s ; ",$i->{current},$i->{units},$i->{forecast};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." Luftdruck ".$i->{current}." ".$i->{units}." Vorhersage=".$i->{forecast};
|
||||
# do not add it due to problems with hms.gplot
|
||||
$val .= "P: ".$i->{current}." ";
|
||||
|
||||
@@ -1244,6 +1219,7 @@ TRX_WEATHER_Parse($$)
|
||||
readingsBulkUpdate($def, $sensor, $i->{forecast});
|
||||
}
|
||||
elsif ($i->{type} eq "speed") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." wind_speed ".$i->{current}." wind_avspeed ".$i->{average};
|
||||
$val .= "W: ".$i->{current}." ";
|
||||
$val .= "WA: ".$i->{average}." ";
|
||||
|
||||
@@ -1254,6 +1230,7 @@ TRX_WEATHER_Parse($$)
|
||||
readingsBulkUpdate($def, $sensor, $i->{average});
|
||||
}
|
||||
elsif ($i->{type} eq "direction") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." wind_dir ".$i->{current}." ".$i->{string};
|
||||
$val .= "WD: ".$i->{current}." ";
|
||||
$val .= "WDN: ".$i->{string}." ";
|
||||
|
||||
@@ -1261,24 +1238,28 @@ TRX_WEATHER_Parse($$)
|
||||
readingsBulkUpdate($def, $sensor, $i->{current} . " " . $i->{string});
|
||||
}
|
||||
elsif ($i->{type} eq "rain") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." rain ".$i->{current};
|
||||
$val .= "RR: ".$i->{current}." ";
|
||||
|
||||
$sensor = "rain_rate";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "train") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." train ".$i->{current};
|
||||
$val .= "TR: ".$i->{current}." ";
|
||||
|
||||
$sensor = "rain_total";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "flip") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." flip ".$i->{current};
|
||||
$val .= "F: ".$i->{current}." ";
|
||||
|
||||
$sensor = "rain_flip";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "uv") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." uv_val ".$i->{current}." uv_risk ".$i->{risk};
|
||||
$val .= "UV: ".$i->{current}." ";
|
||||
$val .= "UVR: ".$i->{risk}." ";
|
||||
|
||||
@@ -1292,8 +1273,9 @@ TRX_WEATHER_Parse($$)
|
||||
my $energy_current = $i->{current};
|
||||
if (defined($def->{scale_current})) {
|
||||
$energy_current = $energy_current * $def->{scale_current};
|
||||
#Log 1,"scale_current=".$def->{scale_current};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." scale_current=".$def->{scale_current};
|
||||
}
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." energy_current=".$energy_current;
|
||||
$val .= "ECUR: ".$energy_current." ";
|
||||
|
||||
$sensor = "energy_current";
|
||||
@@ -1303,8 +1285,9 @@ TRX_WEATHER_Parse($$)
|
||||
my $energy_current = $i->{current};
|
||||
if (defined($def->{scale_current})) {
|
||||
$energy_current = $energy_current * $def->{scale_current};
|
||||
#Log 1,"scale_current=".$def->{scale_current};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." energy_ch1 scale_current=".$def->{scale_current};
|
||||
}
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." CH1 energy_current=".$energy_current;
|
||||
$val .= "CH1: ".$energy_current." ";
|
||||
|
||||
$sensor = "energy_ch1";
|
||||
@@ -1314,8 +1297,9 @@ TRX_WEATHER_Parse($$)
|
||||
my $energy_current = $i->{current};
|
||||
if (defined($def->{scale_current})) {
|
||||
$energy_current = $energy_current * $def->{scale_current};
|
||||
#Log 1,"scale_current=".$def->{scale_current};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." energy_ch2 scale_current=".$def->{scale_current};
|
||||
}
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." CH2 energy_current=".$energy_current;
|
||||
$val .= "CH2: ".$energy_current." ";
|
||||
|
||||
$sensor = "energy_ch2";
|
||||
@@ -1325,8 +1309,9 @@ TRX_WEATHER_Parse($$)
|
||||
my $energy_current = $i->{current};
|
||||
if (defined($def->{scale_current})) {
|
||||
$energy_current = $energy_current * $def->{scale_current};
|
||||
#Log 1,"scale_current=".$def->{scale_current};
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." energy_ch3 scale_current=".$def->{scale_current};
|
||||
}
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." CH3 energy_current=".$energy_current;
|
||||
$val .= "CH3: ".$energy_current." ";
|
||||
|
||||
$sensor = "energy_ch3";
|
||||
@@ -1336,42 +1321,45 @@ TRX_WEATHER_Parse($$)
|
||||
my $energy_total = $i->{current};
|
||||
if (defined($def->{scale_total}) && defined($def->{add_total})) {
|
||||
$energy_total = sprintf("%.4f",$energy_total * $def->{scale_total} + $def->{add_total});
|
||||
#Log 1,"scale_total=".$def->{scale_total};
|
||||
Log3 $iohash, 1, "TRX_WEATHER: device=".$device_name." energy_total scale_total=".$def->{scale_total};
|
||||
}
|
||||
#Log 1,"energy_total=".$energy_total;
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." energy_total=".$energy_total;
|
||||
$val .= "ESUM: ".$energy_total." ";
|
||||
|
||||
$sensor = "energy_total";
|
||||
readingsBulkUpdate($def, $sensor, $energy_total." ".$i->{units});
|
||||
}
|
||||
elsif ($i->{type} eq "weight") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." weight ".$i->{current};
|
||||
$val .= "W: ".$i->{current}." ";
|
||||
|
||||
$sensor = "weight";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "hexline") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: hexline=".$device_name." train ".$i->{current};
|
||||
$sensor = "hexline";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "rssi") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." rssi ".$i->{current};
|
||||
$sensor = "rssi";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "date") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." date ".$i->{current};
|
||||
$val .= $i->{current}." ";
|
||||
$sensor = "date";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "time") {
|
||||
Log3 $iohash, 5, "TRX_WEATHER: device=".$device_name." time ".$i->{current};
|
||||
$val .= $i->{current}." ";
|
||||
$sensor = "time";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
else {
|
||||
print "\nTRX_WEATHER: Unknown: ";
|
||||
print "Type: ".$i->{type}.", ";
|
||||
print "Value: ".$i->{current}."\n";
|
||||
Log3 $iohash, 1, "TRX_WEATHER: device=".$device_name. " UNKNOWN Type: ".$i->{type}." Value: ".$i->{current}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user