So. as promised herewith my perl script to program and switch your Quigg GT-FSI-08 switches. Place this script in the pi home directory of you RaspberryPi, name it SendQuiggCode.pl and call it with:
is the group-id (0..15) you want to use. Notice that not all group-id's have valid code sequences yet. You will get an appropriate error message if no codes available.
is your switch number (a,b,c,d or m). You get an error message when there is no code sequence available for the selected switch.
is the wanted state (on, off) of your switch. Notice that in order to program a switch you need to select the on state.
optional you may specify the code sequence (1..4) that should be used. If there is no specified code sequence the sequence 1 for that group will be used and you get an appropriate message.
optional the number of times you want to repeat this code. Notice that each repeat (for the default 1 times too) means that the code sequence is actually send 3 times by pilight. The first 2 times with a short start pulse, and the last time with a long start pulse. This is necessary for programming the switch. You could look at the last sequence as the program sequence.
This perl script is based on a script published earlier by Lary_Loose for the Lidl switches. See his contribution
Let me know if there are unclear things, difficulties, or whatever. And if you discovered your own codes for your group-id, do publish them here.
Code:
#!/usr/bin/perl
## This script creates raw code sequences for Quigg GT-FSI-08 switches and compatibles.
## The script is based on a script published earlier by Lary_Loose
## see http://forum.pilight.org/Thread-Lidl-radio-outlets?page=2
##
## All codes are testen and do work with the Quigg switches. For some group-id not all 4
## codes per switch are known. But then, you only need a single code per switch action.
## A11 means unit A first ON code, A12 the second ON code, A01 the first OFF code ...
## M is the Master code, which switches all the units. The rest should be self explaining.
## If needed adjust the pilight-send path in the $exe variable.
##
## You need to specify wanted group-id (0 .. 15), switch unit (a,b,c,d or m) and state (on,off)
## You may specify the code sequence to use (1..4) and the number of repeats. When you specify
## a group-id for which there are no codes available you get an error message. When you specify
## a code sequence that has not been specified, then code sequence 1 will be used or if not
## available another error message will be given. But the script is no foll prove, so other
## error messages and program halts will be possible.
##
## Notice that a code sequence is repeated 3 times, the first two with a short start pulse
## (350 us high, 2340 us low) and the last one with a long start pulse (3000 us high, 7300 us low)
## The first tow are needed for teh on-off switch actions, all three together are for programming a switch.
use strict;
use warnings;
$. = ' ';
if (@ARGV < 3)
{
use File::Basename;
printf("usage:\n %s <id> <unit> <state> [codeseq] [repeat]\n", basename($0));
printf(" id: [0..15]\n");
printf(" unit: [ A B C D M ]\n");
printf(" state: [ on off ]\n");
printf(" codeseq:[1 2 3 4]\n");
printf(" repeat: [ 0 1 2 ... ]\n");
exit 1;
}
my $exe = '/usr/local/bin/pilight-send -p raw -c ';
my $id = $ARGV[0];
my $unit = uc($ARGV[1]);
my $istate = (uc($ARGV[2]) eq 'ON') ? 1 : 0;
my $codeseq = ($ARGV[3]) ? $ARGV[3] : (int(rand(4))+1);
my $repeat = ($ARGV[4]) ? $ARGV[4] : 0;
my %code0;
my %code1;
my %code2;
my %code3;
my %code4;
my %code5;
my %code6;
my %code7;
my %code8;
my %code9;
my %code10;
my %code11;
my %code12;
my %code13;
my %code14;
my %code15;
%code14 = (
# codes for switches RvW
'A11', '0000101011010110', 'A12', '1011110110100001', 'A13', '1100010001100101', 'A14', '0110111101001010',
'A01', '1110011010010010', 'A02', '1001100011111000', 'A03', '0101011101111011', 'A04', '0101011101111011',
'B11', '0001001110000011', 'B12', '1101110000101111', 'B13', '0100000011001110', 'B14', '0011111000000000',
'B01', '1111001000110100', 'B02', '1000100111101100', 'B03', '0010010100011001', 'B04', '0111000101011101',
'C11', '0101011101111011', 'C12', '1010101110110111', 'C13', '1110011010010010', 'C14', '1001100011111000',
'C01', '1011110110100001', 'C02', '1100010001100101', 'C03', '0110111101001010', 'C04', '0000101011010110',
'D11', '0111000101011101', 'D12', '1111001000110100', 'D13', '1000100111101100', 'D14', '0010010100011001',
'D01', '1101110000101111', 'D02', '0100000011001110', 'D03', '0011111000000000', 'D04', '0001001110000011',
'M11', '1010101110110111', 'M12', '0101011101111011', 'M13', '1001100011111000', 'M14', '1110011010010010',
'M01', '0000101011010110', 'M02', '0110111101001010', 'M03', '1100010001100101', 'M04', '1011110110100001'
);
%code1 = (
# codes from Oitzu for Lidl radio outlets
'A11', '1111010110011011', 'A12', '1110100100100011', 'A13', '0001010011000100', 'A14', '0011001010100111',
'A01', '0110000101101010', 'A02', '1100111101110001', 'A03', '0111101011100010', 'A04', '1011011000111001',
'B11', '0001010011000100', 'B12', '0011001010100111', 'B13', '1111010110011011', 'B14', '1110100100100011',
'B01', '0110000101101010', 'B02', '1011011000111001', 'B03', '1100111101110001', 'B04', '0111101011100010',
'C11', '1110100100100011', 'C12', '1111010110011011', 'C13', '0001010011000100', 'C14', '0011001010100111',
'C01', '1100111101110001', 'C02', '0110000101101010', 'C03', '0111101011100010', 'C04', '1011011000111001',
'D11', '0111101011100010', 'D12', '0110000101101010', 'D13', '1100111101110001', 'D14', '1011011000111001',
'D01', '0001010011000100', 'D02', '1110100100100011', 'D03', '1111010110011011', 'D04', '0011001010100111',
'M11', '0111101011100010', 'M12', '0110000101101010', 'M13', '1011011000111001', 'M14', '1100111101110001',
'M01', '0001010011000100', 'M02', '1110100100100011', 'M03', '1111010110011011', 'M04', '0011001010100111'
);
%code3 = (
# codes from Lary Loose for Lidl radio outlets
'A11', '0000011001111010', 'A12', '0010100100000001', 'A13', '1011000110110110', 'A14', '1110101000110101',
'A01', '0011001011010111', 'A02', '0111110101001011', 'A03', '1001010010000010', 'A04', '1100100000011000',
'B11', '0001111110100000', 'B12', '0100110011001111', 'B13', '1010011110010011', 'B14', '1101000000101110',
'B01', '0101101101011100', 'B02', '0110001101100100', 'B03', '1000010111111001', 'B04', '1111111011101101',
'C11', '0011001011010111', 'C12', '0111110101001011', 'C13', '1001010010000010', 'C14', '1100100000011000',
'C01', '0000011001111010', 'C02', '0010100100000001', 'C03', '1011000110110110', 'C04', '1110101000110101',
'D11', '0101101101011100', 'D12', '0110001101100100', 'D13', '1000010111111001', 'D14', '1111111011101101',
'D01', '0001111110100000', 'D02', '0100110011001111', 'D03', '1010011110010011', 'D04', '1101000000101110',
'M11', '0011001011010111', 'M12', '0111110101001011', 'M13', '1001010010000010', 'M14', '1100100000011000',
'M01', '0000011001111010', 'M02', '0010100100000001', 'M03', '1011000110110110', 'M04', '1110101000110101'
);
%code10 = (
# see https://github.com/peterand/BATsender for Lidl outlets
'A11', '0100011000001010', 'A12', '0111011111100110', 'A13', '0110100101110001', 'A14', '1011101100100101',
'A01', '1110000001010111', 'A02', '1111010011110010', 'A03', '1001111010011000', 'A04', '1100001010101011',
'B11', '1101101001000000', 'B12', '0010001100010011', 'B13', '0011100001101111', 'B14', '1010110100111110',
'B01', '0001010110001001', 'B02', '0000110010111101', 'B03', '0101000111000100', 'B04', '1000111111011100',
'C11', '1001111010011000', 'C12', '1100001010101011', 'C13', '1110000001010111', 'C14', '1111010011110010',
'C01', '0100011000001010', 'C02', '0111011111100110', 'C03', '0110100101110001', 'C04', '1011101100100101',
'D11', '0000110010111101', 'D12', '0101000111000100', 'D13', '1000111111011100', 'D14', '0001010110001001',
'D01', '0010001100010011', 'D02', '0011100001101111', 'D03', '1010110100111110', 'D04', '1101101001000000',
'M11', '1001111010011000', 'M12', '1111010011110010', 'M13', '1110000001010111', 'M14', '1100001010101011',
'M01', '0100011000001010', 'M02', '1011101100100101', 'M03', '0110100101110001', 'M04', '0111011111100110'
);
%code9 = (
# only 1 code per action
'A11', '0110111011100111', 'A01', '1100000010100010', 'B11', '0110111011100111', 'B01', '1100000010100010',
'C11', '0000001011111011', 'C01', '0001101100011010', 'D11', '0001101100011010', 'D01', '0110111011100111',
'M11', '0111010111000001', 'M01', '0110111011100111'
);
%code15 = (
# only 1 code per action, no M code
'A11', '0010011000110110', 'A01', '1001101100011011', 'B11', '1010100001011111', 'B01', '0101010011001100',
'C11', '0001000001100111', 'C01', '1110010110110101', 'D11', '1100011111010100', 'D01', '0111001010010000'
);
%code5 = (
# all verified
'A11', '0001111110111011', 'A12', '0011100111100100', 'A13', '1010011101000011', 'A14', '1111111001110111',
'A01', '0010001111000010', 'A02', '0111000110100001', 'A03', '1000100011011010', 'A04', '1101110000011001',
'B11', '0001111110111011', 'B12', '0011100111100100', 'B13', '1010011101000011', 'B14', '1111111001110111',
'B01', '0010001111000010', 'B02', '0111000110100001', 'B03', '1000100011011010', 'B04', '1101110000011001',
'C11', '0001111110111011', 'C12', '0011100111100100', 'C13', '1010011101000011', 'C14', '1111111001110111',
'C01', '0010001111000010', 'C02', '0111000110100001', 'C03', '1000100011011010', 'C04', '1101110000011001',
'D11', '0010001111000010', 'D12', '0111000110100001', 'D13', '1000100011011010', 'D14', '1101110000011001',
'D01', '0001111110111011', 'D02', '0011100111100100', 'D03', '1010011101000011', 'D04', '1111111001110111',
'M11', '0010001111000010', 'M12', '0111000110100001', 'M13', '1000100011011010', 'M14', '1101110000011001',
'M01', '0001111110111011', 'M02', '0011100111100100', 'M03', '1010011101000011', 'M04', '1111111001110111'
);
my @codes = (\%code0, \%code1, \%code2, \%code3, \%code4, \%code5, \%code6, \%code7,
\%code8, \%code9, \%code10, \%code11, \%code12, \%code13, \%code14, \%code15); #contains reference to
if (! %{$codes[$id]}) { # test if there is a code hash for this group-id
printf("For group-id %d there is no code available!\n", $id);
exit(1);
}
my %unitselo = (
#select unitcode for selected headers ("old" switches)
'A', '0000', 'B', '0100', 'C', '1100', 'D', '0010', 'M', '1010'
);
my %unitseln = (
#select unitcode for latest switches
'A', '1100', 'B', '0101', 'C', '1110', 'D', '0111', 'M', '0010'
);
my $unitsel = \%unitseln;
foreach (1, 5, 9) { # specify group-id for which the "old" switch select is valid.
if ($_ == $id) {
$unitsel = \%unitselo;
}
}
my $starthi = 350;
my $startlo = 2340;
my $proghi = 3000;
my $proglo = 7300;
my $highmark = 1100; # high value duration for logic 1
my $highspace = 440; # low value duration for logic 1
my $lowmark = 330; # high value duration for logic 0
my $lowspace = 1210; # low value duration for logic 0
my $starter = "$starthi $startlo"; # normal start pulse
my $progter = "$proghi $proglo"; # long start pulse for programmode
my $footer = "200";
my $high = "$highmark $highspace"; # pulse for logic 1
my $low = "$lowmark $lowspace"; # pulse for logic 0
my $bincode = $codes[$id]->{"$unit$istate$codeseq"}; #indirection @{$codes[index]} or with ->
if (! defined($bincode)) { # if no hash code available
my $codeseq_old = $codeseq;
$codeseq=1;
$bincode = $codes[$id]->{"$unit$istate$codeseq"};
if (! defined($bincode)) { # if still no hash code available
printf("Could not find any codeseq for switch %d:%1s-%s. Aborting!\n", $id, $unit, $ARGV[2]);
exit(1);
}
printf("For group-id %d there is no codeseq# %d. Using 1 instead!\n", $id, $codeseq_old);
}
$bincode = sprintf("%04b", $id).$bincode.$unitsel->{$unit};
printf("Code#%s for switch %d:%1s-%s = %s\n",$codeseq, $id, $unit, $ARGV[2], $bincode);
my @rawcode;
for my $i (0 .. (length($bincode)-1))
{
push(@rawcode, (substr($bincode, $i, 1) eq '1') ? $high : $low);
}
for my $i (0 .. $repeat)
{
my $out = `$exe "$starter @rawcode $starter @rawcode $progter @rawcode $footer"`;
# note that we "throw" a long (3x24 bits) code sequence to pilight-send
my $rc = $? >> 8;
print $out;
if ($rc) { exit $rc; }
}
exit 0;