2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

threeState rewrite according to tobi73's observations

git-svn-id: https://svn.fhem.de/fhem/trunk@1553 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2012-05-12 06:54:30 +00:00
parent 3eeb589ade
commit ef278ca11d

View File

@ -672,28 +672,30 @@ CUL_HM_Parse($$)
push @event, "unknownMsg:$p" if(!@event);
} elsif($st eq "threeStateSensor") { #####################################
$p =~ m/^....(..)$/;
my $lst = defined($1) ? $1 : "00";
my $chn = "01";
#tobi73: modified 0601.. ->> 06..
# for multichannel Alive Message - Bytes 3/4=channel ID to be ignored...
if($p =~ m/^06....00$/) {
if($p =~ m/^(..)(..)(..)(..)?$/) {
#tobi73
# "Normal": Byte1/2:chn, 3/4:counter, 5/6:State
# "State": Byte1/2: 06, 3/4:channel, 5/6:State, 7/8:additional info
my ($b12, $b34, $b56, $b78) = ($1, $2, $3, $4);
my $lst = $b56; # Local state;
my $chn;
my $addState = "";
if($b12 eq "06") {
push @event, "alive:yes";
$chn = $b34;
if($b78) {
push(@event, "battery:". (hex($b78) & 0x80) ? "empty" : "ok");
$addState = " sabotage" if($b78 =~ m/^.E/);
}
} else {
$chn = $b12;
#tobi73: For Alive Message of SCI: Bytes 5/6 used for status
if($model eq "HM-SCI-3-FM") {
$p =~ m/^....(..)..$/;
$lst = defined($1) ? $1 : "00";
}
}
# Multi-channel device: Switch to the shadow source hash
# for the HM-SCI-3-FM
if($p =~ m/^(..)(..)/) {
#tobi73: For Alive Message of SCI channel ID in byte 3/4
$chn = ($model eq "HM-SCI-3-FM") ? $2 : $1;
}
if($chn && $chn ne "01" && $chn ne "00") {
my $sshash = $modules{CUL_HM}{defptr}{"$src$chn"};
$shash = $sshash if($sshash);
@ -704,20 +706,13 @@ CUL_HM_Parse($$)
%txt = ("C8"=>"open", "64"=>"tilted", "00"=>"closed");
%txt = ("C8"=>"wet", "64"=>"damp", "00"=>"dry") # by peterp
if($model eq "HM-SEC-WDS");
if($txt{$lst}) {
push @event, "state:$txt{$lst}$target";
} else {
$lst = "00"; # for the ack
}
if($p =~ m/^0601..0E$/) {
push @event, "state:sabotage";
}
CUL_HM_SendCmd($shash, "++8002$id$src${chn}01${lst}00",1,0) # Send Ack
my $txt = $txt{$lst};
$txt = "unknown:$lst" if(!$txt);
push @event, "state:$txt$addState$target";
CUL_HM_SendCmd($shash, "++8002$id$src${chn}00",1,0) # Send Ack
if($id eq $dst);
}
push @event, "unknownMsg:$p" if(!@event);