correct TC,support rename in CUL_HM
git-svn-id: https://fhem.svn.sourceforge.net/svnroot/fhem/trunk/fhem@2035 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -203,6 +203,7 @@ CUL_HM_Initialize($)
|
|||||||
$hash->{ParseFn} = "CUL_HM_Parse";
|
$hash->{ParseFn} = "CUL_HM_Parse";
|
||||||
$hash->{SetFn} = "CUL_HM_Set";
|
$hash->{SetFn} = "CUL_HM_Set";
|
||||||
$hash->{GetFn} = "CUL_HM_Get";
|
$hash->{GetFn} = "CUL_HM_Get";
|
||||||
|
$hash->{RenameFn} = "CUL_HM_Rename";
|
||||||
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:1,0 dummy:1,0 ".
|
$hash->{AttrList} = "IODev do_not_notify:1,0 ignore:1,0 dummy:1,0 ".
|
||||||
"showtime:1,0 loglevel:0,1,2,3,4,5,6 ".
|
"showtime:1,0 loglevel:0,1,2,3,4,5,6 ".
|
||||||
"hmClass:receiver,sender serialNr firmware devInfo ".
|
"hmClass:receiver,sender serialNr firmware devInfo ".
|
||||||
@@ -286,6 +287,26 @@ CUL_HM_Undef($$)
|
|||||||
delete($modules{CUL_HM}{defptr}{$HMid});
|
delete($modules{CUL_HM}{defptr}{$HMid});
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
#############################
|
||||||
|
sub
|
||||||
|
CUL_HM_Rename($$$)
|
||||||
|
{
|
||||||
|
#my ($hash, $name,$newName) = @_;
|
||||||
|
my ($name, $oldName) = @_;
|
||||||
|
my $HMid = CUL_HM_Name2Id($name);
|
||||||
|
if (length($HMid) == 8){# we are channel, inform the device
|
||||||
|
$attr{$name}{chanNo} = substr($HMid,6,2);
|
||||||
|
my $device = AttrVal($name, "device", "");
|
||||||
|
$attr{$device}{"channel_".$attr{$name}{chanNo}} = $name if ($device);
|
||||||
|
}
|
||||||
|
else{# we are a device - inform channels if exist
|
||||||
|
for (my$chn = 1; $chn <25;$chn++){
|
||||||
|
my $chnName = AttrVal($name, sprintf("channel_%02X",$chn), "");
|
||||||
|
$attr{$chnName}{device} = $name if ($chnName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
sub
|
sub
|
||||||
@@ -435,14 +456,14 @@ CUL_HM_Parse($$)
|
|||||||
my ( $d1, $vp) = # adjust_command[0..4] adj_data[0..250]
|
my ( $d1, $vp) = # adjust_command[0..4] adj_data[0..250]
|
||||||
( $1, hex($2));
|
( $1, hex($2));
|
||||||
$vp = int($vp/2.56+0.5); # valve position in %
|
$vp = int($vp/2.56+0.5); # valve position in %
|
||||||
#push @event, "actuator:$vp %";remove from TC
|
push @event, "actuator:$vp %";
|
||||||
|
|
||||||
# Set the valve state too, without an extra trigger
|
# Set the valve state too, without an extra trigger
|
||||||
if($dhash) {
|
if($dhash) {
|
||||||
DoTrigger($dname,'ValvePosition: changeTo '.$vp.'%');
|
DoTrigger($dname,'ValvePosition:set_'.$vp.'%');
|
||||||
$dhash->{STATE} = "$vp %";
|
$dhash->{STATE} = "$vp %";
|
||||||
$dhash->{READINGS}{state}{TIME} = $tn;
|
$dhash->{READINGS}{state}{TIME} = $tn;
|
||||||
$dhash->{READINGS}{state}{VAL} = "$vp %";
|
$dhash->{READINGS}{state}{VAL} = "set_$vp %";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# 0403 167DE9 01 05 05 16 0000 windowopen-temp chan 03, dev 167DE9 on slot 01
|
# 0403 167DE9 01 05 05 16 0000 windowopen-temp chan 03, dev 167DE9 on slot 01
|
||||||
@@ -529,8 +550,10 @@ CUL_HM_Parse($$)
|
|||||||
elsif($msgType eq "01"){
|
elsif($msgType eq "01"){
|
||||||
if($p =~ m/^010809(..)0A(..)/) { # TC set valve for VD => post events to VD
|
if($p =~ m/^010809(..)0A(..)/) { # TC set valve for VD => post events to VD
|
||||||
my ( $of, $vep) = (hex($1), hex($2));
|
my ( $of, $vep) = (hex($1), hex($2));
|
||||||
DoTrigger($dname,'ValveErrorPosition: changeTo '.$vep.'%');
|
push @event, "ValveErrorPosition for $dname: $vep %";
|
||||||
DoTrigger($dname,'ValveOffset: changeTo '.$of.'%');
|
push @event, "ValveOffset for $dname: $of %";
|
||||||
|
DoTrigger($dname,'ValveErrorPosition:set_'.$vep.'%');
|
||||||
|
DoTrigger($dname,'ValveOffset:set_'.$of.'%');
|
||||||
push @event,""; # nothing to report for TC
|
push @event,""; # nothing to report for TC
|
||||||
}
|
}
|
||||||
elsif($p =~ m/^010[56]/){ # 'prepare to set' or 'end set'
|
elsif($p =~ m/^010[56]/){ # 'prepare to set' or 'end set'
|
||||||
@@ -560,7 +583,7 @@ CUL_HM_Parse($$)
|
|||||||
if($msgType eq "02" && $p =~ m/^(..)(..)(..)(..)/) {#subtype+chn+value+err
|
if($msgType eq "02" && $p =~ m/^(..)(..)(..)(..)/) {#subtype+chn+value+err
|
||||||
my ($chn,$vp, $err) = ($2,hex($3), hex($4));
|
my ($chn,$vp, $err) = ($2,hex($3), hex($4));
|
||||||
$vp = int($vp)/2; # valve position in %
|
$vp = int($vp)/2; # valve position in %
|
||||||
push @event, "actuator:$vp %";
|
push @event, "ValvePosition:$vp%";
|
||||||
$shash = $modules{CUL_HM}{defptr}{"$src$chn"}
|
$shash = $modules{CUL_HM}{defptr}{"$src$chn"}
|
||||||
if($modules{CUL_HM}{defptr}{"$src$chn"});
|
if($modules{CUL_HM}{defptr}{"$src$chn"});
|
||||||
|
|
||||||
@@ -719,9 +742,7 @@ CUL_HM_Parse($$)
|
|||||||
|
|
||||||
if($id eq $dst) { # Send Ack
|
if($id eq $dst) { # Send Ack
|
||||||
CUL_HM_SendCmd($shash, $msgcnt."8002".$id.$src."0101".
|
CUL_HM_SendCmd($shash, $msgcnt."8002".$id.$src."0101".
|
||||||
($state =~ m/on/?"C8":"00")."00", 1, 0);#todo why that???
|
($state =~ m/on/?"C8":"00")."00", 1, 0);#Actor simulation
|
||||||
# did someone simulate an actor?
|
|
||||||
# a normal ack should do - or?
|
|
||||||
}
|
}
|
||||||
$sendAck = ""; #todo why is this special?
|
$sendAck = ""; #todo why is this special?
|
||||||
}
|
}
|
||||||
@@ -2052,7 +2073,7 @@ CUL_HM_Set($@)
|
|||||||
my $pressCnt = (!$hash->{helper}{count})?1:$hash->{helper}{count}+1;
|
my $pressCnt = (!$hash->{helper}{count})?1:$hash->{helper}{count}+1;
|
||||||
$pressCnt %= 256;
|
$pressCnt %= 256;
|
||||||
my @peerList;
|
my @peerList;
|
||||||
foreach my $peer (sort(split(',',$attr{$name}{peerList}))) {
|
foreach my $peer (sort(split(',',AttrVal($name,"peerList","")))) {
|
||||||
$peer =~ s/ .*//;
|
$peer =~ s/ .*//;
|
||||||
push (@peerList,substr(CUL_HM_Name2Id($peer),0,6));
|
push (@peerList,substr(CUL_HM_Name2Id($peer),0,6));
|
||||||
}
|
}
|
||||||
@@ -2287,7 +2308,12 @@ CUL_HM_SendCmd($$$$)
|
|||||||
|
|
||||||
if($mn eq "++") {
|
if($mn eq "++") {
|
||||||
$mn = $io->{HM_CMDNR} ? (($io->{HM_CMDNR} +1)&0xff) : 1;
|
$mn = $io->{HM_CMDNR} ? (($io->{HM_CMDNR} +1)&0xff) : 1;
|
||||||
} else {
|
}
|
||||||
|
elsif($cmd =~ m/^[+-]/){; #continue pure
|
||||||
|
IOWrite($hash, "", $cmd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
$mn = hex($mn);
|
$mn = hex($mn);
|
||||||
}
|
}
|
||||||
$io->{HM_CMDNR} = $mn;
|
$io->{HM_CMDNR} = $mn;
|
||||||
@@ -2335,7 +2361,7 @@ CUL_HM_responseSetup($$$)
|
|||||||
$hash->{helper}{respWait}{forPeer}= $peerID;# this is the HMid + channel
|
$hash->{helper}{respWait}{forPeer}= $peerID;# this is the HMid + channel
|
||||||
|
|
||||||
# define timeout - holdup cmdStack until response complete or timeout
|
# define timeout - holdup cmdStack until response complete or timeout
|
||||||
InternalTimer(gettimeofday()+$rTo,"CUL_HM_respPendTout","respPend:$dst", 0);#todo General change timer to 1.5
|
InternalTimer(gettimeofday()+$rTo,"CUL_HM_respPendTout","respPend:$dst", 0);
|
||||||
#--- remove channel entries that will be replaced
|
#--- remove channel entries that will be replaced
|
||||||
my $chnhash = $modules{CUL_HM}{defptr}{"$dst$chn"};
|
my $chnhash = $modules{CUL_HM}{defptr}{"$dst$chn"};
|
||||||
$chnhash = $hash if(!$chnhash);
|
$chnhash = $hash if(!$chnhash);
|
||||||
@@ -2412,7 +2438,7 @@ CUL_HM_respPendTout($)
|
|||||||
CUL_HM_eventP($hash,"Tout") if ($hash->{helper}{respWait}{cmd});
|
CUL_HM_eventP($hash,"Tout") if ($hash->{helper}{respWait}{cmd});
|
||||||
CUL_HM_eventP($hash,"ToutResp") if ($hash->{helper}{respWait}{Pending});
|
CUL_HM_eventP($hash,"ToutResp") if ($hash->{helper}{respWait}{Pending});
|
||||||
CUL_HM_respPendRm($hash);
|
CUL_HM_respPendRm($hash);
|
||||||
DoTrigger($hash->{NAME}, "RESPONSE TIMEOUT");#Generel - keep it?
|
DoTrigger($hash->{NAME}, "RESPONSE TIMEOUT");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
###################################
|
###################################
|
||||||
|
|||||||
3
fhem.pl
3
fhem.pl
@@ -126,6 +126,7 @@ sub CommandTrigger($$);
|
|||||||
# GetFn - get some data from this device
|
# GetFn - get some data from this device
|
||||||
# StateFn - set local info for this device, do not activate anything
|
# StateFn - set local info for this device, do not activate anything
|
||||||
# NotifyFn - call this if some device changed its properties
|
# NotifyFn - call this if some device changed its properties
|
||||||
|
# RenameFn - inform the device about its renameing
|
||||||
# ReadyFn - check for available data, if no FD
|
# ReadyFn - check for available data, if no FD
|
||||||
# ReadFn - Reading from a Device (see FHZ/WS300)
|
# ReadFn - Reading from a Device (see FHZ/WS300)
|
||||||
|
|
||||||
@@ -1554,6 +1555,8 @@ CommandRename($$)
|
|||||||
$oldvalue{$new} = $oldvalue{$old} if(defined($oldvalue{$old}));
|
$oldvalue{$new} = $oldvalue{$old} if(defined($oldvalue{$old}));
|
||||||
delete($oldvalue{$old});
|
delete($oldvalue{$old});
|
||||||
|
|
||||||
|
CallFn($new, "RenameFn", $new,$old);# ignore replies
|
||||||
|
|
||||||
DoTrigger("global", "RENAMED $old $new");
|
DoTrigger("global", "RENAMED $old $new");
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user