mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
rssi, RTGR328N datetime
git-svn-id: https://svn.fhem.de/fhem/trunk@3290 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
3769f9f065
commit
6e23c7df51
@ -5,7 +5,7 @@
|
||||
#
|
||||
# Derived from 00_CUL.pm: Copyright (C) Rudolf Koenig"
|
||||
#
|
||||
# Copyright (C) 2012 Willi Herzig
|
||||
# Copyright (C) 2012/2013 Willi Herzig
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -33,6 +33,7 @@ use Time::HiRes qw(gettimeofday);
|
||||
|
||||
my $last_rmsg = "abcd";
|
||||
my $last_time = 1;
|
||||
my $trx_rssi = 0;
|
||||
|
||||
sub TRX_Clear($);
|
||||
sub TRX_Read($);
|
||||
@ -53,10 +54,10 @@ TRX_Initialize($)
|
||||
$hash->{Clients} =
|
||||
":TRX_WEATHER:TRX_SECURITY:TRX_LIGHT:TRX_ELSE:";
|
||||
my %mc = (
|
||||
"1:TRX_WEATHER" => "^..(50|51|52|54|55|56|57|5a|5d).*",
|
||||
"1:TRX_WEATHER" => "^..(50|51|52|54|55|56|57|58|5a|5d).*",
|
||||
"2:TRX_SECURITY" => "^..(20).*",
|
||||
"3:TRX_LIGHT" => "^..(10|11|12|13|14).*",
|
||||
"4:TRX_ELSE" => "^..(0[0-f]|1[5-f]|2[1-f]|3[0-f]|4[0-f]|53|58|59|5b|5c|5e|5f|[6-f][0-f]).*",
|
||||
"4:TRX_ELSE" => "^..(0[0-f]|1[5-f]|2[1-f]|3[0-f]|4[0-f]|53|59|5b|5c|5e|5f|[6-f][0-f]).*",
|
||||
);
|
||||
$hash->{MatchList} = \%mc;
|
||||
|
||||
@ -67,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 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 loglevel:0,1,2,3,4,5,6";
|
||||
$hash->{ShutdownFn} = "TRX_Shutdown";
|
||||
}
|
||||
|
||||
@ -101,8 +102,7 @@ TRX_Define($$)
|
||||
return "wrong syntax: define <name> TRX devicename [noinit]"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$hash->{DeviceName} = $dev;
|
||||
my $ret = DevIo_OpenDev($hash, 0, "TRX_DoInit");
|
||||
return $ret;
|
||||
@ -485,6 +485,16 @@ attr RFXTRXUSB longids BTHR918N
|
||||
# Will generate devices names like TX3_T_07, TX3_T_01 ,TX3_H_07.
|
||||
attr RFXTRXUSB longids TX3_T,TX3_H</PRE>
|
||||
</li><br>
|
||||
<li>rssi<br>
|
||||
1: enable RSSI logging, 0: disable RSSI logging<br>
|
||||
Default is no RSSI logging.
|
||||
<br><br>
|
||||
Examples:<PRE>
|
||||
# Do log rssi values (this is default):
|
||||
attr RFXCOMUSB rssi 0
|
||||
# Enable rssi logging for devices:
|
||||
attr RFXCOMUSB rssi 1
|
||||
</li><br>
|
||||
</ul>
|
||||
<br>
|
||||
</ul>
|
||||
|
@ -44,7 +44,7 @@ TRX_ELSE_Initialize($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
$hash->{Match} = "^..(0[0-f]|1[5-f]|2[1-f]|3[0-f]|4[0-f]|53|58|59|5b|5c|5e|5f|[6-f][0-f]).*";
|
||||
$hash->{Match} = "^..(0[0-f]|1[5-f]|2[1-f]|3[0-f]|4[0-f]|53|59|5b|5c|5e|5f|[6-f][0-f]).*";
|
||||
$hash->{DefFn} = "TRX_ELSE_Define";
|
||||
$hash->{UndefFn} = "TRX_ELSE_Undef";
|
||||
$hash->{ParseFn} = "TRX_ELSE_Parse";
|
||||
|
@ -4,7 +4,7 @@
|
||||
# 46_TRX_SECURITY.pm
|
||||
# FHEM module for X10, KD101, Visonic
|
||||
#
|
||||
# Copyright (C) 2012 Willi Herzig
|
||||
# Copyright (C) 2012/2013 Willi Herzig
|
||||
#
|
||||
# This file is part of fhem.
|
||||
#
|
||||
@ -37,6 +37,7 @@ use warnings;
|
||||
my $TRX_SECURITY_debug = 0;
|
||||
|
||||
my $time_old = 0;
|
||||
my $trx_rssi;
|
||||
|
||||
my $TRX_SECURITY_type_default = "ds10a";
|
||||
|
||||
@ -395,6 +396,7 @@ sub TRX_SECURITY_parse_X10Sec {
|
||||
my $type = "";
|
||||
my $delay = "";
|
||||
my $battery = "";
|
||||
my $rssi = "";
|
||||
my $option = "";
|
||||
my @res;
|
||||
if (exists $x10_security{$data}) {
|
||||
@ -418,6 +420,11 @@ sub TRX_SECURITY_parse_X10Sec {
|
||||
}
|
||||
}
|
||||
|
||||
if ($trx_rssi == 1) {
|
||||
$rssi = sprintf("%d", ($bytes->[7] & 0xf0) >> 4);
|
||||
#Log 1, "TRX_SECURITY: $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);
|
||||
@ -489,6 +496,12 @@ sub TRX_SECURITY_parse_X10Sec {
|
||||
readingsBulkUpdate($def, $sensor, $current);
|
||||
}
|
||||
|
||||
if ($rssi ne "") {
|
||||
$sensor = "rssi";
|
||||
readingsBulkUpdate($def, $sensor, $rssi);
|
||||
}
|
||||
|
||||
|
||||
if ($delay ne '') {
|
||||
$sensor = "delay";
|
||||
$current = "Error";
|
||||
@ -516,6 +529,12 @@ TRX_SECURITY_Parse($$)
|
||||
{
|
||||
my ($iohash, $hexline) = @_;
|
||||
|
||||
$trx_rssi = 0;
|
||||
if (defined($attr{$iohash->{NAME}}{rssi})) {
|
||||
$trx_rssi = $attr{$iohash->{NAME}}{rssi};
|
||||
#Log 1,"TRX_SECURITY_Parse: attr rssi = $trx_rssi";
|
||||
}
|
||||
|
||||
my $time = time();
|
||||
# convert to binary
|
||||
my $msg = pack('H*', $hexline);
|
||||
|
@ -57,6 +57,9 @@
|
||||
# "UVN800" is Oregon UVN800
|
||||
# "TFA_UV" is TFA_UV-Sensor
|
||||
#
|
||||
# Date/Time Sensors:
|
||||
# * "RTGR328_DATE" is RTGR328N
|
||||
#
|
||||
# Energy Sensors:
|
||||
# * "CM160" is OWL CM119, CM160
|
||||
# * "CM180" is OWL CM180
|
||||
@ -100,13 +103,14 @@ use warnings;
|
||||
my $TRX_HEX_debug = 0;
|
||||
|
||||
my $time_old = 0;
|
||||
my $trx_rssi;
|
||||
|
||||
sub
|
||||
TRX_WEATHER_Initialize($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
|
||||
$hash->{Match} = "^..(50|51|52|54|55|56|57|5a|5d).*";
|
||||
$hash->{Match} = "^..(50|51|52|54|55|56|57|58|5a|5d).*";
|
||||
$hash->{DefFn} = "TRX_WEATHER_Define";
|
||||
$hash->{UndefFn} = "TRX_WEATHER_Undef";
|
||||
$hash->{ParseFn} = "TRX_WEATHER_Parse";
|
||||
@ -176,6 +180,8 @@ my %types =
|
||||
0x5610 => { part => 'WIND', method => \&TRX_WEATHER_common_anemometer, },
|
||||
# UV
|
||||
0x5709 => { part => 'UV', method => \&TRX_WEATHER_common_uv, },
|
||||
# Date/Time sensors
|
||||
0x580D => { part => 'DATE', method => \&TRX_WEATHER_common_datetime, },
|
||||
# Energy usage sensors
|
||||
0x5A11 => { part => 'ENERGY', method => \&TRX_WEATHER_common_energy, },
|
||||
# WEIGHT
|
||||
@ -281,6 +287,17 @@ sub TRX_WEATHER_simple_battery {
|
||||
type => 'battery',
|
||||
current => $battery,
|
||||
};
|
||||
|
||||
my $rssi = ($bytes->[$off] & 0xf0) >> 4;
|
||||
|
||||
if ($trx_rssi == 1) {
|
||||
push @$res, {
|
||||
device => $dev,
|
||||
type => 'rssi',
|
||||
current => sprintf("%d",$rssi),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub TRX_WEATHER_battery {
|
||||
@ -301,6 +318,17 @@ sub TRX_WEATHER_battery {
|
||||
type => 'battery',
|
||||
current => $battery,
|
||||
};
|
||||
|
||||
my $rssi = ($bytes->[$off] & 0xf0) >> 4;
|
||||
|
||||
if ($trx_rssi == 1) {
|
||||
push @$res, {
|
||||
device => $dev,
|
||||
type => 'rssi',
|
||||
current => sprintf("%d",$rssi),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -319,6 +347,7 @@ sub TRX_WEATHER_use_longid {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
#
|
||||
sub TRX_WEATHER_common_anemometer {
|
||||
@ -752,6 +781,63 @@ sub TRX_WEATHER_common_uv {
|
||||
return @res;
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------
|
||||
#
|
||||
sub TRX_WEATHER_common_datetime {
|
||||
my $type = shift;
|
||||
my $longids = shift;
|
||||
my $bytes = shift;
|
||||
|
||||
my $subtype = sprintf "%02x", $bytes->[1];
|
||||
#Log 1,"subtype=$subtype";
|
||||
my $dev_type;
|
||||
|
||||
my %devname =
|
||||
( # HEXSTRING => "NAME"
|
||||
0x01 => "RTGR328_DATE", # RTGR328N datetime datagram
|
||||
);
|
||||
|
||||
if (exists $devname{$bytes->[1]}) {
|
||||
$dev_type = $devname{$bytes->[1]};
|
||||
} else {
|
||||
Log 1,"TRX_WEATHER: common_datetime error undefined subtype=$subtype";
|
||||
my @res = ();
|
||||
return @res;
|
||||
}
|
||||
|
||||
my $dev_str = $dev_type;
|
||||
if (TRX_WEATHER_use_longid($longids,$dev_type)) {
|
||||
$dev_str .= $DOT.sprintf("%02x%02x", $bytes->[3],$bytes->[4]);
|
||||
}
|
||||
|
||||
my @res = ();
|
||||
|
||||
# hexline debugging
|
||||
if ($TRX_HEX_debug) {
|
||||
my $hexline = ""; for (my $i=0;$i<@$bytes;$i++) { $hexline .= sprintf("%02x",$bytes->[$i]);}
|
||||
push @res, { device => $dev_str, type => 'hexline', current => $hexline, units => 'hex', };
|
||||
}
|
||||
|
||||
push @res, {
|
||||
device => $dev_str,
|
||||
type => 'date',
|
||||
current => sprintf("%02d-%02d-%02d", $bytes->[5],$bytes->[6],$bytes->[7]),
|
||||
units => 'yymmdd',
|
||||
};
|
||||
|
||||
push @res, {
|
||||
device => $dev_str,
|
||||
type => 'time',
|
||||
current => sprintf("%02d:%02d:%02d", $bytes->[9],$bytes->[10],$bytes->[11]),
|
||||
units => 'hhmmss',
|
||||
};
|
||||
|
||||
TRX_WEATHER_simple_battery($bytes, $dev_str, \@res, 12);
|
||||
|
||||
return @res;
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
#
|
||||
sub TRX_WEATHER_common_energy {
|
||||
@ -829,6 +915,7 @@ sub TRX_WEATHER_common_energy {
|
||||
return @res;
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
#
|
||||
sub TRX_WEATHER_common_weight {
|
||||
@ -904,6 +991,12 @@ TRX_WEATHER_Parse($$)
|
||||
#Log 1,"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";
|
||||
}
|
||||
|
||||
my $time = time();
|
||||
# convert to binary
|
||||
my $msg = pack('H*', $hexline);
|
||||
@ -1106,6 +1199,20 @@ TRX_WEATHER_Parse($$)
|
||||
$sensor = "hexline";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "rssi") {
|
||||
$sensor = "rssi";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "date") {
|
||||
$val .= $i->{current}." ";
|
||||
$sensor = "date";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
elsif ($i->{type} eq "time") {
|
||||
$val .= $i->{current}." ";
|
||||
$sensor = "time";
|
||||
readingsBulkUpdate($def, $sensor, $i->{current});
|
||||
}
|
||||
else {
|
||||
print "\nTRX_WEATHER: Unknown: ";
|
||||
print "Type: ".$i->{type}.", ";
|
||||
|
Loading…
Reference in New Issue
Block a user