From c446788943589a3df86b50e50edaba447502a586 Mon Sep 17 00:00:00 2001 From: sidey79 Date: Wed, 20 Feb 2019 21:34:37 +0000 Subject: [PATCH] 14_SD_RSL.pm: added support for "all" button git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18675 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- CHANGED | 1 + FHEM/14_SD_RSL.pm | 180 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 127 insertions(+), 54 deletions(-) diff --git a/CHANGED b/CHANGED index 8a869180d..1b8d56d2d 100644 --- a/CHANGED +++ b/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 14_SD_RSL: Updated implementation for "all" button on devices - feature: 14_SD_WS: support sensors E0001PA,S522,TX-EZ6,other reading sendmode humidityTrend, temperatureTrend, windspeed, batteryState added diff --git a/FHEM/14_SD_RSL.pm b/FHEM/14_SD_RSL.pm index de798d40a..2f024ba8f 100644 --- a/FHEM/14_SD_RSL.pm +++ b/FHEM/14_SD_RSL.pm @@ -1,9 +1,11 @@ ########################################### -# SIGNALduini RSL Modul. Modified version of FHEMduino Modul by Wzut +# SIGNALduino RSL Modul. Modified version of FHEMduino Modul by Wzut # # $Id$ # Supports following devices: # - Conrad RSL +# Ralf9 2019 +# Sidey89 2019 ##################################### package main; @@ -15,41 +17,41 @@ my %sets = ( "on:noArg" => "", "off:noArg" => ""); my @RSLCodes; - # Tastenpaar [1 - 3] , Schiebeschalter/Kanal [I - IV] , an-aus [1 - 0] - $RSLCodes[0][0][0] = 62; # ? / ? off - $RSLCodes[0][0][1] = 54; # ? / ? on - $RSLCodes[1][1][0] = 1; # 1 / I off - $RSLCodes[1][1][1] = 14; # 1 / I on - $RSLCodes[1][2][0] = 46; # 2 / I off - $RSLCodes[1][2][1] = 38; # 2 / I on - $RSLCodes[1][3][0] = 30; # 3 / I off - $RSLCodes[1][3][1] = 22; # 3 / I on - $RSLCodes[1][4][0] = 53; # 4 / I off - nicht auf 12 Kanal FB - $RSLCodes[1][4][1] = 57; # 4 / I on - nicht auf 12 Kanal FB - $RSLCodes[2][1][0] = 13; # 1 / II off - $RSLCodes[2][1][1] = 5; # 1 / II on - $RSLCodes[2][2][0] = 37; # 2 / II off - $RSLCodes[2][2][1] = 41; # 2 / II on - $RSLCodes[2][3][0] = 21; # 3 / II off - $RSLCodes[2][3][1] = 25; # 3 / II on - $RSLCodes[2][4][0] = 56; # 4 / II off - nicht auf 12 Kanal FB - $RSLCodes[2][4][1] = 48; # 4 / II on - nicht auf 12 Kanal FB - $RSLCodes[3][1][0] = 4; # 1 / III off - $RSLCodes[3][1][1] = 8; # 1 / III on - $RSLCodes[3][2][0] = 40; # 2 / III off - $RSLCodes[3][2][1] = 32; # 2 / III on - $RSLCodes[3][3][0] = 24; # 3 / III off - $RSLCodes[3][3][1] = 16; # 3 / III on - $RSLCodes[3][4][0] = 50; # 4 / III off - nicht auf 12 Kanal FB - $RSLCodes[3][4][1] = 60; # 4 / III on - nicht auf 12 Kanal FB - $RSLCodes[4][1][0] = 10; # 1 / IV off - $RSLCodes[4][1][1] = 2; # 1 / IV on - $RSLCodes[4][2][0] = 34; # 2 / IV off - $RSLCodes[4][2][1] = 44; # 2 / IV on - $RSLCodes[4][3][0] = 18; # 3 / IV off - $RSLCodes[4][3][1] = 28; # 3 / IV on - $RSLCodes[4][4][0] = 35; # 4 / IV off - nicht auf 12 Kanal FB - $RSLCodes[4][4][1] = 19; # 4 / IV on - nicht auf 12 Kanal FB + # Schiebeschalter/Kanal [I - IV] , Tastenpaar [1 - 4] , an-aus [1 - 0] + $RSLCodes[0][0][0] = 0xBE; # ? / ? off + $RSLCodes[0][0][1] = 0xB6; # ? / ? on + $RSLCodes[1][1][0] = 0x81; # I 1 / off + $RSLCodes[1][1][1] = 0x8E; # I 1 / on + $RSLCodes[1][2][0] = 0xAE; # I 2 / off + $RSLCodes[1][2][1] = 0xA6; # I 2 / on + $RSLCodes[1][3][0] = 0x9E; # I 3 / off + $RSLCodes[1][3][1] = 0x96; # I 3 / on + $RSLCodes[1][4][0] = 0xB5; # I 4 / off - nicht auf 12 Kanal FB + $RSLCodes[1][4][1] = 0xB9; # I 4 / on - nicht auf 12 Kanal FB + $RSLCodes[2][1][0] = 0x8D; # II 1 / off + $RSLCodes[2][1][1] = 0x85; # II 1 / on + $RSLCodes[2][2][0] = 0xA5; # II 2 / off + $RSLCodes[2][2][1] = 0xA9; # II 2 / on + $RSLCodes[2][3][0] = 0x95; # II 3 / off + $RSLCodes[2][3][1] = 0x99; # II 3 / on + $RSLCodes[2][4][0] = 0xB8; # II 4 / off - nicht auf 12 Kanal FB + $RSLCodes[2][4][1] = 0xB0; # II 4 / on - nicht auf 12 Kanal FB + $RSLCodes[3][1][0] = 0x84; # III 1 / off + $RSLCodes[3][1][1] = 0x88; # III 1 / on + $RSLCodes[3][2][0] = 0xA8; # III 2 / off + $RSLCodes[3][2][1] = 0xA0; # III 2 / on + $RSLCodes[3][3][0] = 0x98; # III 3 / off + $RSLCodes[3][3][1] = 0x90; # III 3 / on + $RSLCodes[3][4][0] = 0xB2; # III 4 / off - nicht auf 12 Kanal FB + $RSLCodes[3][4][1] = 0xBC; # III 4 / on - nicht auf 12 Kanal FB + $RSLCodes[4][1][0] = 0x8A; # IV 1 / off + $RSLCodes[4][1][1] = 0x82; # IV 1 / on + $RSLCodes[4][2][0] = 0xA2; # IV 2 / off + $RSLCodes[4][2][1] = 0xAC; # IV 2 / on + $RSLCodes[4][3][0] = 0x92; # IV 3 / off + $RSLCodes[4][3][1] = 0x9C; # IV 3 / on + $RSLCodes[4][4][0] = 0xA3; # IV 4 / off All + $RSLCodes[4][4][1] = 0x93; # IV 4 / on All sub SD_RSL_Initialize($) { @@ -80,6 +82,10 @@ sub SD_RSL_Define($$) my $name = $a[0]; my ($device,$channel,$button) = split("_",$a[2]); + if ($channel eq "ALL") { + $channel = 4; + $button = 4; + } return "wrong syntax: use channel 1 - 4" if(($channel > 4)); # || ($channel < 1 )); return "wrong syntax: use button 1 - 4" if(($button > 4)); # || ($button < 1)); return "wrong syntax: use code 000000 - FFFFFF" if (length($device) != 6); @@ -93,8 +99,8 @@ sub SD_RSL_Define($$) # code auf 32Bit umrechnen int 16777216 = 0x1000000 #$hash->{OnCode} = ($RSLCodes[$channel][$button][1]*16777216) + hex($device); #$hash->{OffCode} = ($RSLCodes[$channel][$button][0]*16777216) + hex($device); - $hash->{OnCode} = "10" . sprintf('%06b', ($RSLCodes[$channel][$button][1])) . sprintf('%24b',hex($device)); - $hash->{OffCode} = "10" . sprintf('%06b', ($RSLCodes[$channel][$button][0])) . sprintf('%24b',hex($device)); + $hash->{OnCode} = sprintf('%02X', ($RSLCodes[$channel][$button][1])); + $hash->{OffCode} = sprintf('%02X', ($RSLCodes[$channel][$button][0])); AssignIoPort($hash); @@ -106,9 +112,12 @@ sub SD_RSL_Set($@) { my ($hash, @a) = @_; my $name = $hash->{NAME}; + my $ioHash = $hash->{IODev}; + my $ioName = $ioHash->{NAME}; my $cmd = $a[1]; my $c; my $message; + my $device = substr($hash->{DEF},0,6); return join(" ", sort keys %sets) if((@a < 2) || ($cmd eq "?")); @@ -117,10 +126,9 @@ sub SD_RSL_Set($@) return "Unknown argument $cmd, choose on or off" if(!$c); - my $io = $hash->{IODev}; ## Send Message to IODev using IOWrite - $message = 'P1#' . $c . '#R' . AttrVal($name, "RSLrepetition", 6); - Log3 $name, 4, $io->{NAME} . " RSL_SET_sendCommand: $name -> message: $message"; + $message = 'P1#0x' . $c . $device . '#R' . AttrVal($name, "RSLrepetition", 6); + Log3 $name, 4, "$ioName RSL_SET_sendCommand: $name -> message: $message"; IOWrite($hash, 'sendMsg', $message); #my $ret = IOWrite($hash, 'sendMsg', $c."_".AttrVal($name, "RSLrepetition", 6)); #Log3 $hash, 5, "$name Set return : $ret"; @@ -151,14 +159,14 @@ sub RSL_getButtonCode($$) ## Groupcode $DeviceCode = substr($msg,2,6); $receivedButtonCode = substr($msg,0,2); - Log3 $hash, 5, "SD_RSL Message Devicecode: $DeviceCode Buttoncode: $receivedButtonCode"; + Log3 $hash, 4, "SD_RSL Message Devicecode: $DeviceCode Buttoncode: $receivedButtonCode"; if ((hex($receivedButtonCode) & 0xc0) != 0x80) { Log3 $hash, 4, "SD_RSL Message Error: received Buttoncode $receivedButtonCode begins not with bin 10"; return ""; } - $parsedButtonCode = hex($receivedButtonCode) & 63; # nur 6 Bit bitte - Log3 $hash, 4, "SD_RSL Message parsed Devicecode: $DeviceCode Buttoncode: $parsedButtonCode"; + $parsedButtonCode = hex($receivedButtonCode); # & 63; # nur 6 Bit bitte + Log3 $hash, 5, "SD_RSL Message parsed Devicecode: $DeviceCode Buttoncode: $parsedButtonCode"; for (my $i=0; $i<5; $i++) { @@ -176,7 +184,12 @@ sub RSL_getButtonCode($$) if (($button >-1) && ($channel > -1)) { Log3 $hash, 4, "RSL button return/result: ID: $DeviceCode $receivedButtonCode DEVICE: $DeviceCode $channel $button ACTION: $action"; - return $DeviceCode."_".$channel."_".$button." ".$action; + if ($channel == 4 && $button == 4) { + return $DeviceCode."_ALL ".$action; + } + else { + return $DeviceCode."_".$channel."_".$button." ".$action; + } } return ""; @@ -205,7 +218,7 @@ sub SD_RSL_Parse($$) if(!$def) { - Log3 $hash, 3, "UNDEFINED Remotebutton send to define: $deviceCode"; + Log3 $hash, 3, "$name RSL_Parse UNDEFINED Remotebutton send to define: $deviceCode"; return "UNDEFINED RSL_$deviceCode SD_RSL $deviceCode"; } @@ -252,8 +265,8 @@ sub SD_RSL_Attr(@) my $hash = $defs{$a[1]}; my $iohash = $defs{$a[3]}; my $cde = $hash->{DEF}; - delete($modules{SIGNALduino_FA20RF}{defptr}{$cde}); - $modules{SIGNALduino_FA20RF}{defptr}{$iohash->{NAME} . "." . $cde} = $hash; + delete($modules{SD_RSL}{defptr}{$cde}); + $modules{SD_RSL}{defptr}{$iohash->{NAME} . "." . $cde} = $hash; return undef; } @@ -267,20 +280,23 @@ sub SD_RSL_Attr(@)

RSL

-The SD_RSL module decrypts and sends Conrad RSL messages sent by the SIGNALduino.
+The SD_RSL module decrypts and creates Conrad RSL messages sent / received by a SIGNALduino device.
+If autocreate is used, a device "<code>_ALL" like RSL_74A400_ALLis created instead of channel and button = 4.
+
Define
Attribute =end html -=cut \ No newline at end of file + +=begin html_DE + + +

RSL

+Das SD_RSL-Modul decodiert und erstellt Conrad-RSL-Nachrichten, die vom SIGNALduino gesendet bzw. empfangen werden.
+Beim Verwendung von Autocreate wird bei der Taste All anstatt channel und button = 4 "<code>_ALL" angelegt, z.B. RSL_74A400_ALL
+
+ +Define + + +Set + + +Get +
+ +Attribute + +=end html_DE + +=cut