diff --git a/CHANGED b/CHANGED index 375d13b71..50fef7d20 100644 --- a/CHANGED +++ b/CHANGED @@ -1,4 +1,5 @@ 01.09.2019 + 14_SD_Keeloq.pm: fix shade function 14_SD_WS_Maverick.pm: feature: added support for device TFA 14.1504 changed: removed internals which are identical to readings diff --git a/FHEM/14_SD_Keeloq.pm b/FHEM/14_SD_Keeloq.pm index 447e7d0e9..2d271e46b 100644 --- a/FHEM/14_SD_Keeloq.pm +++ b/FHEM/14_SD_Keeloq.pm @@ -20,13 +20,14 @@ use POSIX; use Data::Dumper qw (Dumper); my %models = ( - "JaroLift" => { Button => { "up" => "1000", - "stop" => "0100", # new LearnVersion (2) - "down" => "0010", - "learn" => "0001", # old LearnVersion - "shade" => "0101", # 20x stop (stop with 20x repeats) mod to 15 repeats after test | old 0101 | other user 0100 ? - "shade_learn" => "", # 4x stop (stop 4x push) - "updown" => "1010" # new LearnVersion (1) + "JaroLift" => { Button => { "up" => "1000", # button + "stop" => "0100", # button - for learn (LearnVersion new, step 2) + "down" => "0010", # button + "learn" => "0001", # function - old LearnVersion + "shade" => "0101", # function - 20x stop (stop with 20x repeats) mod to 15 repeats after test + # manual - button Stop push 5 seconds (2012) + "shade_learn" => "", # function - 4x stop (stop 4x push) + "updown" => "1010" # buttons together - for learn (LearnVersion new, step 1) }, Channel => { 1 => "0000", 2 => "0001", @@ -57,8 +58,8 @@ my %models = ( }, Protocol => "P88", Typ => "remote" - }, - + }, + "RP_S1_HS_RF11" => { Button => { "one" => "1000", "two" => "0010", "one+two" => "1010" @@ -165,16 +166,16 @@ sub Define() { } else { $model = "unknown"; }; - + my $iodevice = $a[3] if($a[3]); $modules{SD_Keeloq}{defptr}{$hash->{DEF}} = $hash; my $ioname = $modules{SD_Keeloq}{defptr}{ioname} if (exists $modules{SD_Keeloq}{defptr}{ioname} && not $iodevice); $iodevice = $ioname if not $iodevice; - + $attr{$name}{room} = "SD_Keeloq" if ( not exists($attr{$name}{room}) ); $attr{$name}{model} = $model if ( not exists($attr{$name}{model}) ); - + AssignIoPort($hash, $iodevice); return undef; } @@ -216,18 +217,26 @@ sub Attr(@) { $attr{$name}{ChannelNames} = $attrValue; } - if ($attrName eq "Channels" && $attrValue == 0 && $addGroups eq "") { - return "ERROR: you can use Channels = $attrValue only with defined attribut addGroups!"; + if ($attrName eq "Channels") { + my $Channels = AttrVal($name, "Channels", ""); + return "ERROR: you can use Channels = $attrValue only with defined attribut addGroups!" if ($attrValue == 0 && $addGroups eq ""); + if ($Channels > $attrValue) { + foreach my $d (keys %{$hash->{READINGS}}) { + if ($d =~ /^LastAction_Channel_(\d+)/) { + readingsDelete($hash, $d) if ($1 > $attrValue); + } + } + } } - + if ($attrName eq "UI" && $attrValue eq "Einzeilig" && not exists $attr{$name}{Channels} && not exists $attr{$name}{ChannelFixed}) { setReadingsVal($hash,"DDSelected",1,FmtDateTime(time())); } - + if ($attrName eq "ChannelFixed"&& $attrValue > $attr{$name}{Channels}) { return "ERROR: your $attrName attribut with value $attrValue is wrong!\nIt is no compatible with ".$attr{$name}{Channels}." channel option."; } - + if ($attrName eq "Serial_send" && $attrValue !~ /^[0-9a-fA-F]{4}00/) { return "ERROR: your $attrName attribut with value $attrValue is wrong!\nOnly support values with 00 at END!"; } @@ -321,6 +330,7 @@ sub Set($$$@) { my $ret; my $cmd = $a[0]; + my $cmd_org = $cmd; my $cmd2 = $a[1]; ### Typ JaroLift ### @@ -434,7 +444,7 @@ sub Set($$$@) { } foreach my $i (1..$foreachCount) { - Log3 $name, 4, "$ioname: SD_Keeloq_Set - check, foreachCount=$foreachCount cmd=$cmd"; + Log3 $name, 4, "$ioname: SD_Keeloq_Set - check, foreachCount=$foreachCount function=$cmd_org cmd=$cmd"; ## LearnVersion new - part 1 if ($learning ne "old" && $cmd eq "learn" && $i == 1) { $cmd = "updown"; @@ -454,7 +464,8 @@ sub Set($$$@) { } $button = $cmd; - $buttonbits = $models{$model}{Button}{$cmd}; + $buttonbits = $models{$model}{Button}{$cmd} if ($cmd ne "shade"); + $buttonbits = $models{$model}{Button}{stop} if ($cmd eq "shade"); # for status shade my $learning_text = $learning eq "old" ? "send learn" : "send updown and additionally followed stop"; Log3 $name, 4, "$ioname: SD_Keeloq_Set - check, foreachLoop=$i LearnVersion=$learning ($learning_text)" if ((defined $cmd2 && $learning eq "old") || (defined $cmd2 && $learning eq "new")); @@ -564,7 +575,7 @@ sub Set($$$@) { ### Zusammenführen my $bits = reverse (sprintf("%032b", $encoded)).reverse($models{$model}{Channel}{$channel}).reverse($Serial_send).reverse($buttonbits).reverse($bit64to71); - + # special, command shade -> 20 repeats = 2,34 s | 15 repeats = 1,75s # userreport: 12 repeats ok https://github.com/HomeAutoUser/SD_Keeloq__old_Jaro/issues/9#issuecomment-524176737 $Repeats = 15 if ($cmd eq "shade"); @@ -583,7 +594,7 @@ sub Set($$$@) { Log3 $name, 5, "$ioname: SD_Keeloq_Set - Counter = $counter_send"; Log3 $name, 5, "$ioname: SD_Keeloq_Set - encoded (encrypt) = ".sprintf("%032b", $encoded)."\n"; - my $binsplit = SD_Keeloq_binsplit_JaroLift($bits); + my $binsplit = SD_Keeloq_binsplit_JaroLift($bits) if (AttrVal($name, "verbose", "3") eq "5"); Log3 $name, 5, "$ioname: SD_Keeloq_Set encoded <- | -> decrypts"; Log3 $name, 5, "$ioname: SD_Keeloq_Set Grp 0-7 |digitS/N| counter | ch | serial | bt |Grp 8-15"; @@ -690,7 +701,7 @@ sub Parse($$) { my $serialWithoutCh; my $model = "unknown"; my $devicedef; - + if ($hlen == 17) { $model = "unknown"; $serialWithoutCh = reverse (substr ($bitData , 32 , 28)); # 28bit serial @@ -774,7 +785,7 @@ sub Parse($$) { ($bit8to15) = @_ = ( reverse (substr ($bitData , 8 , 8)) , "encrypted" )[$encrypted]; # without MasterMSB | MasterLSB encrypted $bit64to71 = reverse (substr ($bitData , 64 , 8)); - $binsplit = SD_Keeloq_binsplit_JaroLift($bitData); + $binsplit = SD_Keeloq_binsplit_JaroLift($bitData) if (AttrVal($name, "verbose", "3") eq "5"); Log3 $name, 5, "$ioname: SD_Keeloq_Parse - typ = $model"; Log3 $name, 5, "$ioname: SD_Keeloq_Parse encoded <- | -> decrypts"; @@ -966,7 +977,7 @@ sub Parse($$) { Log3 $name, 5, "$ioname: SD_Keeloq_Parse - user_modus = $modus"; Log3 $name, 5, "$ioname: SD_Keeloq_Parse - user_info = $info"; Log3 $name, 5, "######## DEBUG END ########\n"; - + $VLOW = $VLOW eq "0" ? "ok" : "low" if (defined $VLOW); # only chip HCS301 - RP_S1_HS_RF11 | Roto | Waeco_MA650_TX $RPT = $RPT eq "0" ? "no" : "yes" if (defined $RPT); # only chip HCS301 - RP_S1_HS_RF11 | Roto | Waeco_MA650_TX @@ -1304,7 +1315,7 @@ sub SD_Keeloq_attr2htmlButtons($$$$$) { After entering the correct key, you will receive all states and the sending or controlling is possible!
An anchoring of the keys in the module is NOT included and everyone has to manage it himself.

- KeeLoq is a registered trademark of Microchip Technology Inc.-

- + The following devices are supported:
@@ -1468,7 +1479,7 @@ sub SD_Keeloq_attr2htmlButtons($$$$$) { Nach Eingabe der richtigen Schlüssel erhält man alle Zustände und das Senden bzw. steuern ist möglich!
Eine Verankerung der Schlüssel im Modul ist NICHT enthalten und jeder muss diese selbst verwalten.

- KeeLoq is a registered trademark of Microchip Technology Inc.-

- + Es werden bisher folgende Geräte unterstützt: