diff --git a/fhem/FHEM/00_CUL.pm b/fhem/FHEM/00_CUL.pm index 15553f026..00c1c5e28 100755 --- a/fhem/FHEM/00_CUL.pm +++ b/fhem/FHEM/00_CUL.pm @@ -25,6 +25,7 @@ my %gets = ( # Name, Data to send to the CUL, Regexp for the answer "raw" => ["", '.*'], "uptime" => ["t", '^[0-9A-F]{8}[\r\n]*$' ], "fhtbuf" => ["T03", '^[0-9A-F]+[\r\n]*$' ], + "cmds" => ["?", '.*Use one of[ 0-9A-Za-z]+[\r\n]*$' ], ); my %sets = ( @@ -142,6 +143,7 @@ CUL_Define($$) } $hash->{FHTID} = uc($a[3]); $hash->{initString} = "X21"; + $hash->{CMDS} = ""; $hash->{Clients} = $clientsSlowRF; $hash->{MatchList} = \%matchListSlowRF; @@ -460,6 +462,9 @@ READEND: DevIo_Disconnected($hash); $msg = "No answer"; + } elsif($a[1] eq "cmds") { # nice it up + $msg =~ s/.*Use one of//g; + } elsif($a[1] eq "uptime") { # decode it $msg =~ s/[\r\n]//g; $msg = hex($msg)/125; @@ -525,6 +530,14 @@ CUL_DoInit($) CUL_SimpleWrite($hash, $msg); } + # Cmd-String feststellen + + my $cmds = CUL_Get($hash, $name, "cmds", 0); + $cmds =~ s/$name cmds =>//g; + $cmds =~ s/ //g; + $hash->{CMDS} = $cmds; + Log 3, "$name: Possible commands: " . $hash->{CMDS}; + CUL_SimpleWrite($hash, $hash->{initString}); # FHTID @@ -960,27 +973,41 @@ CUL_Attr(@) my $hash = $defs{$name}; $a[3] = "SlowRF" if(!$a[3] || ($a[3] ne "HomeMatic" && $a[3] ne "MAX")); + my $msg = $hash->{NAME} . ": Mode $a[3] not supported"; if($a[3] eq "HomeMatic") { return if($hash->{initString} =~ m/Ar/); - $hash->{Clients} = $clientsHomeMatic; - $hash->{MatchList} = \%matchListHomeMatic; - $hash->{initString} = "X21\nAr"; # X21 is needed for RSSI reporting - CUL_SimpleWrite($hash, $hash->{initString}); + if(($hash->{CMDS} =~ m/A/) || IsDummy($hash->{NAME})) { + $hash->{Clients} = $clientsHomeMatic; + $hash->{MatchList} = \%matchListHomeMatic; + CUL_SimpleWrite($hash, "Zx") if ($hash->{CMDS} =~ m/Z/); # reset Moritz + $hash->{initString} = "X21\nAr"; # X21 is needed for RSSI reporting + CUL_SimpleWrite($hash, $hash->{initString}); + } else { + Log 2, $msg; + return $msg; + } } elsif($a[3] eq "MAX") { return if($hash->{initString} =~ m/Zr/); - $hash->{Clients} = $clientsMAX; - $hash->{MatchList} = \%matchListMAX; - $hash->{initString} = "X21\nZr"; # X21 is needed for RSSI reporting - CUL_SimpleWrite($hash, $hash->{initString}); + if(($hash->{CMDS} =~ m/Z/) || IsDummy($hash->{NAME})) { + $hash->{Clients} = $clientsMAX; + $hash->{MatchList} = \%matchListMAX; + CUL_SimpleWrite($hash, "Ax") if ($hash->{CMDS} =~ m/A/); # reset AskSin + $hash->{initString} = "X21\nZr"; # X21 is needed for RSSI reporting + CUL_SimpleWrite($hash, $hash->{initString}); + } else { + Log 2, $msg; + return $msg; + } } else { return if($hash->{initString} eq "X21"); $hash->{Clients} = $clientsSlowRF; $hash->{MatchList} = \%matchListSlowRF; $hash->{initString} = "X21"; - CUL_SimpleWrite($hash, "Ax"); # reset AskSin + CUL_SimpleWrite($hash, "Ax") if ($hash->{CMDS} =~ m/A/); # reset AskSin + CUL_SimpleWrite($hash, "Zx") if ($hash->{CMDS} =~ m/Z/); # reset Moritz CUL_SimpleWrite($hash, $hash->{initString}); } diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index 07a8679f2..2dc3846a2 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -2820,6 +2820,13 @@ A line ending with \ will be concatenated with the next one, so long lines Read some CUL radio-chip (cc1101) registers (frequency, bandwidth, etc), and display them in human readable form. </li><br> + + <li>cmds<br> + Depending on the firmware installed, CULs have a different set of + possible commands. Please refer to the README of the firmware of your + CUL to interpret the response of this command. See also the raw- + command. + </li><br> </ul> <a name="CULattr"></a>