mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +00:00
10_IT: In AttrList group entfernt, Anpassungen für TSCUL, bei einem modify der DEF wird nun die alte DEF gelöscht
git-svn-id: https://svn.fhem.de/fhem/trunk@28339 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
80cf16ea59
commit
11f7d967c8
@ -1,8 +1,10 @@
|
|||||||
######################################################
|
######################################################
|
||||||
# InterTechno Switch Manager as FHM-Module
|
# InterTechno Switch Manager as FHM-Module
|
||||||
#
|
#
|
||||||
# (c) Olaf Droegehorn / DHS-Computertechnik GmbH
|
# Copyright (C)
|
||||||
# (c) Björn Hempel
|
# Olaf Droegehorn / DHS-Computertechnik GmbH
|
||||||
|
# Björn Hempel
|
||||||
|
# 2023 Ralf9
|
||||||
#
|
#
|
||||||
# Published under GNU GPL License
|
# Published under GNU GPL License
|
||||||
#
|
#
|
||||||
@ -45,7 +47,7 @@ my %codes = (
|
|||||||
my %codes_he800 = (
|
my %codes_he800 = (
|
||||||
"XMIToff" => "off",
|
"XMIToff" => "off",
|
||||||
"XMITon" => "on", # Set to previous dim value (before switching it off)
|
"XMITon" => "on", # Set to previous dim value (before switching it off)
|
||||||
"00" => "off",
|
"00" => "dim00%",
|
||||||
#"01" => "last-dim-on",
|
#"01" => "last-dim-on",
|
||||||
"02" => "dim12%",
|
"02" => "dim12%",
|
||||||
"03" => "dim25%",
|
"03" => "dim25%",
|
||||||
@ -117,13 +119,13 @@ IT_Initialize($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hash->{Match} = "^i......";
|
$hash->{Match} = "^i......";
|
||||||
$hash->{SetFn} = "IT_Set";
|
$hash->{SetFn} = \&IT_Set;
|
||||||
#$hash->{StateFn} = "IT_SetState";
|
#$hash->{StateFn} = "IT_SetState";
|
||||||
$hash->{DefFn} = "IT_Define";
|
$hash->{DefFn} = \&IT_Define;
|
||||||
$hash->{UndefFn} = "IT_Undef";
|
$hash->{UndefFn} = \&IT_Undef;
|
||||||
$hash->{ParseFn} = "IT_Parse";
|
$hash->{ParseFn} = \&IT_Parse;
|
||||||
$hash->{AttrFn} = "IT_Attr";
|
$hash->{AttrFn} = \&IT_Attr;
|
||||||
$hash->{AttrList} = "IODev ITfrequency ITrepetition ITclock switch_rfmode:1,0 do_not_notify:1,0 ignore:0,1 protocol:V1,V3,HE_EU,SBC_FreeTec,HE800 SIGNALduinoProtocolId userV1setCodes unit group dummy:1,0 " .
|
$hash->{AttrList} = "IODev ITfrequency ITrepetition ITclock switch_rfmode:1,0 do_not_notify:1,0 ignore:0,1 protocol:V1,V3,HE_EU,SBC_FreeTec,HE800 SIGNALduinoProtocolId userV1setCodes dummy:1,0 " .
|
||||||
"$readingFnAttributes " .
|
"$readingFnAttributes " .
|
||||||
"model:".join(",", sort keys %models);
|
"model:".join(",", sort keys %models);
|
||||||
|
|
||||||
@ -158,7 +160,7 @@ IT_Do_On_Till($@)
|
|||||||
my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]);
|
my $hms_now = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]);
|
||||||
if($hms_now ge $hms_till) {
|
if($hms_now ge $hms_till) {
|
||||||
Log 4, "on-till: won't switch as now ($hms_now) is later than $hms_till";
|
Log 4, "on-till: won't switch as now ($hms_now) is later than $hms_till";
|
||||||
return "";
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
my @b = ("on");
|
my @b = ("on");
|
||||||
@ -257,6 +259,19 @@ IT_Set($@)
|
|||||||
|
|
||||||
|
|
||||||
my $io = $hash->{IODev};
|
my $io = $hash->{IODev};
|
||||||
|
return 'no IODev available, adapt attribute IODevList' if (!defined($io));
|
||||||
|
|
||||||
|
my $ioNotSIGNALduino = ($io->{TYPE} !~ m/^SIGNALduino/);
|
||||||
|
my $ioTsculfw = 0;
|
||||||
|
if ($io->{TYPE} eq 'TSCUL') {
|
||||||
|
if ($io->{helper}{SVTS}) {
|
||||||
|
$ioTsculfw = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log3 $hash, 2, 'IT set ERROR: TSCUL has not required firmware';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $v = $name ." ". join(" ", @a);
|
my $v = $name ." ". join(" ", @a);
|
||||||
## Log that we are going to switch InterTechno
|
## Log that we are going to switch InterTechno
|
||||||
Log3 $hash, 3, "$io->{NAME} IT_set: $v";
|
Log3 $hash, 3, "$io->{NAME} IT_set: $v";
|
||||||
@ -336,43 +351,54 @@ IT_Set($@)
|
|||||||
|
|
||||||
|
|
||||||
Log3 $hash, 5, "$io->{NAME} IT_set: Type=" . $io->{TYPE} . ' Protocol=' . $hash->{READINGS}{protocol}{VAL};
|
Log3 $hash, 5, "$io->{NAME} IT_set: Type=" . $io->{TYPE} . ' Protocol=' . $hash->{READINGS}{protocol}{VAL};
|
||||||
|
my $oldIOMode;
|
||||||
if ($io->{TYPE} ne "SIGNALduino") {
|
if ($ioNotSIGNALduino) {
|
||||||
# das IODev ist kein SIGNALduino
|
# das IODev ist kein SIGNALduino
|
||||||
|
|
||||||
|
return "IODev $io->{NAME} does not support IT" if ($ioTsculfw && defined($io->{CMDS}) && $io->{CMDS} !~ m/i/); # TSCUL muss das i Kommando kennen
|
||||||
|
|
||||||
## Do we need to change RFMode to SlowRF??
|
## Do we need to change RFMode to SlowRF??
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"switch_rfmode"})) {
|
if (AttrVal($name, 'switch_rfmode', '0')) {
|
||||||
if ($attr{$name}{"switch_rfmode"} eq "1") { # do we need to change RFMode of IODev
|
$oldIOMode = AttrVal($io->{NAME}, 'rfmode', 'SlowRF');
|
||||||
my $ret = CallFn($io->{NAME}, "AttrFn", "set", ($io->{NAME}, "rfmode", "SlowRF"));
|
CallFn($io->{NAME}, "AttrFn", "set", ($io->{NAME}, "rfmode", "SlowRF"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
## Do we need to change ITClock ?? }
|
## Do we need to change ITClock ?? }
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"ITclock"})) {
|
if (defined($message = AttrVal($name, 'ITclock', undef))) {
|
||||||
#$message = "isc".$attr{$name}{"ITclock"};
|
CallFn($io->{NAME}, "SetFn", $io, ($io->{NAME}, "ITClock", $message));
|
||||||
#CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
|
|
||||||
$message = $attr{$name}{"ITclock"};
|
|
||||||
CallFn($io->{NAME}, "SetFn", $io, ($hash->{NAME}, "ITClock", $message));
|
|
||||||
Log3 $hash, 3, "IT set ITclock: $message for $io->{NAME}";
|
Log3 $hash, 3, "IT set ITclock: $message for $io->{NAME}";
|
||||||
}
|
}
|
||||||
|
|
||||||
## Do we need to change ITrepetition ??
|
## Do we need to change ITrepetition ??
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"ITrepetition"})) {
|
my $itrep;
|
||||||
$message = "isr".$attr{$name}{"ITrepetition"};
|
if($itrep = AttrVal($name, 'ITrepetition', 0)) {
|
||||||
CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
|
$itrep = 254 if ($itrep > 254);
|
||||||
Log3 $hash,4, "IT set ITrepetition: $message for $io->{NAME}";
|
$message = 'isr'.$itrep;
|
||||||
}
|
if ($ioTsculfw) { # tsculfw
|
||||||
|
CallFn($io->{NAME}, 'SetFn', $io, ($io->{NAME}, 'raw', $message)); # if not set before send the tsculfw default is 3 and reverts to it after send
|
||||||
|
}
|
||||||
|
else { # culfw, a-culfw
|
||||||
|
CallFn($io->{NAME}, 'GetFn', $io, (' ', 'raw', $message));
|
||||||
|
}
|
||||||
|
Log3 $hash,4, "IT set ITrepetition: $message for $io->{NAME}";
|
||||||
|
}
|
||||||
|
|
||||||
## Do we need to change ITfrequency ??
|
## Do we need to change ITfrequency ??
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"ITfrequency"})) {
|
my $f;
|
||||||
my $f = $attr{$name}{"ITfrequency"}/26*65536;
|
if (defined($f = AttrVal($name, 'ITfrequency', undef))) {
|
||||||
my $f2 = sprintf("%02x", $f / 65536);
|
$f = $f/26*65536;
|
||||||
my $f1 = sprintf("%02x", int($f % 65536) / 256);
|
my $f2 = sprintf("%02x", $f / 65536);
|
||||||
my $f0 = sprintf("%02x", $f % 256);
|
my $f1 = sprintf("%02x", int($f % 65536) / 256);
|
||||||
|
my $f0 = sprintf("%02x", $f % 256);
|
||||||
my $arg = sprintf("%.3f", (hex($f2)*65536+hex($f1)*256+hex($f0))/65536*26);
|
$message = "if$f2$f1$f0";
|
||||||
Log3 $hash, 3, "Setting ITfrequency (0D,0E,0F) to $f2 $f1 $f0 = $arg MHz";
|
my $arg = sprintf("%.3f", (hex($f2)*65536+hex($f1)*256+hex($f0))/65536*26);
|
||||||
CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", "if$f2$f1$f0"));
|
Log3 $hash, 3, "Setting ITfrequency (0D,0E,0F) to $f2 $f1 $f0 = $arg MHz";
|
||||||
}
|
if ($ioTsculfw) { # tsculfw
|
||||||
|
CallFn($io->{NAME}, 'SetFn', $io, ($io->{NAME}, 'raw', $message));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CallFn($io->{NAME}, 'GetFn', $io, (' ', 'raw', $message));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hash->{READINGS}{protocol}{VAL} eq "V3") {
|
if ($hash->{READINGS}{protocol}{VAL} eq "V3") {
|
||||||
@ -432,6 +458,7 @@ IT_Set($@)
|
|||||||
my $msg;
|
my $msg;
|
||||||
|
|
||||||
my %he800MapingTable = (
|
my %he800MapingTable = (
|
||||||
|
0 => 0,
|
||||||
12 => 2,
|
12 => 2,
|
||||||
25 => 3,
|
25 => 3,
|
||||||
37 => 4,
|
37 => 4,
|
||||||
@ -451,8 +478,11 @@ IT_Set($@)
|
|||||||
$rollingCode = 0;
|
$rollingCode = 0;
|
||||||
}
|
}
|
||||||
my $oldMode = 0;
|
my $oldMode = 0;
|
||||||
|
my $sendVal;
|
||||||
if ($cVal eq "on") {
|
if ($cVal eq "on") {
|
||||||
my $sendVal = $hash->{READINGS}{"on_" . $rollingCode}{VAL};
|
if (exists($hash->{READINGS}{"on_" . $rollingCode})) {
|
||||||
|
$sendVal = $hash->{READINGS}{"on_" . $rollingCode}{VAL};
|
||||||
|
}
|
||||||
if (defined $sendVal && $sendVal ne "" && $sendVal ne "0") {
|
if (defined $sendVal && $sendVal ne "" && $sendVal ne "0") {
|
||||||
$message = "ish".uc($sendVal);
|
$message = "ish".uc($sendVal);
|
||||||
$oldMode = 1;
|
$oldMode = 1;
|
||||||
@ -462,7 +492,9 @@ IT_Set($@)
|
|||||||
$mode = 1;
|
$mode = 1;
|
||||||
}
|
}
|
||||||
} elsif ($cVal eq "off") {
|
} elsif ($cVal eq "off") {
|
||||||
my $sendVal = $hash->{READINGS}{"off_" . $rollingCode}{VAL};
|
if (exists($hash->{READINGS}{"off_" . $rollingCode})) {
|
||||||
|
$sendVal = $hash->{READINGS}{"off_" . $rollingCode}{VAL};
|
||||||
|
}
|
||||||
if (defined $sendVal && $sendVal ne "" && $sendVal ne "0") {
|
if (defined $sendVal && $sendVal ne "" && $sendVal ne "0") {
|
||||||
$message = "ish".uc($sendVal);
|
$message = "ish".uc($sendVal);
|
||||||
$oldMode = 1;
|
$oldMode = 1;
|
||||||
@ -532,8 +564,8 @@ IT_Set($@)
|
|||||||
#XOR encryption 2 rounds
|
#XOR encryption 2 rounds
|
||||||
for (my $r=0; $r<=1; $r++){ # 2 encryption rounds
|
for (my $r=0; $r<=1; $r++){ # 2 encryption rounds
|
||||||
$mn[0] = $key[ $mn[0]-$r+1]; # encrypt first nibble
|
$mn[0] = $key[ $mn[0]-$r+1]; # encrypt first nibble
|
||||||
my $i = 0;
|
#my $i = 0;
|
||||||
for ($i=1; $i<=5 ; $i++){ # encrypt 4 nibbles
|
for (my $i=1; $i<=5 ; $i++){ # encrypt 4 nibbles
|
||||||
$mn[$i] = $key[($mn[$i] ^ $mn[$i-1])-$r+1]; # crypted with predecessor & key
|
$mn[$i] = $key[($mn[$i] ^ $mn[$i-1])-$r+1]; # crypted with predecessor & key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -557,8 +589,8 @@ IT_Set($@)
|
|||||||
$message = "ish".uc($bin);
|
$message = "ish".uc($bin);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
my $onoffcode;
|
my $onoffcode = '';
|
||||||
if (defined($c)) {
|
if (defined($c) && defined($hash->{$c})) {
|
||||||
$onoffcode = $hash->{$c};
|
$onoffcode = $hash->{$c};
|
||||||
} else {
|
} else {
|
||||||
if ($hash->{userV1setCodes}) {
|
if ($hash->{userV1setCodes}) {
|
||||||
@ -568,47 +600,51 @@ IT_Set($@)
|
|||||||
if (length($onoffcode) == 4 && $hash->{READINGS}{protocol}{VAL} ne 'SBC_FreeTec') { # EV1527
|
if (length($onoffcode) == 4 && $hash->{READINGS}{protocol}{VAL} ne 'SBC_FreeTec') { # EV1527
|
||||||
$onoffcode = $bintotristate{substr($onoffcode,0,2)} . $bintotristate{substr($onoffcode,2,2)};
|
$onoffcode = $bintotristate{substr($onoffcode,0,2)} . $bintotristate{substr($onoffcode,2,2)};
|
||||||
}
|
}
|
||||||
$message = "is".uc($hash->{XMIT}.$onoffcode);
|
$message = 'is'.uc($hash->{XMIT}.$onoffcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($io->{TYPE} ne "SIGNALduino") {
|
if ($ioNotSIGNALduino) {
|
||||||
# das IODev ist kein SIGNALduino
|
if ($ioTsculfw) { # tsculfw
|
||||||
## Send Message to IODev and wait for correct answer
|
## Send Message to IODev
|
||||||
my $msg = CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
|
CallFn($io->{NAME}, 'SetFn', $io, (' ', 'raw', $message)); # tsculfw VTS0.32+ resets frequency, offset, ITrepetition and ITclock back to firmware default values after send
|
||||||
Log3 $hash,5,"IT_Set: GetFn(raw): message = $message Antwort = $msg";
|
}
|
||||||
if ($msg =~ m/raw => $message/) {
|
else { # culfw, a-culfw
|
||||||
Log 4, "ITSet: Answer from $io->{NAME}: $msg";
|
## Send Message to IODev and wait for correct answer
|
||||||
} else {
|
my $msg = CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
|
||||||
Log 2, "IT IODev device didn't answer is command correctly: $msg";
|
Log3 $hash,5,"IT_Set: GetFn(raw): message = $message Antwort = $msg";
|
||||||
}
|
if ($msg =~ m/raw => $message/) {
|
||||||
## Do we need to change ITrepetition back??
|
Log 4, "ITSet: Answer from $io->{NAME}: $msg";
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"ITrepetition"})) {
|
} else {
|
||||||
$message = "isr".$it_defrepetition;
|
Log 2, "IT IODev device didn't answer is command correctly: $msg";
|
||||||
CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", $message));
|
}
|
||||||
Log3 $hash, 3, "IT set ITrepetition back: $message for $io->{NAME}";
|
|
||||||
}
|
|
||||||
|
|
||||||
## Do we need to change ITfrequency back??
|
## Do we need to change ITrepetition back??
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"ITfrequency"})) {
|
if (defined(AttrVal($name, 'ITrepetition', undef))) {
|
||||||
Log3 $hash,4 ,"Setting ITfrequency back to 433.92 MHz";
|
$message = 'isr'.$it_defrepetition;
|
||||||
CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", "if0"));
|
CallFn($io->{NAME}, 'GetFn', $io, (' ', 'raw', $message));
|
||||||
}
|
Log3 $hash, 3, "IT set ITrepetition back: $message for $io->{NAME}";
|
||||||
|
}
|
||||||
|
|
||||||
## Do we need to change ITClock back??
|
## Do we need to change ITfrequency back??
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"ITclock"}))
|
if (defined(AttrVal($name, 'ITrepetition', undef))) {
|
||||||
{
|
Log3 $hash,4 ,'Setting ITfrequency back to 433.92 MHz';
|
||||||
Log3 $hash, 3, "Setting ITClock back to 420";
|
CallFn($io->{NAME}, 'GetFn', $io, (' ', 'raw', 'if0'));
|
||||||
#CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", "sic250"));
|
}
|
||||||
CallFn($io->{NAME}, "SetFn", $io, ($hash->{NAME}, "ITClock", "420"));
|
|
||||||
}
|
## Do we need to change ITClock back??
|
||||||
|
if (defined(AttrVal($name, 'ITclock', undef))) {
|
||||||
|
Log3 $hash, 3, 'Setting ITClock back to 420';
|
||||||
|
#CallFn($io->{NAME}, "GetFn", $io, (" ", "raw", "sic250"));
|
||||||
|
CallFn($io->{NAME}, 'SetFn', $io, ($hash->{NAME}, 'ITClock', '420'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
## Do we need to change RFMode back to previous mode??
|
||||||
|
if (AttrVal($name, 'switch_rfmode', '0')) { # do we need to change RFMode of IODev?
|
||||||
|
CallFn($io->{NAME}, 'AttrFn', 'set', ($hash->{NAME}, 'rfmode', $oldIOMode));
|
||||||
|
}
|
||||||
|
|
||||||
## Do we need to change RFMode back to HomeMatic??
|
|
||||||
if(defined($attr{$name}) && defined($attr{$name}{"switch_rfmode"})) {
|
|
||||||
if ($attr{$name}{"switch_rfmode"} eq "1") { # do we need to change RFMode of IODev
|
|
||||||
my $ret = CallFn($io->{NAME}, "AttrFn", "set", ($io->{NAME}, "rfmode", "HomeMatic"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { # SIGNALduino
|
} else { # SIGNALduino
|
||||||
|
|
||||||
@ -711,6 +747,19 @@ IT_Define($$)
|
|||||||
my $groupBit;
|
my $groupBit;
|
||||||
my $name = $a[0];
|
my $name = $a[0];
|
||||||
|
|
||||||
|
if ($hash->{OLDDEF}) {
|
||||||
|
Log3 $hash,4,"ITdefine: delete OLDDEF $hash->{CODE}{1}";
|
||||||
|
delete($hash->{CODE}{1});
|
||||||
|
my @b = split(/[ \t]+/, $hash->{OLDDEF}, 2);
|
||||||
|
delete($modules{IT}{defptr}{lc($b[0])}{$name});
|
||||||
|
delete($hash->{READINGS}{protocol});
|
||||||
|
delete($hash->{READINGS}{mode});
|
||||||
|
delete($hash->{READINGS}{unit});
|
||||||
|
delete($hash->{READINGS}{group});
|
||||||
|
for my $c (keys(%it_c2b)) {
|
||||||
|
delete($hash->{$c});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($a[3] eq "HE800") {
|
if ($a[3] eq "HE800") {
|
||||||
# OLD, do not use anymore
|
# OLD, do not use anymore
|
||||||
@ -894,16 +943,49 @@ IT_Parse($$)
|
|||||||
$modules{IT}{defptr}{ioname} = $ioname;
|
$modules{IT}{defptr}{ioname} = $ioname;
|
||||||
if ((substr($msg, 0, 1)) ne 'i') {
|
if ((substr($msg, 0, 1)) ne 'i') {
|
||||||
Log3 $hash,4,"$ioname IT: message not supported by IT \"$msg\"!";
|
Log3 $hash,4,"$ioname IT: message not supported by IT \"$msg\"!";
|
||||||
return undef;
|
return '';
|
||||||
}
|
}
|
||||||
if (length($msg) != 7 && length($msg) != 12 && length($msg) != 17 && length($msg) != 19 && length($msg) != 20) {
|
|
||||||
Log3 $hash,3,"$ioname IT: message \"$msg\" (" . length($msg) . ") too short!";
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
Log3 $hash,4,"$ioname IT: message \"$msg\" (" . length($msg) . ")";
|
|
||||||
my $bin = undef;
|
my $bin = undef;
|
||||||
my $isDimMode = 0;
|
my $ishe = (substr($msg, 1, 1) eq 'h');
|
||||||
if (length($msg) == 17) { # IT V3
|
if ($ishe) {
|
||||||
|
if (length($msg) == 9 || length($msg) == 17) { # from sduino
|
||||||
|
$msg .= '0';
|
||||||
|
}
|
||||||
|
Log3 $hash,4,"$ioname IT: HE message \"$msg\" (" . length($msg) . ")";
|
||||||
|
if (length($msg) == 18 || length($msg) == 20) { # HomeEasy EU
|
||||||
|
#Log3 $ioname,3,"HEX Part1: " . substr($msg,2,8);
|
||||||
|
my $bin1=sprintf("%024b",hex(substr($msg,2,8)));
|
||||||
|
while (length($bin1) < 32) {
|
||||||
|
# suffix 0
|
||||||
|
$bin1 = '0'.$bin1;
|
||||||
|
}
|
||||||
|
#Log3 $ioname,3,"HEX Part2: " . substr($msg,2+8,7);
|
||||||
|
my $bin2=sprintf("%024b",hex(substr($msg,2+8,7)));
|
||||||
|
while (length($bin2) < 28) {
|
||||||
|
# suffix 0
|
||||||
|
$bin2 = '0'.$bin2;
|
||||||
|
}
|
||||||
|
$bin = $bin1 . $bin2;
|
||||||
|
}
|
||||||
|
elsif (length($msg) == 10 || length($msg) == 12) { # HomeEasy HE800
|
||||||
|
$bin=sprintf("%024b",hex(substr($msg,2,8)));
|
||||||
|
#my $bin1=sprintf("%024b",hex(substr($msg,2,8)));
|
||||||
|
#while (length($bin1) < 32) {
|
||||||
|
# # suffix 0
|
||||||
|
# $bin1 = '0'.$bin1;
|
||||||
|
#}
|
||||||
|
#$bin = $bin1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log3 $ioname,3,"$ioname IT: HE message \"$msg\" (" . length($msg) . ") wrong length!";
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { # IT V1 / V3
|
||||||
|
Log3 $hash,4,"$ioname IT: message \"$msg\" (" . length($msg) . ")";
|
||||||
|
#my $isDimMode = 0;
|
||||||
|
if (length($msg) == 17) { # IT V3
|
||||||
my $bin1=sprintf("%024b",hex(substr($msg,1,length($msg)-1-8)));
|
my $bin1=sprintf("%024b",hex(substr($msg,1,length($msg)-1-8)));
|
||||||
while (length($bin1) < 32) {
|
while (length($bin1) < 32) {
|
||||||
# suffix 0
|
# suffix 0
|
||||||
@ -916,7 +998,8 @@ IT_Parse($$)
|
|||||||
}
|
}
|
||||||
$bin = $bin1 . $bin2;
|
$bin = $bin1 . $bin2;
|
||||||
Log3 $hash,4,"$ioname ITv3: bin message \"$bin\" (" . length($bin) . ")";
|
Log3 $hash,4,"$ioname ITv3: bin message \"$bin\" (" . length($bin) . ")";
|
||||||
} elsif (length($msg) == 19 ) { # IT V3 Dimm
|
}
|
||||||
|
elsif (length($msg) == 19 ) { # IT V3 Dimm
|
||||||
my $bin1=sprintf("%024b",hex(substr($msg,1,length($msg)-1-8-8)));
|
my $bin1=sprintf("%024b",hex(substr($msg,1,length($msg)-1-8-8)));
|
||||||
while (length($bin1) < 32) {
|
while (length($bin1) < 32) {
|
||||||
# suffix 0
|
# suffix 0
|
||||||
@ -934,35 +1017,14 @@ IT_Parse($$)
|
|||||||
}
|
}
|
||||||
$bin = substr($bin1 . $bin2 . $bin3,24,length($bin1 . $bin2 . $bin3)-1);
|
$bin = substr($bin1 . $bin2 . $bin3,24,length($bin1 . $bin2 . $bin3)-1);
|
||||||
Log3 $hash,4,"$ioname ITv3dimm: bin message \"$bin\" (" . length($bin) . ")";
|
Log3 $hash,4,"$ioname ITv3dimm: bin message \"$bin\" (" . length($bin) . ")";
|
||||||
} elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU
|
}
|
||||||
#Log3 undef,3,"HEX Part1: " . substr($msg,2,8);
|
elsif (length($msg) == 7) { # IT
|
||||||
my $bin1=sprintf("%024b",hex(substr($msg,2,8)));
|
$bin=sprintf("%024b",hex(substr($msg,1,length($msg)-1)));
|
||||||
while (length($bin1) < 32) {
|
}
|
||||||
# suffix 0
|
else {
|
||||||
$bin1 = '0'.$bin1;
|
Log3 $ioname,3,"$ioname IT: message \"$msg\" (" . length($msg) . ") wrong length!";
|
||||||
}
|
return '';
|
||||||
#Log3 undef,3,"HEX Part2: " . substr($msg,2+8,7);
|
}
|
||||||
my $bin2=sprintf("%024b",hex(substr($msg,2+8,7)));
|
|
||||||
#$bin2 = substr($bin2,4);
|
|
||||||
while (length($bin2) < 28) {
|
|
||||||
# suffix 0
|
|
||||||
$bin2 = '0'.$bin2;
|
|
||||||
}
|
|
||||||
$bin = $bin1 . $bin2;# . $bin3;
|
|
||||||
} elsif (length($msg) == 12 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy HE800
|
|
||||||
my $bin1=sprintf("%024b",hex(substr($msg,2,8)));
|
|
||||||
while (length($bin1) < 32) {
|
|
||||||
# suffix 0
|
|
||||||
$bin1 = '0'.$bin1;
|
|
||||||
}
|
|
||||||
$bin = $bin1;# . $bin3;
|
|
||||||
} else { # IT
|
|
||||||
if (length($msg) > 10) {
|
|
||||||
Log3 $hash,4,"$ioname IT: Wrong IT message received: $msg";
|
|
||||||
return undef;
|
|
||||||
} else {
|
|
||||||
$bin=sprintf("%024b",hex(substr($msg,1,length($msg)-1)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((length($bin) % 2) != 0) {
|
if ((length($bin) % 2) != 0) {
|
||||||
@ -971,10 +1033,14 @@ IT_Parse($$)
|
|||||||
}
|
}
|
||||||
my $binorg = $bin;
|
my $binorg = $bin;
|
||||||
my $msgcode="";
|
my $msgcode="";
|
||||||
if (length($msg) == 12 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy HE800;
|
if ($ishe) { # HomeEasy
|
||||||
$msgcode=substr($bin, 0, 28);
|
if (length($msg) >= 18) { # HomeEasy EU
|
||||||
} elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU;
|
$msgcode=substr($bin, 0, 57);
|
||||||
$msgcode=substr($bin, 0, 57);
|
}
|
||||||
|
else { # HomeEasy HE800;
|
||||||
|
#$msgcode=substr($bin, 0, 28);
|
||||||
|
$msgcode=$bin;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
while (length($bin)>=2) {
|
while (length($bin)>=2) {
|
||||||
if (length($msg) == 7) {
|
if (length($msg) == 7) {
|
||||||
@ -992,8 +1058,8 @@ IT_Parse($$)
|
|||||||
#Log3 $hash,4,"$ioname IT:unknown tristate in \"$bin\"";
|
#Log3 $hash,4,"$ioname IT:unknown tristate in \"$bin\"";
|
||||||
#return "unknown tristate in \"$bin\""
|
#return "unknown tristate in \"$bin\""
|
||||||
}
|
}
|
||||||
} elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU
|
#} elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU, but this is never reached, see $ishe above!
|
||||||
$msgcode=$msgcode.$bintotristateHE{substr($bin,0,2)};
|
# $msgcode=$msgcode.$bintotristateHE{substr($bin,0,2)};
|
||||||
} else {
|
} else {
|
||||||
$msgcode=$msgcode.$bintotristateV3{substr($bin,0,2)};
|
$msgcode=$msgcode.$bintotristateV3{substr($bin,0,2)};
|
||||||
}
|
}
|
||||||
@ -1030,12 +1096,12 @@ IT_Parse($$)
|
|||||||
if (length($msg) == 19) {
|
if (length($msg) == 19) {
|
||||||
$dimCode=substr($msgcode,32,4);
|
$dimCode=substr($msgcode,32,4);
|
||||||
}
|
}
|
||||||
} elsif (length($msg) == 20 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy EU
|
} elsif ($ishe && length($msg) >= 18) { # HomeEasy EU
|
||||||
$onoffcode=substr($msgcode,46,2);
|
$onoffcode=substr($msgcode,46,2);
|
||||||
$groupBit=substr($msgcode,48,2);
|
$groupBit=substr($msgcode,48,2);
|
||||||
$unitCode=substr($msgcode,50,7);
|
$unitCode=substr($msgcode,50,7);
|
||||||
$housecode=substr($msgcode,0,46).$unitCode;
|
$housecode=substr($msgcode,0,46).$unitCode;
|
||||||
} elsif (length($msg) == 12 && (substr($msg, 1, 1)) eq 'h') { # HomeEasy HE800
|
} elsif ($ishe && length($msg) <= 12) { # HomeEasy HE800
|
||||||
#$housecode=substr($msgcode,0,6).substr($msgcode,26,2);
|
#$housecode=substr($msgcode,0,6).substr($msgcode,26,2);
|
||||||
#$onoffcode=0;
|
#$onoffcode=0;
|
||||||
|
|
||||||
@ -1093,7 +1159,7 @@ IT_Parse($$)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log3 $hash,4,"$ioname IT: Wrong IT message received: $msgcode";
|
Log3 $hash,4,"$ioname IT: Wrong IT message received: $msgcode";
|
||||||
return undef;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!defined($modules{IT}{defptr}{lc("$housecode")})) {
|
if(!defined($modules{IT}{defptr}{lc("$housecode")})) {
|
||||||
@ -1106,7 +1172,7 @@ IT_Parse($$)
|
|||||||
if (!defined($isEV1527)) { # itv1
|
if (!defined($isEV1527)) { # itv1
|
||||||
if ($onoffcode eq "F0") { # on code IT
|
if ($onoffcode eq "F0") { # on code IT
|
||||||
Log3 $hash,3,"$ioname IT: For autocreate please use the on button.";
|
Log3 $hash,3,"$ioname IT: For autocreate please use the on button.";
|
||||||
return undef;
|
return '';
|
||||||
}
|
}
|
||||||
$tmpOffCode = "F0";
|
$tmpOffCode = "F0";
|
||||||
$tmpOnCode = "0F";
|
$tmpOnCode = "0F";
|
||||||
@ -1123,7 +1189,7 @@ IT_Parse($$)
|
|||||||
$tmpOnCode = '0100';
|
$tmpOnCode = '0100';
|
||||||
}
|
}
|
||||||
return "UNDEFINED IT_$housecode IT $housecode $tmpOnCode $tmpOffCode" if(!$def);
|
return "UNDEFINED IT_$housecode IT $housecode $tmpOnCode $tmpOffCode" if(!$def);
|
||||||
} elsif (length($msg) == 20) { # HE_EU
|
} elsif ($ishe && length($msg) >= 18) { # HE_EU
|
||||||
my $isGroupCode = '0';
|
my $isGroupCode = '0';
|
||||||
if (($onoffcode == '01' && $groupBit == '01') || ($onoffcode == '00' && $groupBit == '11')) {
|
if (($onoffcode == '01' && $groupBit == '01') || ($onoffcode == '00' && $groupBit == '11')) {
|
||||||
# Group Code found
|
# Group Code found
|
||||||
@ -1132,7 +1198,7 @@ IT_Parse($$)
|
|||||||
Log3 $hash,2,"$ioname IT: $housecode not defined (Address: ".substr($msgcode,0,46)." Unit: $unitCode Switch code: $onoffcode GroupCode: $isGroupCode)";
|
Log3 $hash,2,"$ioname IT: $housecode not defined (Address: ".substr($msgcode,0,46)." Unit: $unitCode Switch code: $onoffcode GroupCode: $isGroupCode)";
|
||||||
#return "$housecode not defined (Address: ".substr($msgcode,0,26)." Group: $groupBit Unit: $unitCode Switch code: $onoffcode)!";
|
#return "$housecode not defined (Address: ".substr($msgcode,0,26)." Group: $groupBit Unit: $unitCode Switch code: $onoffcode)!";
|
||||||
return "UNDEFINED IT_$housecode IT " . substr($msgcode,0,46) . " $isGroupCode $unitCode" if(!$def);
|
return "UNDEFINED IT_$housecode IT " . substr($msgcode,0,46) . " $isGroupCode $unitCode" if(!$def);
|
||||||
} elsif (length($msg) == 12 && (substr($msg, 1, 1)) eq 'h') { # HE800
|
} elsif ($ishe && length($msg) <= 12) { # HE800
|
||||||
Log3 $hash,2,"$ioname IT: $housecode not defined (HE800)";
|
Log3 $hash,2,"$ioname IT: $housecode not defined (HE800)";
|
||||||
return "UNDEFINED IT_HE800_$housecode IT " . "HE800 $transmittercode $unitCode" if(!$def);
|
return "UNDEFINED IT_HE800_$housecode IT " . "HE800 $transmittercode $unitCode" if(!$def);
|
||||||
} else {
|
} else {
|
||||||
@ -1171,6 +1237,7 @@ IT_Parse($$)
|
|||||||
if ($def->{$name}->{READINGS}{protocol}{VAL} eq 'HE800') {
|
if ($def->{$name}->{READINGS}{protocol}{VAL} eq 'HE800') {
|
||||||
|
|
||||||
my %he800MapingTable = (
|
my %he800MapingTable = (
|
||||||
|
0 => 0,
|
||||||
2 => 12,
|
2 => 12,
|
||||||
3 => 25,
|
3 => 25,
|
||||||
4 => 37,
|
4 => 37,
|
||||||
@ -1213,7 +1280,10 @@ IT_Parse($$)
|
|||||||
# $newstate="on";
|
# $newstate="on";
|
||||||
#} els
|
#} els
|
||||||
if ($binVal == 0) {
|
if ($binVal == 0) {
|
||||||
$newstate="off";
|
$newstate='off';
|
||||||
|
}
|
||||||
|
elsif ($binVal == 100) {
|
||||||
|
$newstate='on';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elsif ($def->{$name}->{$it_c2b{"on"}} eq lc($onoffcode)) {
|
} elsif ($def->{$name}->{$it_c2b{"on"}} eq lc($onoffcode)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user