From 6748a5288972de2d72bf57730357183c88f2b16b Mon Sep 17 00:00:00 2001 From: HomeAutoUser Date: Mon, 18 Mar 2019 18:03:09 +0100 Subject: [PATCH 1/6] SD_UT - added new models - revised code for Tedsen - user with many buttons on remote answered on forum https://forum.fhem.de/index.php/topic,39153.0.html - two protocols from one production, revised so we have only one (multiple names for a product) --- CHANGED | 4 + FHEM/14_SD_UT.pm | 149 ++++++++++++++++++++++++++++-------- FHEM/lib/SD_ProtocolData.pm | 117 +++++++++++++++++----------- 3 files changed, 196 insertions(+), 74 deletions(-) diff --git a/CHANGED b/CHANGED index 744af408d..852bd6ca5 100644 --- a/CHANGED +++ b/CHANGED @@ -1,3 +1,7 @@ +18.03.2019 + 14_SD_UT.pm: revised Tedsen models | TEDSEN_SKX1MD OLD rename to TEDSEN_SKX1xx because other new models TEDSEN_SKX2xx,TEDSEN_SKX4xx,TEDSEN_SKX6xx + !! Old model TEDSEN_SKX1MD delete and autocreate to TEDSEN_SKX1xx | remotes with different number of buttons !! + signalduino_protocols.pm: revised ID46 and ID78 (GEIGER blind motors) removed | ID 46 is now Tedsen remote for Berner Garagentorantrieb GA401 and Geiger Antriebstechnik Rolladensteuerung) 16.03.2019 00_SIGNALduino.pm revised doc sendMSG 12.03.2019 diff --git a/FHEM/14_SD_UT.pm b/FHEM/14_SD_UT.pm index 63aae6f7d..4dae0c352 100644 --- a/FHEM/14_SD_UT.pm +++ b/FHEM/14_SD_UT.pm @@ -128,7 +128,15 @@ # - Berner Garagentorantrieb GA401 | remote TEDSEN SKX1MD 433.92 MHz - 1 button | settings via 9 switch on battery compartment [Protocol 46] #{ compatible with doors: BERNER SKX1MD, ELKA SKX1MD, TEDSEN SKX1LC, TEDSEN SKX1 # https://github.com/RFD-FHEM/RFFHEM/issues/91 -#} get sduino_dummy raw MU;;P0=-15829;;P1=-3580;;P2=1962;;P3=-330;;P4=245;;P5=-2051;;D=1234523232345234523232323234523234540023452323234523452323232323452323454023452323234523452323232323452323454023452323234523452323232323452323454023452323234523452323232323452323454023452323234523452323;;CP=2;; +# get sduino_dummy raw MU;;P0=-15829;;P1=-3580;;P2=1962;;P3=-330;;P4=245;;P5=-2051;;D=1234523232345234523232323234523234540023452323234523452323232323452323454023452323234523452323232323452323454023452323234523452323232323452323454023452323234523452323232323452323454023452323234523452323;;CP=2;; +# GEIGER GF0001, 2 Button, DIP-Schalter: + 0 + - + + - 0 0 +# https://forum.fhem.de/index.php/topic,39153.0.html +# rauf: MU;P0=-32001;P1=2072;P2=-260;P3=326;P4=-2015;P5=-15769;D=01212123412123434121212123434123412351212123412123434121212123434123412351212123412123434121212123434123412351212123412123434121212123434123412351212123412123434121212123434123412351212123412123434121212123434123412351212123412123434121212123434123412351;CP=3;R=37;O; +# runter: MU;P0=-15694;P1=2009;P2=-261;P3=324;P4=-2016;D=01212123412123434121212123434123434301212123412123434121212123434123434301212123412123434121212123434123434301212123412123434121212123434123434301212123412123434121212123434123434301;CP=3;R=30; +# ??? +# MU;P0=313;P1=1212;P2=-309;P4=-2024;P5=-16091;P6=2014;D=01204040562620404626204040404040462046204040562620404626204040404040462046204040562620404626204040404040462046204040562620404626204040404040462046204040;CP=0;R=236; +# MU;P0=-15770;P1=2075;P2=-264;P3=326;P4=-2016;P5=948;D=012121234121234341212121234341234343012125;CP=3;R=208; +#} ############################################################################################################################################################################### # - Chilitec Großhandel 22640 - LED Christbaumkerzen mit Fernbedienung #{ Taste -: AA802 0010 brightness_minus @@ -302,8 +310,8 @@ my %models = ( "00111100" => "Ch4_off", "00001111" => "Master_on", "00011110" => "Master_off", - "00010100" => "Unknown_on", - "00000101" => "Unknown_off", + "00010100" => "Unknown_up", + "00000101" => "Unknown_down", hex_lengh => "5", Protocol => "P34", Typ => "remote" @@ -351,7 +359,31 @@ my %models = ( Protocol => "P81", Typ => "remote" }, - "TEDSEN_SKX1MD" => { "0" => "send", + "Tedsen_SKX1xx" => { "1100" => "Button_1", # tristate 10 + hex_lengh => "5", + Protocol => "P46", + Typ => "remote" + }, + "Tedsen_SKX2xx" => { "1000" => "Button_1", # tristate F0 = GEIGER Ab: 0- + "1010" => "Button_2", # tristate FF = GEIGER Auf: 00 + hex_lengh => "5", + Protocol => "P46", + Typ => "remote" + }, + "Tedsen_SKX4xx" => { "1000" => "Button_1", # tristate F0 = GEIGER Ab: 0- + "1010" => "Button_2", # tristate FF = GEIGER Auf: 00 + "0000" => "Button_3", # tristate 00 = GEIGER Ab: -- + "0010" => "Button_4", # tristate 0F = GEIGER Auf: -0 + hex_lengh => "5", + Protocol => "P46", + Typ => "remote" + }, + "Tedsen_SKX6xx" => { "1000" => "Button_1", # tristate F0 = GEIGER Ab: 0- + "1010" => "Button_2", # tristate FF = GEIGER Auf: 00 + "0000" => "Button_3", # tristate 00 = GEIGER Ab: -- + "0010" => "Button_4", # tristate 0F = GEIGER Auf: -0 + "1110" => "Button_5", # tristate 1F = GEIGER Ab: +0 + "1011" => "Button_6", # tristate F1 = GEIGER Auf: 0+ hex_lengh => "5", Protocol => "P46", Typ => "remote" @@ -482,12 +514,12 @@ sub SD_UT_Define($$) { return "wrong HEX-Value! ($a[3]) $a[2] HEX-Value to short | long or not HEX (0-9 | a-f | A-F){4}"; } - ### [5] checks TEDSEN_SKX1MD ### - return "wrong HEX-Value! ($a[3]) $a[2] HEX-Value to short | long or not HEX (0-9 | a-f | A-F){5}" if ($a[2] eq "TEDSEN_SKX1MD" && not $a[3] =~ /^[0-9a-fA-F]{5}/s); ### [6] checks MD_2003R | MD_210R | MD_2018R ### return "wrong HEX-Value! ($a[3]) $a[2] HEX-Value to short | long or not HEX (0-9 | a-f | A-F){6}" if (($a[2] eq "MD_2003R" || $a[2] eq "MD_210R" || $a[2] eq "MD_2018R") && not $a[3] =~ /^[0-9a-fA-F]{6}/s); ### [7] checks Hoermann HSM4 | Krinner_LUMIX ### return "wrong HEX-Value! ($a[3]) $a[2] HEX-Value to short | long or not HEX (0-9 | a-f | A-F){7}" if (($a[2] eq "HSM4" || $a[2] eq "Krinner_LUMIX") && not $a[3] =~ /^[0-9a-fA-F]{7}/s); + ### [7] checks Tedsen_SKX1xx, Tedsen_SKX2xx, Tedsen_SKX4xx, Tedsen_SKX6xx (tristate code)### + return "wrong tristate code! ($a[3]) $a[2] code to short | long or values not 0, 1 or F" if (($a[2] eq "Tedsen_SKX1xx" || $a[2] eq "Tedsen_SKX2xx" || $a[2] eq "Tedsen_SKX4xx" || $a[2] eq "Tedsen_SKX6xx") && not $a[3] =~ /^[01fF]{7}$/s); ### [9] checks Hoermann HS1-868-BS ### return "wrong HEX-Value! ($a[3]) $a[2] HEX-Value to short | long or not HEX (0-9 | a-f | A-F){9}" if ($a[2] eq "HS1_868_BS" && not $a[3] =~ /^[0-9a-fA-F]{9}/s); ### [14] checks LED_XM21_0 ### @@ -548,11 +580,12 @@ sub SD_UT_Set($$$@) { my @definition = split(" ", $hash->{DEF}); # split adress from def my $bitData = sprintf( "%012b", hex($definition[1])) if ($name ne "unknown"); # argument 1 - adress to binary with 12 digits $msg = $models{$model}{Protocol} . "#" . $bitData . "#R" . $repeats; - ############ TEDSEN_SKX1MD ############ - } elsif ($model eq "TEDSEN_SKX1MD" && $cmd ne "?") { - my @definition = split(" ", $hash->{DEF}); # split adress from def - my $bitData = sprintf( "%020b", hex($definition[1])) if ($name ne "unknown"); # argument 1 - adress to binary with 20 digits - $msg = $models{$model}{Protocol} . "#" . $bitData . "#R" . $repeats; + ############ Tedsen_SKX1xx, Tedsen_SKX2xx, Tedsen_SKX4xx, Tedsen_SKX6xx ############ + } elsif (($model eq "Tedsen_SKX1xx" || $model eq "Tedsen_SKX2xx" || $model eq "Tedsen_SKX4xx" || $model eq "Tedsen_SKX6xx") && $cmd ne "?") { + my @definition = split(" ", $hash->{DEF}); # split adress from def + my $adr = SD_UT_tristate2bin($definition[1]); # argument 1 - adress tristate to bin with 18 bits + $msg = $models{$model}{Protocol} . "#" . $adr; + $msgEnd = "#R" . $repeats; ############ QUIGG_DMV ############ } elsif ($model eq "QUIGG_DMV" && $cmd ne "?") { my @definition = split(" ", $hash->{DEF}); # split adress from def @@ -610,7 +643,7 @@ sub SD_UT_Set($$$@) { ############ Krinner_LUMIX ############ } elsif ($model eq "Krinner_LUMIX" && $cmd ne "?") { my @definition = split(" ", $hash->{DEF}); # split adress from def - my $adr = sprintf( "%028b", hex($definition[1])) if ($name ne "unknown"); # argument 1 - adress to binary with 14 digits + my $adr = sprintf( "%028b", hex($definition[1])) if ($name ne "unknown"); # argument 1 - adress to binary with 28 digits $msg = $models{$model}{Protocol} . "#" . $adr; $msgEnd .= "#R" . $repeats; ############ Manax ############ @@ -619,7 +652,7 @@ sub SD_UT_Set($$$@) { ############ ESTO KL_RF01############ } elsif ($model eq "KL_RF01" && $cmd ne "?") { my @definition = split(" ", $hash->{DEF}); # split adress from def - my $adr = sprintf( "%016b", hex($definition[1])) if ($name ne "unknown"); # argument 1 - adress to binary with 14 digits + my $adr = sprintf( "%016b", hex($definition[1])) if ($name ne "unknown"); # argument 1 - adress to binary with 16 digits $msg = $models{$model}{Protocol} . "#" . $adr; $msgEnd .= "11110"; # nibble7 every? $msgEnd .= "#R" . $repeats; @@ -708,6 +741,7 @@ sub SD_UT_Parse($$) { my $sabotage; # MD_210R my $batteryState; my $state = "unknown"; + my $tristateCode; my $unknown_bits; # unknown bits to a reading my $deletecache = $modules{SD_UT}{defptr}{deletecache}; @@ -783,11 +817,17 @@ sub SD_UT_Parse($$) { $devicedef = "TR_502MSV " . $deviceCode; $def = $modules{SD_UT}{defptr}{$devicedef}; } - ### Remote control TEDSEN_SKX1MD [P46] ### + ### Remote control Tedsen_SKX2xx [P46] ### if (!$def && $protocol == 46) { - $deviceCode = $rawData; - $devicedef = "TEDSEN_SKX1MD " . $deviceCode; - $def = $modules{SD_UT}{defptr}{$devicedef}; + $deviceCode = SD_UT_bin2tristate(substr($bitData,0,14)); # only 14 bit from bitdata to tristate + $devicedef = "Tedsen_SKX1xx " . $deviceCode if (!$def); + $def = $modules{SD_UT}{defptr}{$devicedef} if (!$def); + $devicedef = "Tedsen_SKX2xx " . $deviceCode if (!$def); + $def = $modules{SD_UT}{defptr}{$devicedef} if (!$def); + $devicedef = "Tedsen_SKX4xx " . $deviceCode if (!$def); + $def = $modules{SD_UT}{defptr}{$devicedef} if (!$def); + $devicedef = "Tedsen_SKX6xx " . $deviceCode if (!$def); + $def = $modules{SD_UT}{defptr}{$devicedef} if (!$def); } ### NEFF SF01_01319004 || BOSCH SF01_01319004_Typ2 [P86] ### if (!$def && $protocol == 86) { @@ -972,9 +1012,11 @@ sub SD_UT_Parse($$) { $usersystem = "Unitec 47125" if (oct("0b".$zone) == 7); } Log3 $name, 5, "$ioname: SD_UT_Parse devicedef=$devicedef attr_model=$model protocol=$protocol deviceCode=$deviceCode state=$state Zone=$zone"; - ############ TEDSEN_SKX1MD ############ Protocol 46 ############ - } elsif ($model eq "TEDSEN_SKX1MD" && $protocol == 46) { - $state = "receive"; + ############ Tedsen_SKX1xx, Tedsen_SKX2xx, Tedsen_SKX4xx, Tedsen_SKX6xx ############ Protocol 46 ############ + } elsif (($model eq "Tedsen_SKX1xx" || $model eq "Tedsen_SKX2xx" || $model eq "Tedsen_SKX4xx" || $model eq "Tedsen_SKX6xx") && $protocol == 46) { + $state = substr($bitData,14,4); + $tristateCode = SD_UT_bin2tristate(substr($bitData,0,-2)); # only 18 bit from bitdata + Log3 $iohash, 4, "$ioname: SD_UT_Parse $model - converted to tristate $tristateCode"; ############ SA_434_1_mini ############ Protocol 81 ############ } elsif ($model eq "SA_434_1_mini" && ($protocol == 81 || $protocol == 83 || $protocol == 86)) { $state = "receive"; @@ -1113,6 +1155,7 @@ sub SD_UT_Parse($$) { readingsBulkUpdate($hash, "Usersystem", $usersystem, 0) if (defined($zoneRead) && $model eq "Unitec_47031"); readingsBulkUpdate($hash, "LastAction", "receive", 0) if (defined($state) && $models{$model}{Typ} eq "remote" && ($model ne "SA_434_1_mini" || $model ne "HS1_868_BS")); readingsBulkUpdate($hash, "state", $state) if (defined($state) && $state ne "unknown"); + readingsBulkUpdate($hash, "tristateCode", $tristateCode) if (defined($tristateCode)); readingsEndUpdate($hash, 1); # Notify is done by Dispatch return $name; @@ -1177,9 +1220,9 @@ sub SD_UT_Attr(@) { } elsif ($attrName eq "model" && $attrValue eq "SA_434_1_mini") { $deviceCode = sprintf("%03X", oct( "0b$bitData" ) ); $devicename = $devicemodel."_".$deviceCode; - ############ TEDSEN_SKX1MD ############ - } elsif ($attrName eq "model" && $attrValue eq "TEDSEN_SKX1MD") { - $deviceCode = sprintf("%05X", oct( "0b$bitData" ) ); + ############ Tedsen_SKX1xx, Tedsen_SKX2xx, Tedsen_SKX4xx, Tedsen_SKX6xx ############ + } elsif ($attrName eq "model" && ($attrValue eq "Tedsen_SKX1xx" || $attrValue eq "Tedsen_SKX2xx" || $attrValue eq "Tedsen_SKX4xx" || $attrValue eq "Tedsen_SKX6xx")) { + $deviceCode = SD_UT_bin2tristate(substr($bitData,0,14)); # only 14 bit from bitdata to tristate $devicename = $devicemodel."_".$deviceCode; ############ Unitec_47031 ############ } elsif ($attrName eq "model" && $attrValue eq "Unitec_47031") { @@ -1286,6 +1329,36 @@ sub SD_UT_Attr(@) { return undef; } +################################### +sub SD_UT_bin2tristate($) { + my $bitData = shift; + my %bintotristate=( + "00" => "0", + "10" => "F", + "11" => "1" + ); + my $tscode; + for (my $n=0; $n < length($bitData); $n = $n + 2) { + $tscode = $tscode . $bintotristate{substr($bitData,$n,2)}; + } + return $tscode; +} + +################################### +sub SD_UT_tristate2bin($) { + my $tsData = shift; + my %tristatetobin=( + "0" => "00", + "F" => "10", + "1" => "11" + ); + my $bitData; + for (my $n=0; $n < length($tsData); $n++) { + $bitData = $bitData . $tristatetobin{substr($tsData,$n,1)}; + } + return $bitData; +} + ################################### 1; @@ -1319,7 +1392,14 @@ sub SD_UT_Attr(@) { - + @@ -1430,7 +1510,7 @@ sub SD_UT_Attr(@) { button O on the remote
- +
-