Skip to content

Commit

Permalink
Decoding protocol 22
Browse files Browse the repository at this point in the history
HAMULiGHT LED transformer, see #1206
  • Loading branch information
elektron-bbs committed Dec 10, 2023
1 parent d3dd2d7 commit c4458ed
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 29 deletions.
2 changes: 1 addition & 1 deletion FHEM/00_SIGNALduino.pm
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ my %matchListSIGNALduino = (
'14:Dooya' => '^P16#[A-Fa-f0-9]+',
'15:SOMFY' => '^Ys[0-9A-F]+',
'16:SD_WS_Maverick' => '^P47#[A-Fa-f0-9]+',
'17:SD_UT' => '^P(?:14|20|24|26|29|30|34|46|56|68|69|76|78|81|83|86|90|91|91.1|92|93|95|97|99|104|105|114|118|121|127|128|130)#.*', # universal - more devices with different protocols
'17:SD_UT' => '^P(?:14|20|22|24|26|29|30|34|46|56|68|69|76|78|81|83|86|90|91|91.1|92|93|95|97|99|104|105|114|118|121|127|128|130)#.*', # universal - more devices with different protocols
'18:FLAMINGO' => '^P13\.?1?#[A-Fa-f0-9]+', # Flamingo Smoke
'19:CUL_WS' => '^K[A-Fa-f0-9]{5,}',
'20:Revolt' => '^r[A-Fa-f0-9]{22}',
Expand Down
93 changes: 73 additions & 20 deletions FHEM/14_SD_UT.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#########################################################################################
# $Id: 14_SD_UT.pm 0 2023-10-02 18:00:00Z elektron-bbs $
# $Id: 14_SD_UT.pm 0 2023-12-10 18:00:00Z elektron-bbs $
#
# The file is part of the SIGNALduino project.
# The purpose of this module is universal support for devices.
Expand Down Expand Up @@ -425,6 +425,14 @@
# CREATE_6601TL_F53A fan_faster MS;P0=-11884;P1=392;P2=-1179;P3=1180;P4=-391;D=10121212123412341234341212123412341212121212341234;CP=1;SP=0;R=231;O;m2;
#}
###############################################################################################################################################################################
# - Hamulight remote control for ab sets 1-channel [Protocol 22]
#{ elektron-bbs 2023-12-10
# https://github.com/RFD-FHEM/RFFHEM/issues/1206 @ obduser 2023-12-09
# Hamulight_AB
#
#
#}
###############################################################################################################################################################################
# !!! ToDo´s !!!
# - LED lights, counter battery-h reading --> commandref hour_counter module
# -
Expand Down Expand Up @@ -1022,6 +1030,15 @@ my %models = (
Protocol => 'P118',
Typ => 'remote'
},
'Hamulight_AB' => { '01011111' => 'on_off',
'01010101' => 'dim_1',
'01010110' => 'dim_2',
'01010000' => 'dim_3',
'01011001' => 'dim_4',
hex_length => [8],
Protocol => 'P22',
Typ => 'remote'
},
'unknown' => { Protocol => 'any',
hex_length => [],
Typ => 'not_exist'
Expand All @@ -1031,7 +1048,7 @@ my %models = (
#############################
sub SD_UT_Initialize {
my ($hash) = @_;
$hash->{Match} = '^P(?:14|20|24|26|29|30|34|46|56|68|69|76|78|81|83|86|90|91|91\.1|92|93|95|97|99|104|105|114|118|121|127|128|130)#.*';
$hash->{Match} = '^P(?:14|20|22|24|26|29|30|34|46|56|68|69|76|78|81|83|86|90|91|91\.1|92|93|95|97|99|104|105|114|118|121|127|128|130)#.*';
$hash->{DefFn} = \&SD_UT_Define;
$hash->{UndefFn} = \&SD_UT_Undef;
$hash->{ParseFn} = \&SD_UT_Parse;
Expand All @@ -1042,20 +1059,21 @@ sub SD_UT_Initialize {
" $readingFnAttributes UTclock UTfrequency";
$hash->{AutoCreate} =
{
'AC114_01B.*' => {ATTR => 'model:AC114_01B', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'BF_301.*' => {ATTR => 'model:BF_301', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'MD_2003R.*' => {ATTR => 'model:MD_2003R', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'MD_2018R.*' => {ATTR => 'model:MD_2018R', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'MD_210R.*' => {ATTR => 'model:MD_210R', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'Momento.*' => {ATTR => 'model:Momento', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'OR28V.*' => {ATTR => 'model:OR28V', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'RCnoName20.*' => {ATTR => 'model:RCnoName20', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'DC_1961_TG.*' => {ATTR => 'model:DC_1961_TG', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'TC6861.*' => {ATTR => 'model:TR401', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'TR401.*' => {ATTR => 'model:TR401', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'Techmar.*' => {ATTR => 'model:Techmar', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'Visivo.*' => {ATTR => 'model:Visivo', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'xavax.*' => {ATTR => 'model:xavax', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'AC114_01B.*' => {ATTR => 'model:AC114_01B', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'BF_301.*' => {ATTR => 'model:BF_301', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'MD_2003R.*' => {ATTR => 'model:MD_2003R', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'MD_2018R.*' => {ATTR => 'model:MD_2018R', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'MD_210R.*' => {ATTR => 'model:MD_210R', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'Momento.*' => {ATTR => 'model:Momento', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'OR28V.*' => {ATTR => 'model:OR28V', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'RCnoName20.*' => {ATTR => 'model:RCnoName20', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'DC_1961_TG.*' => {ATTR => 'model:DC_1961_TG', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'TC6861.*' => {ATTR => 'model:TR401', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'TR401.*' => {ATTR => 'model:TR401', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'Techmar.*' => {ATTR => 'model:Techmar', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'Visivo.*' => {ATTR => 'model:Visivo', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'xavax.*' => {ATTR => 'model:xavax', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'Hamulight_AB.*' => {ATTR => 'model:Hamulight_AB', FILTER => '%NAME', autocreateThreshold => '3:180', GPLOT => q{}},
'unknown_please_select_model' => {ATTR => 'model:unknown', FILTER => '%NAME', autocreateThreshold => '5:180', GPLOT => q{}},
};
return FHEM::Meta::InitMod( __FILE__, $hash );
Expand All @@ -1068,6 +1086,9 @@ sub SD_UT_Define {
my $iodevice;
my $ioname;

# Anzeigen der Modulversion (Internal FVERSION) über FHEM::Meta, Variable in META.json Abschnitt erforderlich: "version": "v1.0.0", siehe https://wiki.fhem.de/wiki/Meta
return $@ unless ( FHEM::Meta::SetInternals($hash) );

# Argument 0 1 2 3 4
return 'wrong syntax: define <name> SD_UT <model> <HEX-Value> <optional IODEV>' if(int(@a) < 3 || int(@a) > 5);
return "wrong <model> $a[2]\n\n(allowed modelvalues: " . join(' | ', sort keys %models).')' if $a[2] && ( !grep { $_ eq $a[2] } %models );
Expand Down Expand Up @@ -1100,9 +1121,9 @@ sub SD_UT_Define {
### [3] checks SA_434_1_mini | QUIGG_DMV | TR_502MSV | BeSmart_S4 ###
# uncoverable branch true
return "wrong HEX-Value! ($a[3]) $a[2] HEX-Value to short or long (must be 3 chars) or not HEX (0-9 | a-f | A-F){3}" if (($a[2] eq 'SA_434_1_mini' || $a[2] eq 'QUIGG_DMV' || $a[2] eq 'TR_502MSV' || $a[2] eq 'BeSmart_S4') && not $a[3] =~ /^[0-9a-fA-F]{3}/xms);
### [4 nibble] checks Neff SF01_01319004 & BOSCH SF01_01319004_Typ2 & Chilitec_22640 & ESTO KL_RF01 & RCnoName20 & RCnoName20_10 & RCnoName128 & DC-1961-TG & xavax & BF_301 & Meikee_xx & CREATE_6601TL###
### [4 nibble] checks Neff SF01_01319004 & BOSCH SF01_01319004_Typ2 & Chilitec_22640 & ESTO KL_RF01 & RCnoName20 & RCnoName20_10 & RCnoName128 & DC-1961-TG & xavax & BF_301 & Meikee_xx & CREATE_6601TL & Hamulight_AB ###
# uncoverable branch true
return "Wrong HEX-Value! ($a[3]) $a[2] Hex-value to short or long (must be 4 chars) or not hex (0-9 | a-f | A-F) {4}" if (($a[2] eq 'SF01_01319004' || $a[2] eq 'SF01_01319004_Typ2' || $a[2] eq 'Chilitec_22640' || $a[2] eq 'KL_RF01' || $a[2] eq 'RCnoName20' || $a[2] eq 'RCnoName20_10' || $a[2] eq 'RCnoName128' || $a[2] eq 'DC_1961_TG' || $a[2] eq 'xavax' || $a[2] eq 'BF_301' || $a[2] eq 'Meikee_21' || $a[2] eq 'Meikee_24' || $a[2] eq 'CREATE_6601TL') && not $a[3] =~ /^[0-9a-fA-F]{4}/xms);
return "Wrong HEX-Value! ($a[3]) $a[2] Hex-value to short or long (must be 4 chars) or not hex (0-9 | a-f | A-F) {4}" if (($a[2] eq 'SF01_01319004' || $a[2] eq 'SF01_01319004_Typ2' || $a[2] eq 'Chilitec_22640' || $a[2] eq 'KL_RF01' || $a[2] eq 'RCnoName20' || $a[2] eq 'RCnoName20_10' || $a[2] eq 'RCnoName128' || $a[2] eq 'DC_1961_TG' || $a[2] eq 'xavax' || $a[2] eq 'BF_301' || $a[2] eq 'Meikee_21' || $a[2] eq 'Meikee_24' || $a[2] eq 'CREATE_6601TL' || $a[2] eq 'Hamulight_AB') && not $a[3] =~ /^[0-9a-fA-F]{4}/xms);
### [5 nibble] checks RCnoName127
# uncoverable branch true
return "Wrong HEX-Value! ($a[3]) $a[2] Hex-value to short or long (must be 5 chars) or not hex (0-9 | a-f | A-F) {5}" if ($a[2] eq 'RCnoName127' && not $a[3] =~ /^[0-9a-fA-F]{5}/xms);
Expand Down Expand Up @@ -1356,8 +1377,8 @@ sub SD_UT_Set {
} elsif ($model eq 'TC6861') {
$msg = $models{$model}{Protocol} . q{#P};
$msgEnd = '#R' . $repeats;
############ Meikee_21 | Meikee_24 | RCnoName128 | RCnoName20 | RCnoName20_10 | DC-1961-TG | CREATE_6601TL ############
} elsif ($model eq 'Meikee_21' || $model eq 'Meikee_24' || $model eq 'RCnoName128' || $model eq 'RCnoName20' || $model eq 'RCnoName20_10' || $model eq 'DC_1961_TG' || $model eq 'CREATE_6601TL') {
############ Meikee_21 | Meikee_24 | RCnoName128 | RCnoName20 | RCnoName20_10 | DC-1961-TG | CREATE_6601TL | Hamulight_AB ############
} elsif ($model eq 'Meikee_21' || $model eq 'Meikee_24' || $model eq 'RCnoName128' || $model eq 'RCnoName20' || $model eq 'RCnoName20_10' || $model eq 'DC_1961_TG' || $model eq 'CREATE_6601TL' || $model eq 'Hamulight_AB') {
my $adr = sprintf '%016b' , hex $definition[1]; # argument 1 - adress to binary with 16 bits
$msg = $models{$model}{Protocol} . q{#} . $adr;
$msgEnd = '#R' . $repeats;
Expand Down Expand Up @@ -1460,6 +1481,15 @@ sub SD_UT_Set {
Log3 $name, 5, "$ioname: SD_UT_Set $name bits=$split[1] sum=$sum";
$msg .= sprintf '%08b' , $sum;
$msg .= $msgEnd;
############ Hamulight_AB ############
} elsif ($model eq 'Hamulight_AB') {
$msg .= $save; # command
my @split = split /[#]/xms , $msg;
my $sum = oct ('0b'. substr $split[1],0,8) + oct ('0b'. substr $split[1],8,8) + oct ('0b'. substr $split[1],16,8);
$sum = ($sum - 83) & 0xFF;
Log3 $name, 5, "$ioname: SD_UT_Set $name bits=$split[1] sum=$sum";
$msg .= sprintf '%08b' , $sum;
$msg .= $msgEnd;
########### TR401 (Well-Light) #########
} elsif ($model eq 'TR401') {
my ($housecode, $ch) = split('_', $definition[1]);
Expand Down Expand Up @@ -1787,6 +1817,24 @@ sub SD_UT_Parse {
$name = $model . '_' . $deviceCode;
}
}
if (!$def && $protocol == 22) {
### Remote control Hamulight_AB [P22] ###
my $sum = 0;
for (my $n = 0; $n < 6; $n += 2) { # sum over 3 bytes
$sum += hex(substr($rawData, $n, 2));
}
$sum = ($sum - 83) & 0xFF;
if ($sum != hex(substr($rawData, 6, 2))) { # byte 4
Log3 $iohash, 3, "$ioname: SD_UT_Parse device Hamulight_AB - ERROR checksum $sum != " . hex(substr($rawData, 6, 2));
return '';
}
$deviceCode = substr($rawData,0,4);
$state = substr($bitData,16,8);
$model = 'Hamulight_AB';
$devicedef = 'Hamulight_AB ' . $deviceCode;
$name = 'Hamulight_AB' . '_' . $deviceCode;
$def = $modules{SD_UT}{defptr}{$devicedef};
}
if (!$def && $protocol == 92) {
### Remote control Krinner_LUMIX [P92] ###
$deviceCode = substr($rawData,0,7);
Expand Down Expand Up @@ -2573,6 +2621,9 @@ sub SD_UT_tristate2bin {
1;
=pod
=encoding utf8
=item summary module for some SIGNALduino devices
=item summary_DE Universalmodul f&uuml;r einige SIGNALduino Devices
=begin html
Expand Down Expand Up @@ -3035,6 +3086,7 @@ sub SD_UT_tristate2bin {
</ul>
=end html_DE

=for :application/json;q=META.json 14_SD_UT.pm
{
"author": [
Expand Down Expand Up @@ -3075,6 +3127,7 @@ sub SD_UT_tristate2bin {
}
}
},
"version": "v1.0.0",
"release_status": "stable",
"resources": {
"bugtracker": {
Expand Down
20 changes: 12 additions & 8 deletions FHEM/lib/SD_ProtocolData.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ package lib::SD_ProtocolData;
use strict;
use warnings;

our $VERSION = '1.54';
our $VERSION = '1.55';
our %protocols = (
"0" => ## various weather sensors (500 | 9100)
# Mebus | Id:237 Ch:1 T: 1.9 Bat:low MS;P0=-9298;P1=495;P2=-1980;P3=-4239;D=1012121312131313121313121312121212121212131212131312131212;CP=1;SP=0;R=223;O;m2;
Expand Down Expand Up @@ -787,26 +787,28 @@ package lib::SD_ProtocolData;
},
"22" => ## HAMULiGHT LED Trafo
# https://forum.fhem.de/index.php?topic=89301.0 | https://forum.fhem.de/index.php/topic,89643.msg822289.html#msg822289 @Michi240281
# remote with one button on/off
# remote with one button for toggle on/off
# u22#8F995F34 MU;P0=-196;P1=32001;P3=214;P4=1192;P5=-1200;P6=-595;P7=597;D=0103030453670707036363636367070363670703670367036363636367070363670367070303030304536707070363636363670703636707036703670363636363670703636703670703030303045367070703636363636707036367070367036703636363636707036367036707030303030453670707036363636367070;CP=3;R=15;
# u22#8F995F34 MU;P0=-604;P1=188;P2=583;P3=-224;P4=1199;P5=-1197;D=0102323102310231010101010232310102310232313131313451023232310101010102323101023231023102310101010102323101023102323131313134510232323101010101023231010232310231023101010101023231010231023231313131345102323231010101010232310102323102310231010101010232310;CP=1;R=15;
# u22#8F995F34 MU;P0=-614;P1=597;P2=-228;P3=171;P4=1184;P5=-1215;D=0123012123232323245301212123030303030121230301212301230123030303030121230301230121232323232453012121230303030301212303012123012301230303030301212303012301212323232324530121212303030303012123030121230123012303030303012123030123012;CP=3;R=7;
# u22#8F995F34 MU;P0=604;P1=-197;P2=205;P3=-595;P4=1194;P5=-1197;D=0101012323232323010123230101230123012323232323010123230123010121212121452301010123232323230101232301012301230123232323230101232301230101212121214523010101232323232301012323010123012301232323232301012323012301012121212145230101012323232323010123230101230;CP=2;R=17;
# u22#8F995F34 MU;P0=193;P1=-607;P2=605;P3=-209;P4=1204;P5=-1196;D=0123010101010123230101230123230303030345012323230101010101232301012323012301230101010101232301012301232303030303450123232301010101012323010123230123012301010101012323010123012323030303034501232323010101010123230101232301230123010101010123230101230123230;CP=0;R=18;
# u22#8F995F34 MU;P0=192;P1=-209;P2=1182;P3=-1214;P4=-606;P5=594;D=0101012304515151040404040451510404515104510451040404040451510404510451510101010123045151510404040404515104045151045104510404040404515104045104515101010101230451515104040404045151040451510451045104040404045151040451045150;CP=0;R=17;
# https://github.com/RFD-FHEM/RFFHEM/issues/1206 @ obduser 2023-12-09
{
name => 'HAMULiGHT',
comment => 'remote control for LED Transformator',
comment => 'Remote control for LED transformer',
id => '22',
knownFreqs => '433.92',
one => [1,-3],
zero => [3,-1],
start => [6,-6],
clockabs => 200, # ca 200us
start => [1,-1,1,-1,6,-6],
end => [1,-1,1,-1],
clockabs => 200,
format => 'twostate',
preamble => 'u22#',
#clientmodule => '',
#modulematch => '',
preamble => 'P22#',
clientmodule => 'SD_UT',
modulematch => '^P22#',
length_min => '32',
length_max => '32',
},
Expand Down Expand Up @@ -3470,6 +3472,8 @@ package lib::SD_ProtocolData;
length_max => '24',
},

# "131" reserved for => ## Bresser lightning sensor

########################################################################
#### ### register informations from other hardware protocols #### ####

Expand Down

0 comments on commit c4458ed

Please sign in to comment.