mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 03:06:37 +00:00
Integrated Rotary Switches
git-svn-id: https://svn.fhem.de/fhem/trunk@1706 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
bc1cc52b9c
commit
f5af0185a1
@ -21,6 +21,8 @@ my %codes = (
|
||||
|
||||
my %it_c2b;
|
||||
|
||||
my $it_defrepetition = 6; ## Default number of InterTechno Repetitions
|
||||
|
||||
my $it_simple ="off on";
|
||||
my %models = (
|
||||
itremote => 'sender',
|
||||
@ -43,7 +45,7 @@ IT_Initialize($)
|
||||
$hash->{DefFn} = "IT_Define";
|
||||
$hash->{UndefFn} = "IT_Undef";
|
||||
# $hash->{ParseFn} = "IT_Parse";
|
||||
$hash->{AttrList} = "IODev switch_rfmode:1,0 do_not_notify:1,0 ignore:0,1 dummy:1,0 model:itremote,itswitch,itdimmer loglevel:0,1,2,3,4,5,6";
|
||||
$hash->{AttrList} = "IODev ITfrequency ITrepetition switch_rfmode:1,0 do_not_notify:1,0 ignore:0,1 dummy:1,0 model:itremote,itswitch,itdimmer loglevel:0,1,2,3,4,5,6";
|
||||
|
||||
}
|
||||
|
||||
@ -91,6 +93,7 @@ IT_Set($@)
|
||||
my ($hash, @a) = @_;
|
||||
my $ret = undef;
|
||||
my $na = int(@a);
|
||||
my $message;
|
||||
|
||||
return "no set value specified" if($na < 2 || $na > 3);
|
||||
|
||||
@ -107,16 +110,11 @@ IT_Set($@)
|
||||
}
|
||||
return "Unknown argument $a[1], choose one of " .
|
||||
join(" ", sort keys %it_c2b);
|
||||
|
||||
}
|
||||
|
||||
return IT_Do_On_Till($hash, @a) if($a[1] eq "on-till");
|
||||
|
||||
return "Bad time spec" if($na == 3 && $a[2] !~ m/^\d*\.?\d+$/);
|
||||
|
||||
my $v = join(" ", @a);
|
||||
|
||||
my $message = "is".uc($hash->{XMIT}.$hash->{$c});
|
||||
my $io = $hash->{IODev};
|
||||
|
||||
## Do we need to change RFMode to SlowRF??
|
||||
@ -125,6 +123,28 @@ IT_Set($@)
|
||||
my $ret = CallFn($io->{NAME}, "AttrFn", "set", ($io->{NAME}, "rfmode", "SlowRF"));
|
||||
}
|
||||
}
|
||||
|
||||
## Do we need to change ITrepetition ??
|
||||
if(defined($attr{$a[0]}) && defined($attr{$a[0]}{"ITrepetition"})) {
|
||||
$message = "isr".$attr{$a[0]}{"ITrepetition"};
|
||||
CUL_SimpleWrite($io, $message);
|
||||
Log GetLogLevel($a[0],4), "IT set ITrepetition: $message for $io->{NAME}";
|
||||
}
|
||||
|
||||
## Do we need to change ITfrequency ??
|
||||
if(defined($attr{$a[0]}) && defined($attr{$a[0]}{"ITfrequency"})) {
|
||||
my $f = $attr{$a[0]}{"ITfrequency"}/26*65536;
|
||||
my $f2 = sprintf("%02x", $f / 65536);
|
||||
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);
|
||||
Log GetLogLevel($a[0],4), "Setting ITfrequency (0D,0E,0F) to $f2 $f1 $f0 = $arg MHz";
|
||||
CUL_SimpleWrite($hash, "if$f2$f1$f0");
|
||||
}
|
||||
|
||||
my $v = join(" ", @a);
|
||||
$message = "is".uc($hash->{XMIT}.$hash->{$c});
|
||||
|
||||
## Log that we are going to switch InterTechno
|
||||
Log GetLogLevel($a[0],2), "IT set $v";
|
||||
@ -138,6 +158,19 @@ IT_Set($@)
|
||||
Log 2, "IT IODev device didn't answer is command correctly: $msg";
|
||||
}
|
||||
|
||||
## Do we need to change ITrepetition back??
|
||||
if(defined($attr{$a[0]}) && defined($attr{$a[0]}{"ITrepetition"})) {
|
||||
$message = "isr".$it_defrepetition;
|
||||
CUL_SimpleWrite($io, $message);
|
||||
Log GetLogLevel($a[0],4), "IT set ITrepetition back: $message for $io->{NAME}";
|
||||
}
|
||||
|
||||
## Do we need to change ITfrequency back??
|
||||
if(defined($attr{$a[0]}) && defined($attr{$a[0]}{"ITfrequency"})) {
|
||||
Log GetLogLevel($a[0],4), "Setting ITfrequency back to 433.92 MHz";
|
||||
CUL_SimpleWrite($hash, "if0");
|
||||
}
|
||||
|
||||
## Do we need to change RFMode back to HomeMatic??
|
||||
if(defined($attr{$a[0]}) && defined($attr{$a[0]}{"switch_rfmode"})) {
|
||||
if ($attr{$a[0]}{"switch_rfmode"} eq "1") { # do we need to change RFMode of IODev
|
||||
@ -168,6 +201,37 @@ IT_Define($$)
|
||||
my ($hash, $def) = @_;
|
||||
my @a = split("[ \t][ \t]*", $def);
|
||||
|
||||
# calculate transmit code from IT A-P rotary switches
|
||||
if($a[2] =~ /^([A-O])(([0]{0,1}[1-9])|(1[0-6]))$/i) {
|
||||
my %it_1st = (
|
||||
"A","0000","B","F000","C","0F00","D","FF00","E","00F0","F","F0F0",
|
||||
"G","0FF0","H","FFF0","I","000F","J","F00F","K","0F0F","L","FF0F",
|
||||
"M","00FF","N","F0FF","O","0FFF","P","FFFF"
|
||||
);
|
||||
my %it_2nd = (
|
||||
1 ,"0000",2 ,"F000",3 ,"0F00",4 ,"FF00",5 ,"00F0",6 ,"F0F0",
|
||||
7 ,"0FF0",8 ,"FFF0",9 ,"000F",10,"F00F",11,"0F0F",12,"FF0F",
|
||||
13,"00FF",14,"F0FF",15,"0FFF",16,"FFFF"
|
||||
);
|
||||
|
||||
$a[2] = $it_1st{$1}.$it_2nd{int($2)}."0F";
|
||||
defined $a[3] or $a[3] = "FF";
|
||||
defined $a[4] or $a[4] = "F0";
|
||||
defined $a[5] or $a[5] = "0F";
|
||||
defined $a[6] or $a[6] = "00";
|
||||
}
|
||||
# calculate transmit code from FLS 100 I,II,III,IV rotary switches
|
||||
if($a[2] =~ /^(I|II|III|IV)([1-4])$/i) {
|
||||
my %fls_1st = ("I","0FFF","II","F0FF","III","FF0F","IV","FFF0" );
|
||||
my %fls_2nd = (1 ,"0FFF",2 ,"F0FF",3 ,"FF0F",4 ,"FFF0");
|
||||
|
||||
$a[2] = $fls_1st{$1}.$fls_2nd{int($2)}."0F";
|
||||
defined $a[3] or $a[3] = "FF";
|
||||
defined $a[4] or $a[4] = "F0";
|
||||
defined $a[5] or $a[5] = "0F";
|
||||
defined $a[6] or $a[6] = "00";
|
||||
}
|
||||
|
||||
my $u = "wrong syntax: define <name> IT 10-bit-housecode " .
|
||||
"off-code on-code [dimup-code] [dimdown-code]";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user