Add codes for brennenstuhl plugs

This commit is contained in:
sqozz 2018-03-12 23:39:14 +01:00
parent 0e659a6f97
commit 9e3f87cc25

View file

@ -33,13 +33,20 @@ typedef struct {
char* id; char* id;
String name; String name;
bool powered; bool powered;
uint8_t type; // 0=DIP, 1=Learned
int on_code;
int off_code;
} PowerSocket; } PowerSocket;
PowerSocket sockets[] = { PowerSocket sockets[] = {
(PowerSocket) {"00000", "10000", "A", false}, (PowerSocket) {"00000", "10000", "A", false, 0, -1, -1},
(PowerSocket) {"00000", "01000", "B", false}, (PowerSocket) {"00000", "01000", "B", false, 0, -1, -1},
(PowerSocket) {"00000", "00100", "C", false}, (PowerSocket) {"00000", "00100", "C", false, 0, -1, -1},
(PowerSocket) {"00000", "00010", "D", false} (PowerSocket) {"00000", "00010", "D", false, 0, -1, -1},
(PowerSocket) {"", "", "E", false, 1, 530800, 713872},
(PowerSocket) {"", "", "F", false, 1, 172340, 409380},
(PowerSocket) {"", "", "G", false, 1, 842428, 409388},
(PowerSocket) {"", "", "H", false, 1, 713874, 530802}
}; };
int numofsockets = sizeof(sockets)/sizeof(sockets[0]); int numofsockets = sizeof(sockets)/sizeof(sockets[0]);
@ -187,12 +194,29 @@ String setSocket(int socketIdx, bool newStatus) {
sockets[socketIdx] = socket; // write back to status array sockets[socketIdx] = socket; // write back to status array
if (newStatus == true) { if (newStatus == true) {
for (char i = 0; i <= 1; i++) { for (char i = 0; i <= 1; i++) {
mySwitch.switchOn(socket.channel, socket.id); if (socket.type == 0) {
Serial.println("id socket");
mySwitch.setProtocol(1);
mySwitch.switchOn(socket.channel, socket.id);
} else if (socket.type == 1) {
Serial.println("learning socket");
mySwitch.setProtocol(5);
mySwitch.send(socket.on_code, 24);
}
delay(250); delay(250);
} }
} else { } else {
for (char i = 0; i <= 1; i++) { for (char i = 0; i <= 1; i++) {
mySwitch.switchOff(socket.channel, socket.id); if (socket.type == 0) {
Serial.println("id socket");
mySwitch.setProtocol(1);
mySwitch.switchOff(socket.channel, socket.id);
} else if (socket.type == 1) {
Serial.println("learning socket");
char* off_code = socket.id;
mySwitch.setProtocol(5);
mySwitch.send(socket.off_code, 24);
}
delay(250); delay(250);
} }
} }