mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-12 22:56:34 +00:00
FHT sending added to CUL
git-svn-id: https://svn.fhem.de/fhem/trunk@378 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c2b24391c4
commit
800a10a557
@ -499,3 +499,4 @@
|
||||
- feature: FHEMWEB modules added
|
||||
- feature: holiday module + doc + example + holiday2we attribute
|
||||
- bugfix: sunrise stuff fixed, doc missing
|
||||
- feature: CUL FHT sending added
|
||||
|
@ -77,15 +77,18 @@ CUL_Define($$)
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
my $po;
|
||||
|
||||
return "wrong syntax: define <name> CUL devicename [mobile]"
|
||||
if(@a < 3 || @a > 4);
|
||||
return "wrong syntax: define <name> CUL devicename <FHTID> [mobile]"
|
||||
if(@a < 4 || @a > 5);
|
||||
|
||||
delete $hash->{PortObj};
|
||||
delete $hash->{FD};
|
||||
|
||||
my $name = $a[0];
|
||||
my $dev = $a[2];
|
||||
$hash->{MOBILE} = 1 if($a[3] && $a[3] eq "mobile");
|
||||
return "FHTID must be H1H2, with H1 and H2 hex and both smaller than 64"
|
||||
if($a[3] !~ m/^[0-6]\d[0-6]\d$/);
|
||||
$hash->{FHTID} = uc($a[3]);
|
||||
$hash->{MOBILE} = 1 if($a[4] && $a[4] eq "mobile");
|
||||
$hash->{STATE} = "defined";
|
||||
|
||||
$attr{$name}{savefirst} = 1;
|
||||
@ -460,6 +463,19 @@ CUL_DoInit($)
|
||||
}
|
||||
|
||||
CUL_SimpleWrite($hash, $initstr);
|
||||
|
||||
# FHTID
|
||||
my $fhtid;
|
||||
CUL_SimpleWrite($hash, "T01");
|
||||
($err, $fhtid) = CUL_ReadAnswer($hash, "FHTID", 0);
|
||||
return "$name: $err" if($err);
|
||||
$fhtid =~ s/[\r\n]//g;
|
||||
Log 5, "GOT CUL fhtid: $fhtid";
|
||||
if(!defined($fhtid) || $fhtid ne $hash->{FHTID}) {
|
||||
Log 2, "Setting CUL fhtid to " . $hash->{FHTID};
|
||||
CUL_SimpleWrite($hash, "T01" . $hash->{FHTID});
|
||||
}
|
||||
|
||||
$hash->{STATE} = "Initialized";
|
||||
|
||||
# Reset the counter
|
||||
@ -558,6 +574,19 @@ CUL_Write($$$)
|
||||
} elsif($fn eq "04" && substr($msg,0,6) eq "010101") { # FS20
|
||||
$fn = "F";
|
||||
$msg = substr($msg,6);
|
||||
} elsif($fn eq "04" && substr($msg,0,6) eq "020183") { # FHT
|
||||
|
||||
my $moff = 10;
|
||||
Log 1, "Parse: $msg";
|
||||
while(length($msg) > $moff) {
|
||||
my $snd = substr($msg,6,4) .
|
||||
substr($msg,$moff,2) . "79" . substr($msg,$moff+2,2);
|
||||
Log 1, "Dumping: T$snd";
|
||||
$hash->{PortObj}->write("T$snd\n");
|
||||
$moff += 4;
|
||||
}
|
||||
return;
|
||||
|
||||
} else {
|
||||
Log GetLogLevel($name,2), "CUL cannot translate $fn $msg";
|
||||
return;
|
||||
|
@ -412,12 +412,14 @@ FHT_Parse($$)
|
||||
|
||||
}
|
||||
|
||||
$cmd = "FHZ:$cmd" if(substr($msg,24,1) eq "7");
|
||||
|
||||
$def->{READINGS}{$cmd}{TIME} = $tn;
|
||||
$def->{READINGS}{$cmd}{VAL} = $val;
|
||||
if(substr($msg,24,1) eq "7") {
|
||||
$cmd = "FHZ:$cmd";
|
||||
} else {
|
||||
$def->{READINGS}{$cmd}{TIME} = $tn;
|
||||
$def->{READINGS}{$cmd}{VAL} = $val;
|
||||
$def->{STATE} = "$cmd: $val" if($cmd eq "measured-temp");
|
||||
}
|
||||
$def->{CHANGED}[0] = "$cmd: $val";
|
||||
$def->{STATE} = "$cmd: $val" if($cmd eq "measured-temp");
|
||||
|
||||
Log 4, "FHT $name $cmd: $val";
|
||||
|
||||
|
@ -96,7 +96,8 @@ KS300_Parse($$)
|
||||
"israining", "unknown1", "unknown2", "unknown3");
|
||||
my @sfx = ( "(counter)", "(l/m2)", "(km/h)", "(%)", "(Celsius)",
|
||||
"(yes/no)", "","","");
|
||||
|
||||
my %repchanged = ("rain"=>1, "wind"=>1, "humidity"=>1, "temperature"=>1,
|
||||
"israining"=>1);
|
||||
|
||||
# counter for the change hash
|
||||
my $n= 1; # 0 is STATE and will b explicitely set
|
||||
@ -194,12 +195,10 @@ KS300_Parse($$)
|
||||
# remember tsecs
|
||||
$r->{tsecs}{TIME} = $tm;
|
||||
$r->{tsecs}{VAL} = "$tsecs";
|
||||
$def->{CHANGED}[$n++] = "tsecs: $tsecs";
|
||||
|
||||
# remember rain_raw_adj
|
||||
$r->{rain_raw_adj}{TIME} = $tm;
|
||||
$r->{rain_raw_adj}{VAL} = $rain_raw_adj;
|
||||
$def->{CHANGED}[$n++] = "rain_raw_adj: $rain_raw_adj";
|
||||
|
||||
|
||||
# KS300 has a sensor which detects any drop of rain and immediately
|
||||
@ -238,7 +237,8 @@ KS300_Parse($$)
|
||||
$r->{$txt[$i]}{TIME} = $tm;
|
||||
$val = "$v[$i] $sfx[$i]";
|
||||
$r->{$txt[$i]}{VAL} = $val;
|
||||
$def->{CHANGED}[$n++] = "$txt[$i]: $val";
|
||||
$def->{CHANGED}[$n++] = "$txt[$i]: $val"
|
||||
if(defined($repchanged{$txt[$i]}));
|
||||
}
|
||||
|
||||
###################################
|
||||
|
@ -41,7 +41,7 @@ CUL_WS_Define($$)
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
return "wrong syntax: define <name> CUL_WS <code> [corr1...corr4]"
|
||||
if(int(@a) < 3 || int(@a) > 6);
|
||||
if(int(@a) < 3 || int(@a) > 7);
|
||||
$a[2] = lc($a[2]);
|
||||
return "Define $a[0]: wrong CODE format: valid is 1-8"
|
||||
if($a[2] !~ m/^[1-8]$/);
|
||||
|
@ -1,7 +1,6 @@
|
||||
FHEM:
|
||||
- Remote serial device via IP (for the FHZ1300 WLAN)
|
||||
- Common buffer for parallel use of two devices: CUL+FHZ, (WS300/EM1000PC?)
|
||||
- holiday database
|
||||
- fhem-to-fhem module
|
||||
- CUR built-in MENU creation support
|
||||
- Remove or reimplement repeater attribute (cul/fhz/doc)
|
||||
|
26
fhem/fhem.pl
26
fhem/fhem.pl
@ -151,7 +151,7 @@ my %defaultattr; # Default attributes
|
||||
my %intAt; # Internal at timer hash.
|
||||
my $nextat; # Time when next timer will be triggered.
|
||||
my $intAtCnt=0;
|
||||
my $cvsid = '$Id: fhem.pl,v 1.71 2009-05-23 07:32:08 rudolfkoenig Exp $';
|
||||
my $cvsid = '$Id: fhem.pl,v 1.72 2009-05-30 15:11:56 rudolfkoenig Exp $';
|
||||
my $namedef =
|
||||
"where <name> is either:\n" .
|
||||
"- a single device name\n" .
|
||||
@ -613,9 +613,15 @@ devspec2array($)
|
||||
if($l =~ m/(.*)=(.*)/) {
|
||||
my ($lattr,$re) = ($1, $2);
|
||||
if($knownattr{$lattr}) {
|
||||
foreach my $l (sort keys %defs) {
|
||||
push @ret, $l
|
||||
if($defs{$l}{$lattr} && (!$re || $defs{$l}{$lattr} =~ m/$re/));
|
||||
eval { # a bad regexp may shut down fhem.pl
|
||||
foreach my $l (sort keys %defs) {
|
||||
push @ret, $l
|
||||
if($defs{$l}{$lattr} && (!$re || $defs{$l}{$lattr} =~ m/$re/));
|
||||
}
|
||||
};
|
||||
if($@) {
|
||||
Log 1, "devspec2array $name: $@";
|
||||
return $name;
|
||||
}
|
||||
} else {
|
||||
foreach my $l (sort keys %attr) {
|
||||
@ -627,9 +633,15 @@ devspec2array($)
|
||||
next;
|
||||
}
|
||||
|
||||
if($l =~ m/[*\[\]^\$]/) { # Regexp
|
||||
push @ret, grep($_ =~ m/$l/, sort keys %defs);
|
||||
next;
|
||||
eval { # a bad regexp may shut down fhem.pl
|
||||
if($l =~ m/[*\[\]^\$]/) { # Regexp
|
||||
push @ret, grep($_ =~ m/$l/, sort keys %defs);
|
||||
next;
|
||||
}
|
||||
};
|
||||
if($@) {
|
||||
Log 1, "devspec2array $name: $@";
|
||||
return $name;
|
||||
}
|
||||
|
||||
if($l =~ m/-/) { # Range
|
||||
|
Loading…
x
Reference in New Issue
Block a user