mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
00_TCM: new UTE option, new init command
git-svn-id: https://svn.fhem.de/fhem/trunk@12155 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
37d838eff7
commit
b9a5d96bd0
@ -59,7 +59,7 @@ TCM_Initialize($)
|
||||
$hash->{SetFn} = "TCM_Set";
|
||||
$hash->{NotifyFn} = "TCM_Notify";
|
||||
$hash->{AttrFn} = "TCM_Attr";
|
||||
$hash->{AttrList} = "baseID blockSenderID:own,no comType:TCM,RS485 do_not_notify:1,0 " .
|
||||
$hash->{AttrList} = "baseID blockSenderID:own,no comModeUTE:auto,biDir,uniDir comType:TCM,RS485 do_not_notify:1,0 " .
|
||||
"dummy:1,0 learningMode:always,demand,nearfield " .
|
||||
"sendInterval:0,25,40,50,100,150,200,250 smartAckMailboxMax:slider,0,1,20 " .
|
||||
"smartAckLearnMode:simple,advance,advanceSelectRep";
|
||||
@ -96,6 +96,106 @@ sub TCM_Define($$)
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# Initialize serial communication
|
||||
sub
|
||||
TCM_InitSerialCom($)
|
||||
{
|
||||
my ($hash) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
if ($hash->{STATE} eq "disconnected") {
|
||||
Log3 $name, 2, "TCM $name not initialized";
|
||||
return undef;
|
||||
}
|
||||
my $attrVal;
|
||||
my $comType = AttrVal($name, "comType", "TCM");
|
||||
my $setCmdVal = "";
|
||||
my @setCmd = ("set", "reset", $setCmdVal);
|
||||
# read and discard receive buffer, modem reset
|
||||
if ($hash->{MODEL} eq "ESP2") {
|
||||
if ($comType eq "TCM") {
|
||||
TCM_ReadAnswer($hash, "set reset");
|
||||
TCM_Set($hash, @setCmd);
|
||||
}
|
||||
} else {
|
||||
TCM_ReadAnswer($hash, "set reset");
|
||||
TCM_Set($hash, @setCmd);
|
||||
}
|
||||
# default attributes
|
||||
my %setAttrInit;
|
||||
if ($comType eq "RS485" || $hash->{DeviceName} eq "none") {
|
||||
%setAttrInit = (sendInterval => {ESP2 => 100, ESP3 => 0},
|
||||
learningMode => {ESP2 => "always", ESP3 => "always"}
|
||||
);
|
||||
}else {
|
||||
%setAttrInit = ("sendInterval" => {ESP2 => 100, ESP3 => 0});
|
||||
}
|
||||
foreach(keys %setAttrInit) {
|
||||
$attrVal = AttrVal($name, $_, undef);
|
||||
if(!defined $attrVal && defined $setAttrInit{$_}{$hash->{MODEL}}) {
|
||||
$attr{$name}{$_} = $setAttrInit{$_}{$hash->{MODEL}};
|
||||
Log3 $name, 2, "TCM $name Attribute $_ $setAttrInit{$_}{$hash->{MODEL}} initialized";
|
||||
}
|
||||
}
|
||||
# default transceiver parameter
|
||||
if ($comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
||||
my %setCmdRestore = (mode => "00",
|
||||
maturity => "01",
|
||||
repeater => "RepEnable: 00 RepLevel: 00",
|
||||
smartAckMailboxMax => 0
|
||||
);
|
||||
foreach(keys %setCmdRestore) {
|
||||
$setCmdVal = ReadingsVal($name, $_, AttrVal($name, $_, undef));
|
||||
if (defined $setCmdVal) {
|
||||
if ($_ eq "repeater") {
|
||||
$setCmdVal = substr($setCmdVal, 11, 2) . substr($setCmdVal, 24, 2);
|
||||
$setCmdVal = "0000" if ($setCmdVal eq "0001");
|
||||
}
|
||||
@setCmd = ("set", $_, $setCmdVal);
|
||||
TCM_Set($hash, @setCmd);
|
||||
Log3 $name, 2, "TCM $name $_ $setCmdVal restored";
|
||||
} else {
|
||||
if ($hash->{MODEL} eq "ESP2") {
|
||||
|
||||
} else {
|
||||
if ($_ eq "repeater") {
|
||||
$setCmdVal = substr($setCmdRestore{$_}, 11, 2) . substr($setCmdRestore{$_}, 24, 2);
|
||||
} else {
|
||||
$setCmdVal = $setCmdRestore{$_};
|
||||
}
|
||||
@setCmd = ("set", $_, $setCmdVal);
|
||||
my $msg = TCM_Set($hash, @setCmd);
|
||||
Log3 $name, 2, "TCM $name $_ $setCmdVal initialized" if ($msg eq "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
my $baseID = AttrVal($name, "baseID", undef);
|
||||
if (defined($baseID)) {
|
||||
$hash->{BaseID} = $baseID;
|
||||
$hash->{LastID} = sprintf "%08X", (hex $baseID) + 127;
|
||||
} elsif ($comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
||||
my @getBaseID = ("get", "baseID");
|
||||
if (TCM_Get($hash, @getBaseID) =~ /[Ff]{2}[\dA-Fa-f]{6}/) {
|
||||
$hash->{BaseID} = sprintf "%08X", hex $&;
|
||||
$hash->{LastID} = sprintf "%08X", (hex $&) + 127;
|
||||
} else {
|
||||
$hash->{BaseID} = "00000000";
|
||||
$hash->{LastID} = "00000000";
|
||||
}
|
||||
}
|
||||
if ($hash->{MODEL} eq "ESP3" && $comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
||||
# get chipID
|
||||
my @getChipID = ('get', 'version');
|
||||
if (TCM_Get($hash, @getChipID) =~ m/ChipID:.([\dA-Fa-f]{8})/) {
|
||||
$hash->{ChipID} = sprintf "%08X", hex $1;
|
||||
}
|
||||
}
|
||||
#CommandSave(undef, undef);
|
||||
readingsSingleUpdate($hash, "state", "initialized", 1);
|
||||
Log3 $name, 2, "TCM $name initialized";
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Write
|
||||
# Input is header and data (HEX), without CRC
|
||||
sub
|
||||
@ -692,6 +792,7 @@ my %sets120 = ( # Name, Data to send to the CUL, Regexp for the answer
|
||||
|
||||
# Set commands TCM 310
|
||||
my %sets310 = (
|
||||
"init" => {},
|
||||
"teach" => {packetType => 5, arg=> "\\d+"},
|
||||
"sleep" => {packetType => 5, cmd => "01", arg => "00[0-9A-F]{6}"},
|
||||
"reset" => {packetType => 5, cmd => "02"},
|
||||
@ -784,6 +885,10 @@ sub TCM_Set($@)
|
||||
|
||||
} else {
|
||||
# TCM310
|
||||
if($cmd eq "init") {
|
||||
TCM_InitSerialCom($hash);
|
||||
return;
|
||||
}
|
||||
TCM_Write($hash, sprintf("%04X00%02X", length($cmdHex)/2, $cmdhash->{packetType}), $cmdHex);
|
||||
($err, $msg) = TCM_ReadAnswer($hash, "set $cmd");
|
||||
if(!$err) {
|
||||
@ -910,7 +1015,7 @@ sub TCM_Attr(@) {
|
||||
if ($attrName eq "blockSenderID") {
|
||||
if (!defined $attrVal) {
|
||||
|
||||
} elsif ($attrVal !~ m/^(own|no)$/) {
|
||||
} elsif ($attrVal !~ m/^own|no$/) {
|
||||
Log3 $name, 2, "EnOcean $name attribute-value [$attrName] = $attrVal wrong";
|
||||
CommandDeleteAttr(undef, "$name $attrName");
|
||||
}
|
||||
@ -926,10 +1031,18 @@ sub TCM_Attr(@) {
|
||||
$hash->{LastID} = sprintf "%08X", (hex $attrVal) + 127;
|
||||
}
|
||||
|
||||
} elsif ($attrName eq "comModeUTE") {
|
||||
if (!defined $attrVal){
|
||||
|
||||
} elsif ($attrVal !~ m/^auto|biDir|uniDir$/) {
|
||||
Log3 $name, 2, "EnOcean $name attribute-value [$attrName] = $attrVal wrong";
|
||||
CommandDeleteAttr(undef, "$name $attrName");
|
||||
}
|
||||
|
||||
} elsif ($attrName eq "comType") {
|
||||
if (!defined $attrVal){
|
||||
|
||||
} elsif ($attrVal !~ m/^(TCM|RS485)$/) {
|
||||
} elsif ($attrVal !~ m/^TCM|RS485$/) {
|
||||
Log3 $name, 2, "EnOcean $name attribute-value [$attrName] = $attrVal wrong";
|
||||
CommandDeleteAttr(undef, "$name $attrName");
|
||||
}
|
||||
@ -937,7 +1050,7 @@ sub TCM_Attr(@) {
|
||||
} elsif ($attrName eq "learningMode") {
|
||||
if (!defined $attrVal){
|
||||
|
||||
} elsif ($attrVal !~ m/^(always|demand|nearfield)$/) {
|
||||
} elsif ($attrVal !~ m/^always|demand|nearfield$/) {
|
||||
Log3 $name, 2, "EnOcean $name attribute-value [$attrName] = $attrVal wrong";
|
||||
CommandDeleteAttr(undef, "$name $attrName");
|
||||
}
|
||||
@ -974,99 +1087,8 @@ sub TCM_Attr(@) {
|
||||
#
|
||||
sub TCM_Notify(@) {
|
||||
my ($hash, $dev) = @_;
|
||||
my $name = $hash->{NAME};
|
||||
if ($dev->{NAME} eq "global" && grep (m/^(INITIALIZED|REREADCFG)$/, @{$dev->{CHANGED}})){
|
||||
if ($hash->{STATE} eq "disconnected") {
|
||||
Log3 $name, 2, "TCM $name not initialized";
|
||||
return undef;
|
||||
}
|
||||
my $attrVal;
|
||||
my $comType = AttrVal($name, "comType", "TCM");
|
||||
my $setCmdVal = "";
|
||||
my @setCmd = ("set", "reset", $setCmdVal);
|
||||
# read and discard receive buffer, modem reset
|
||||
if ($hash->{MODEL} eq "ESP2") {
|
||||
if ($comType eq "TCM") {
|
||||
TCM_ReadAnswer($hash, "set reset");
|
||||
TCM_Set($hash, @setCmd);
|
||||
}
|
||||
} else {
|
||||
TCM_ReadAnswer($hash, "set reset");
|
||||
TCM_Set($hash, @setCmd);
|
||||
}
|
||||
# default attributes
|
||||
my %setAttrInit;
|
||||
if ($comType eq "RS485" || $hash->{DeviceName} eq "none") {
|
||||
%setAttrInit = (sendInterval => {ESP2 => 100, ESP3 => 0},
|
||||
learningMode => {ESP2 => "always", ESP3 => "always"}
|
||||
);
|
||||
}else {
|
||||
%setAttrInit = ("sendInterval" => {ESP2 => 100, ESP3 => 0});
|
||||
}
|
||||
foreach(keys %setAttrInit) {
|
||||
$attrVal = AttrVal($name, $_, undef);
|
||||
if(!defined $attrVal && defined $setAttrInit{$_}{$hash->{MODEL}}) {
|
||||
$attr{$name}{$_} = $setAttrInit{$_}{$hash->{MODEL}};
|
||||
Log3 $name, 2, "TCM $name Attribute $_ $setAttrInit{$_}{$hash->{MODEL}} initialized";
|
||||
}
|
||||
}
|
||||
# default transceiver parameter
|
||||
if ($comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
||||
my %setCmdRestore = (mode => "00",
|
||||
maturity => "01",
|
||||
repeater => "RepEnable: 00 RepLevel: 00",
|
||||
smartAckMailboxMax => 0
|
||||
);
|
||||
foreach(keys %setCmdRestore) {
|
||||
$setCmdVal = ReadingsVal($name, $_, AttrVal($name, $_, undef));
|
||||
if (defined $setCmdVal) {
|
||||
if ($_ eq "repeater") {
|
||||
$setCmdVal = substr($setCmdVal, 11, 2) . substr($setCmdVal, 24, 2);
|
||||
$setCmdVal = "0000" if ($setCmdVal eq "0001");
|
||||
}
|
||||
@setCmd = ("set", $_, $setCmdVal);
|
||||
TCM_Set($hash, @setCmd);
|
||||
Log3 $name, 2, "TCM $name $_ $setCmdVal restored";
|
||||
} else {
|
||||
if ($hash->{MODEL} eq "ESP2") {
|
||||
|
||||
} else {
|
||||
if ($_ eq "repeater") {
|
||||
$setCmdVal = substr($setCmdRestore{$_}, 11, 2) . substr($setCmdRestore{$_}, 24, 2);
|
||||
} else {
|
||||
$setCmdVal = $setCmdRestore{$_};
|
||||
}
|
||||
@setCmd = ("set", $_, $setCmdVal);
|
||||
my $msg = TCM_Set($hash, @setCmd);
|
||||
Log3 $name, 2, "TCM $name $_ $setCmdVal initialized" if ($msg eq "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
my $baseID = AttrVal($name, "baseID", undef);
|
||||
if (defined($baseID)) {
|
||||
$hash->{BaseID} = $baseID;
|
||||
$hash->{LastID} = sprintf "%08X", (hex $baseID) + 127;
|
||||
} elsif ($comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
||||
my @getBaseID = ("get", "baseID");
|
||||
if (TCM_Get($hash, @getBaseID) =~ /[Ff]{2}[\dA-Fa-f]{6}/) {
|
||||
$hash->{BaseID} = sprintf "%08X", hex $&;
|
||||
$hash->{LastID} = sprintf "%08X", (hex $&) + 127;
|
||||
} else {
|
||||
$hash->{BaseID} = "00000000";
|
||||
$hash->{LastID} = "00000000";
|
||||
}
|
||||
}
|
||||
if ($hash->{MODEL} eq "ESP3" && $comType ne "RS485" && $hash->{DeviceName} ne "none") {
|
||||
# get chipID
|
||||
my @getChipID = ('get', 'version');
|
||||
if (TCM_Get($hash, @getChipID) =~ m/ChipID:.([\dA-Fa-f]{8})/) {
|
||||
$hash->{ChipID} = sprintf "%08X", hex $1;
|
||||
}
|
||||
}
|
||||
#CommandSave(undef, undef);
|
||||
readingsSingleUpdate($hash, "state", "initialized", 1);
|
||||
Log3 $name, 2, "TCM $name initialized";
|
||||
if ($dev->{NAME} eq "global" && grep (m/^INITIALIZED|REREADCFG$/, @{$dev->{CHANGED}})){
|
||||
TCM_InitSerialCom($hash);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
@ -1095,8 +1117,8 @@ TCM_Undef($$)
|
||||
1;
|
||||
|
||||
=pod
|
||||
=item summary <a href="http://www.enocean.com/esp">EnOcean Serial Protocol</a> Inferface (ESP2/ESP3)
|
||||
=item summary_DE <a href="http://www.enocean.com/esp">EnOcean Serial Protocol</a> Interface (ESP2/ESP3)
|
||||
=item summary EnOcean Serial Protocol Inferface (ESP2/ESP3)
|
||||
=item summary_DE EnOcean Serial Protocol Interface (ESP2/ESP3)
|
||||
=begin html
|
||||
|
||||
<a name="TCM"></a>
|
||||
@ -1210,6 +1232,8 @@ TCM_Undef($$)
|
||||
<li>filterEnable <FilterON/OFF><FilterOperator><br>
|
||||
Enable/Disable all supplied filters. Description of the filter parameters, see
|
||||
<a href="https://www.enocean.com/esp">EnOcean Serial Protocol 3 (ESP3)</a></li>
|
||||
<li>init<br>
|
||||
Initialize serial communication and transceiver configuration</li>
|
||||
<li>maturity [00|01]<br>
|
||||
Waiting till end of maturity time before received radio telegrams will transmit:
|
||||
radio telegrams are send immediately = 00, after the maturity time is elapsed = 01</li>
|
||||
@ -1305,6 +1329,12 @@ TCM_Undef($$)
|
||||
[baseID] = <none> is default.<br>
|
||||
Set Transceiver baseID and override automatic allocation. Use this attribute only if the IODev does not allow automatic allocation.
|
||||
</li>
|
||||
<li><a name="TCM_comModeUTE">comModeUTE</a> <auto|biDir|uniDir>,
|
||||
[comModeUTE] = auto is default.<br>
|
||||
Presetting the communication method of actuators that be taught using the UTE teach-in. The automatic selection of the
|
||||
communication method should only be overwrite manually, if this is explicitly required in the operating instructions of
|
||||
the actuator. The parameters should then be immediately re-set to "auto".
|
||||
</li>
|
||||
<li><a name="TCM_comType">comType</a> <TCM|RS485>,
|
||||
[comType] = TCM is default.<br>
|
||||
Type of communication device
|
||||
|
Loading…
x
Reference in New Issue
Block a user