use readingsUpdate
git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@1992 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -99,7 +99,7 @@ TRX_LIGHT_Initialize($)
|
|||||||
$hash->{DefFn} = "TRX_LIGHT_Define";
|
$hash->{DefFn} = "TRX_LIGHT_Define";
|
||||||
$hash->{UndefFn} = "TRX_LIGHT_Undef";
|
$hash->{UndefFn} = "TRX_LIGHT_Undef";
|
||||||
$hash->{ParseFn} = "TRX_LIGHT_Parse";
|
$hash->{ParseFn} = "TRX_LIGHT_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 event-on-update-reading event-on-change-reading do_not_notify:1,0 loglevel:0,1,2,3,4,5,6";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,6 +447,8 @@ sub TRX_LIGHT_parse_X10 {
|
|||||||
$command = ($command eq "on") ? "dark" : "bright" ;
|
$command = ($command eq "on") ? "dark" : "bright" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readingsBeginUpdate($def);
|
||||||
|
|
||||||
if ($type == 0x10 || $type == 0x11) {
|
if ($type == 0x10 || $type == 0x11) {
|
||||||
# try to use it for all types:
|
# try to use it for all types:
|
||||||
$current = $command;
|
$current = $command;
|
||||||
@@ -458,9 +460,7 @@ sub TRX_LIGHT_parse_X10 {
|
|||||||
|
|
||||||
$sensor = $firstdevice == 1 ? $def->{TRX_LIGHT_devicelog} : $def->{TRX_LIGHT_devicelog2};
|
$sensor = $firstdevice == 1 ? $def->{TRX_LIGHT_devicelog} : $def->{TRX_LIGHT_devicelog2};
|
||||||
$val .= $current;
|
$val .= $current;
|
||||||
$def->{READINGS}{$sensor}{TIME} = $tm;
|
readingsUpdate($def, $sensor, $current);
|
||||||
$def->{READINGS}{$sensor}{VAL} = $current;
|
|
||||||
$def->{CHANGED}[$n++] = $sensor . ": " . $current;
|
|
||||||
} else {
|
} 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;
|
$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;
|
Log 1, $error;
|
||||||
@@ -469,13 +469,12 @@ sub TRX_LIGHT_parse_X10 {
|
|||||||
|
|
||||||
if (($firstdevice == 1) && $val) {
|
if (($firstdevice == 1) && $val) {
|
||||||
$def->{STATE} = $val;
|
$def->{STATE} = $val;
|
||||||
$def->{TIME} = $tm;
|
readingsUpdate($def, "state", $val);
|
||||||
$def->{CHANGED}[$n++] = $val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DoTrigger($name, undef);
|
readingsEndUpdate($def, 1);
|
||||||
|
|
||||||
return "";
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@@ -504,7 +503,7 @@ TRX_LIGHT_Parse($$)
|
|||||||
my $num_bytes = ord($msg);
|
my $num_bytes = ord($msg);
|
||||||
|
|
||||||
if ($num_bytes < 3) {
|
if ($num_bytes < 3) {
|
||||||
return;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $type = $rfxcom_data_array[0];
|
my $type = $rfxcom_data_array[0];
|
||||||
@@ -514,7 +513,7 @@ TRX_LIGHT_Parse($$)
|
|||||||
if ($type == 0x10 || $type == 0x11 || $type == 0x12) {
|
if ($type == 0x10 || $type == 0x11 || $type == 0x12) {
|
||||||
Log 1, "TRX_LIGHT: X10 num_bytes=$num_bytes hex=$hexline" if ($TRX_LIGHT_debug == 1);
|
Log 1, "TRX_LIGHT: X10 num_bytes=$num_bytes hex=$hexline" if ($TRX_LIGHT_debug == 1);
|
||||||
$res = TRX_LIGHT_parse_X10(\@rfxcom_data_array);
|
$res = TRX_LIGHT_parse_X10(\@rfxcom_data_array);
|
||||||
Log 1, "TRX_LIGHT: unsupported hex=$hexline" if ($res ne "" && $res !~ /^UNDEFINED.*/);
|
Log 1, "TRX_LIGHT: unsupported hex=$hexline" if ($res eq "");
|
||||||
return $res;
|
return $res;
|
||||||
} else {
|
} else {
|
||||||
Log 0, "TRX_LIGHT: not implemented num_bytes=$num_bytes hex=$hexline";
|
Log 0, "TRX_LIGHT: not implemented num_bytes=$num_bytes hex=$hexline";
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ 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 loglevel:0,1,2,3,4,5,6";
|
$hash->{AttrList} = "IODev ignore:1,0 event-on-update-reading event-on-change-reading do_not_notify:1,0 loglevel:0,1,2,3,4,5,6";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,16 +160,14 @@ sub TRX_SECURITY_parse_X10Sec {
|
|||||||
} else {
|
} else {
|
||||||
$error = "TRX_SECURITY: x10_devtype wrong for subtype=$subtype";
|
$error = "TRX_SECURITY: x10_devtype wrong for subtype=$subtype";
|
||||||
Log 1, $error;
|
Log 1, $error;
|
||||||
return $error;
|
return "";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$error = "TRX_SECURITY: error undefined subtype=$subtype";
|
$error = "TRX_SECURITY: error undefined subtype=$subtype";
|
||||||
Log 1, $error;
|
Log 1, $error;
|
||||||
return $error;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
#Log 4, "device_type=$device_type";
|
|
||||||
|
|
||||||
#--------------
|
#--------------
|
||||||
my $device_name = "TRX".$DOT.$dev_type.$DOT.$device;
|
my $device_name = "TRX".$DOT.$dev_type.$DOT.$device;
|
||||||
Log 4, "device_name=$device_name";
|
Log 4, "device_name=$device_name";
|
||||||
@@ -182,7 +180,7 @@ sub TRX_SECURITY_parse_X10Sec {
|
|||||||
if (!$def) {
|
if (!$def) {
|
||||||
Log 1, "UNDEFINED $device_name TRX_SECURITY $dev_type $device $dev_reading";
|
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";
|
Log 3, "TRX_SECURITY: TRX_SECURITY Unknown device $device_name, please define it";
|
||||||
return "UNDEFINED $device_name TRX_SECURITY $dev_type $device $dev_reading";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,8 +240,8 @@ sub TRX_SECURITY_parse_X10Sec {
|
|||||||
$command = $rec;
|
$command = $rec;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log 1, "TRX_SECURITY undefined command cmd=$data device-nr=$device, hex=$hexdata";
|
Log 1, "TRX_SECURITY: undefined command cmd=$data device-nr=$device, hex=$hexdata";
|
||||||
return "TRX_SECURITY undefined command";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $battery_level = $bytes->[7] & 0x0f;
|
my $battery_level = $bytes->[7] & 0x0f;
|
||||||
@@ -251,7 +249,7 @@ sub TRX_SECURITY_parse_X10Sec {
|
|||||||
if ($battery_level == 0x9) { $battery = 'batt_ok'}
|
if ($battery_level == 0x9) { $battery = 'batt_ok'}
|
||||||
elsif ($battery_level == 0x0) { $battery = 'batt_low'}
|
elsif ($battery_level == 0x0) { $battery = 'batt_low'}
|
||||||
else {
|
else {
|
||||||
Log 1,"TRX-X10: X10Sec unkown battery_level=$battery_level";
|
Log 1,"TRX_SECURITY: X10Sec unkown battery_level=$battery_level";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,19 +278,17 @@ sub TRX_SECURITY_parse_X10Sec {
|
|||||||
$current = "Closed" if ($command eq "normal");
|
$current = "Closed" if ($command eq "normal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readingsBeginUpdate($def);
|
||||||
|
|
||||||
if (($dev_type ne "kr18") || ($dev_type ne "VISONIC_REMOTE")) {
|
if (($dev_type ne "kr18") || ($dev_type ne "VISONIC_REMOTE")) {
|
||||||
if ($firstdevice == 1) {
|
if ($firstdevice == 1) {
|
||||||
$val .= $current;
|
$val .= $current;
|
||||||
}
|
}
|
||||||
$def->{READINGS}{$sensor}{TIME} = $tm;
|
readingsUpdate($def, $sensor, $current);
|
||||||
$def->{READINGS}{$sensor}{VAL} = $current;
|
|
||||||
$def->{CHANGED}[$n++] = $sensor . ": " . $current;
|
|
||||||
|
|
||||||
if (($def->{STATE} ne $val)) {
|
if (($def->{STATE} ne $val)) {
|
||||||
$sensor = "statechange";
|
$sensor = "statechange";
|
||||||
$def->{READINGS}{$sensor}{TIME} = $tm;
|
readingsUpdate($def, $sensor, $current);
|
||||||
$def->{READINGS}{$sensor}{VAL} = $current;
|
|
||||||
$def->{CHANGED}[$n++] = $sensor . ": " . $current;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
# kr18 remote control or VISONIC_REMOTE
|
# kr18 remote control or VISONIC_REMOTE
|
||||||
@@ -300,16 +296,12 @@ sub TRX_SECURITY_parse_X10Sec {
|
|||||||
|
|
||||||
#$sensor = $def->{TRX_SECURITY_devicelog};
|
#$sensor = $def->{TRX_SECURITY_devicelog};
|
||||||
$val = $current;
|
$val = $current;
|
||||||
#$def->{READINGS}{$sensor}{TIME} = $tm;
|
readingsUpdate($def, $sensor, $current);
|
||||||
#$def->{READINGS}{$sensor}{VAL} = $current;
|
|
||||||
#$def->{CHANGED}[$n++] = $sensor . ": " . $current;
|
|
||||||
|
|
||||||
my @cmd_split = split(/-/, $command);
|
my @cmd_split = split(/-/, $command);
|
||||||
$sensor = $cmd_split[0];
|
$sensor = $cmd_split[0];
|
||||||
$current = $cmd_split[1];
|
$current = $cmd_split[1];
|
||||||
$def->{READINGS}{$sensor}{TIME} = $tm;
|
readingsUpdate($def, $sensor, $current);
|
||||||
$def->{READINGS}{$sensor}{VAL} = $current;
|
|
||||||
$def->{CHANGED}[$n++] = $sensor . ": " . $current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($battery ne "") {
|
if ($battery ne "") {
|
||||||
@@ -317,9 +309,7 @@ sub TRX_SECURITY_parse_X10Sec {
|
|||||||
$current = "Error";
|
$current = "Error";
|
||||||
$current = "ok" if ($battery eq "batt_ok");
|
$current = "ok" if ($battery eq "batt_ok");
|
||||||
$current = "low" if ($battery eq "batt_low");
|
$current = "low" if ($battery eq "batt_low");
|
||||||
$def->{READINGS}{$sensor}{TIME} = $tm;
|
readingsUpdate($def, $sensor, $current);
|
||||||
$def->{READINGS}{$sensor}{VAL} = $current;
|
|
||||||
$def->{CHANGED}[$n++] = $sensor . ": " . $current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($delay ne '') {
|
if ($delay ne '') {
|
||||||
@@ -327,20 +317,17 @@ sub TRX_SECURITY_parse_X10Sec {
|
|||||||
$current = "Error";
|
$current = "Error";
|
||||||
$current = "min" if ($delay eq "min_delay");
|
$current = "min" if ($delay eq "min_delay");
|
||||||
$current = "max" if ($delay eq "max_delay");
|
$current = "max" if ($delay eq "max_delay");
|
||||||
$def->{READINGS}{$sensor}{TIME} = $tm;
|
readingsUpdate($def, $sensor, $current);
|
||||||
$def->{READINGS}{$sensor}{VAL} = $current;
|
|
||||||
$def->{CHANGED}[$n++] = $sensor . ": " . $current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($firstdevice == 1) && $val) {
|
if (($firstdevice == 1) && $val) {
|
||||||
$def->{STATE} = $val;
|
$def->{STATE} = $val;
|
||||||
$def->{TIME} = $tm;
|
readingsUpdate($def, "state", $val);
|
||||||
$def->{CHANGED}[$n++] = $val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DoTrigger($name, undef);
|
readingsEndUpdate($def, 1);
|
||||||
|
|
||||||
return "";
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -369,7 +356,7 @@ TRX_SECURITY_Parse($$)
|
|||||||
my $num_bytes = ord($msg);
|
my $num_bytes = ord($msg);
|
||||||
|
|
||||||
if ($num_bytes < 3) {
|
if ($num_bytes < 3) {
|
||||||
return;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $type = $rfxcom_data_array[0];
|
my $type = $rfxcom_data_array[0];
|
||||||
@@ -379,7 +366,7 @@ TRX_SECURITY_Parse($$)
|
|||||||
if ($type == 0x20) {
|
if ($type == 0x20) {
|
||||||
Log 1, "TRX_SECURITY: X10Sec num_bytes=$num_bytes hex=$hexline" if ($TRX_SECURITY_debug == 1);
|
Log 1, "TRX_SECURITY: X10Sec num_bytes=$num_bytes hex=$hexline" if ($TRX_SECURITY_debug == 1);
|
||||||
$res = TRX_SECURITY_parse_X10Sec(\@rfxcom_data_array);
|
$res = TRX_SECURITY_parse_X10Sec(\@rfxcom_data_array);
|
||||||
Log 1, "TRX_SECURITY: unsupported hex=$hexline" if ($res ne "" && $res !~ /^UNDEFINED.*/);
|
Log 1, "TRX_SECURITY: unsupported hex=$hexline" if ($res eq "");
|
||||||
return $res;
|
return $res;
|
||||||
} else {
|
} else {
|
||||||
Log 0, "TRX_SECURITY: not implemented num_bytes=$num_bytes hex=$hexline";
|
Log 0, "TRX_SECURITY: not implemented num_bytes=$num_bytes hex=$hexline";
|
||||||
|
|||||||
Reference in New Issue
Block a user